📄 unsendedreportlistadd.aspx.cs
字号:
/**************************************************************************************
作者:Created By zhouzheng.
创建日期:2002-11-11
修改者:
修改日期:
修改部分:
类功能:增加未发送工作汇报
****************************/
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using OI.DatabaseOper ;
using System.Diagnostics ;
namespace OI.Report
{
/// <summary>
/// unSendedReportListAdd 的摘要说明。
/// </summary>
public class unSendedReportListAdd : OI.PageBase
{
protected System.Web.UI.WebControls.TextBox TextBoxTitle;
protected System.Web.UI.WebControls.DropDownList DropDownListUserID;
protected System.Web.UI.WebControls.TextBox TextBoxFileDescription;
protected System.Web.UI.WebControls.TextBox TextBoxContent;
protected System.Web.UI.WebControls.Button ButtonSave;
protected System.Web.UI.WebControls.Button ButtonSend;
protected System.Web.UI.HtmlControls.HtmlInputFile FilePath;
protected System.Web.UI.WebControls.Label LabelWarning;
private DatabaseConnect dc;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (!IsPostBack)
{
dc =new DatabaseConnect();
this.Bind();
}
}
private void Complete()
{
this.ButtonSave.Visible=true;
this.ButtonSend.Visible=true;
this.TextBoxContent.ReadOnly=true;
this.TextBoxFileDescription.ReadOnly=true;
this.TextBoxTitle.ReadOnly=true;
this.DropDownListUserID.Enabled=false;
}
/// <summary>
/// 绑定用户姓名
/// </summary>
private void Bind()
{
string strSQL ="select * from Accounts_Users";
DataSet ds=dc.getBinding(strSQL,"Accounts_Users");
this.DropDownListUserID.DataSource =ds.Tables ["Accounts_Users"];
DropDownListUserID.DataTextField=ds.Tables[0].Columns["UserName"].ToString ();;
DropDownListUserID.DataValueField= ds.Tables[0].Columns["UserID"].ToString ();;
this.DropDownListUserID.DataBind ();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
this.ButtonSend.Click += new System.EventHandler(this.ButtonSend_Click);
this.DropDownListUserID.SelectedIndexChanged += new System.EventHandler(this.DropDownListUserID_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
/// <summary>
/// 保存工作汇报
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonSave_Click(object sender, System.EventArgs e)
{
if(!this.IsValid)
return;
dc=new DatabaseConnect();
string texTitle =OI.Modules.String.GenSafeChars(this.TextBoxTitle.Text.Trim());
string texFileDescription =OI.Modules.String.GenSafeChars(this.TextBoxFileDescription.Text.Trim());
string texContent =OI.Modules.String.GenSafeChars(this.TextBoxContent.Text.Trim());
string fileName="";
string path="";
string fullPath="";
//上传附件
if(this.FilePath.PostedFile.ContentLength>0)
{
fileName=OI.Modules.FileName.NewFileName(this.FilePath.PostedFile.FileName);
path =OI.Modules.Config.GetSetting("reportAccessories");
fullPath=Server.MapPath(path+"\\"+fileName);
try
{
this.FilePath.PostedFile.SaveAs(fullPath);
}
catch
{
this.RegisterClientScriptBlock("dd","<script language=javascript>\n alert(\"附件未保存成功!\"); \n </script>\n");
return;
}
}
else
{
return;
}
string sql1 ="insert into report(Title,FilePath,FileDescription,Content,IsSend,ReportDate,DeleteSign,UserID)"+
"values('"+texTitle+"','"+fullPath+"','"+texFileDescription+"','"+texContent+"','0','"+System.DateTime.Now+"','0','"+this.User.Identity.Name+"')";
dc.addData(sql1);
this.Complete();
this.LabelWarning.Text ="工作汇报保存成功";
}
private void DropDownListUserID_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
private void ButtonSend_Click(object sender, System.EventArgs e)
{
if(!this.IsValid)
return;
dc=new DatabaseConnect();
string texTitle =OI.Modules.String.GenSafeChars(this.TextBoxTitle.Text.Trim());
string texFileDescription =OI.Modules.String.GenSafeChars(this.TextBoxFileDescription.Text.Trim());
string texContent =OI.Modules.String.GenSafeChars(this.TextBoxContent.Text.Trim());
int intUserID =Convert.ToInt32(this.DropDownListUserID.SelectedItem.Value);
string fileName="";
string path="";
string fullPath="";
if(this.FilePath.PostedFile.ContentLength>0)
{
fileName=OI.Modules.FileName.NewFileName(this.FilePath.PostedFile.FileName);
path =OI.Modules.Config.GetSetting("toFilePath");
fullPath=Server.MapPath(path+"\\"+fileName);
try
{
this.FilePath.PostedFile.SaveAs(fullPath);
}
catch
{
this.RegisterClientScriptBlock("附件未保存成功!","<script language=javascript>\n alert(\"false\"); \n </script>\n");
return;
}
}
else
{
return;
}
string sql2 ="insert into report(Title,FilePath,FileDescription,Content,IsSend,ReportDate,DeleteSign,UserID)"+
"values('"+texTitle+"','"+fullPath+"','"+texFileDescription+"','"+texContent+"','1','"+System.DateTime.Now+"','0','"+this.User.Identity.Name+"')";
dc.addData(sql2);
this.Complete();
this.LabelWarning.Text ="工作汇报发送成功";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -