📄 newdocument.aspx.cs
字号:
TableRow tr = new TableRow();
TableCell tdPotiler = new TableCell();
TableCell tdPostilTime = new TableCell();
TableCell tdPotilType = new TableCell();
TableCell tdPotilContent = new TableCell();
TableCell tdAttachFiles = new TableCell();
TableCell tdTime = new TableCell();
tdPotiler.Text ="批阅人";
tdPotiler.HorizontalAlign = HorizontalAlign.Center;
tdPotiler.Width = Unit.Percentage(20);
tdPostilTime.Text ="批阅时间";
tdPostilTime.HorizontalAlign = HorizontalAlign.Center;
tdPostilTime.Width = Unit.Percentage(20);
tdPotilType.Text ="批阅类型";
tdPotilType.HorizontalAlign = HorizontalAlign.Center;
tdPotilType.Width = Unit.Percentage(10);
tdPotilContent.Text ="批阅内容";
tdPotilContent.HorizontalAlign = HorizontalAlign.Left ;
tdPotilContent.Width = Unit.Percentage(30);
tdAttachFiles.Text ="附件";
tdAttachFiles.HorizontalAlign = HorizontalAlign.Center ;
tdAttachFiles.Width = Unit.Percentage(10);
tdTime.Text ="用时(分)";
tdTime.HorizontalAlign = HorizontalAlign.Center ;
tdTime.Width = Unit.Percentage(10);
tr.Height =22;
tr.BackColor = Color.FromArgb(0xe8,0xf4,0xff);
tr.Cells.Add(tdPotiler);
tr.Cells.Add(tdPostilTime);
tr.Cells.Add(tdPotilType);
tr.Cells.Add(tdPotilContent);
tr.Cells.Add(tdAttachFiles);
tr.Cells.Add(tdTime);
tab.Rows.Add(tr);
tdPotiler = null;
tdPostilTime = null;
tdPotilType = null;
tdPotilContent = null;
tr = null;
}
private void AddProjectControl()
{
if(ddlProject.Visible == true)
{
TableRow tr = new TableRow();
TableCell td = new TableCell();
TableCell tl = new TableCell();
td.Text = "请选择所属项目:";
td.HorizontalAlign = HorizontalAlign.Right;
tr.Cells.Add(td);
ddlProject.Style["Width"] = "450px";
ddlProject.Style["Class"] = "Input3";
tl.Controls.Add(ddlProject);
tr.Cells.Add(tl);
ht.Rows.Add(tr);
td = null;
tr = null;
//ddlProject.EnableViewState =true;
}
}
private void AddAttach(long DocID)
{
UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
DataTable dt = new DataTable();
df.GetDocumentAttach(DocID,out dt);
for(int i=0;i<dt.Rows.Count;i++)
{
TableRow tr = new TableRow();
TableCell td = new TableCell();
TableCell tc = new TableCell();
td.Text ="附件:";
td.HorizontalAlign = HorizontalAlign.Right;
string FilePath = dt.Rows[i]["FileVisualPath"].ToString() + dt.Rows[i]["FileName"].ToString();
tc.Text = "<a href='" +"." + FilePath.Replace("\\","/") +"' target='_blank'>" + dt.Rows[i]["FileName"].ToString() + "</a>";
tc.HorizontalAlign = HorizontalAlign.Left;
tr.Cells.Add(td);
tr.Cells.Add(tc);
tr.Height = 22;
tr.HorizontalAlign = HorizontalAlign.Center;
ht.Rows.Add(tr);
}
dt = null;
df = null;
}
private void AddAttachControl()
{
string Template;
UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
Template = df.GetStyleTemplate(FlowID);
if(Template!="")
{
TableRow tr = new TableRow();
TableCell td = new TableCell();
TableCell tl = new TableCell();
td.Text = "<a href='" + Template + "' style='text-decoration: underline' titile='模板下载' target='_blank'>模板</a>:";
td.HorizontalAlign = HorizontalAlign.Right;
tr.Cells.Add(td);
System.Web.UI.HtmlControls.HtmlInputFile hif = new System.Web.UI.HtmlControls.HtmlInputFile();
hif.ID = "fileTemplate";
hif.Name = "fileTemplate";
hif.Style["width"] = "450px";
hif.Style["Class"] = "Input3";
tl.Controls.Add(hif);
tr.Cells.Add(tl);
ht.Rows.Add(tr);
td = null;
tr = null;
}
df = null;
}
private void UploadFile(long DocID)
{
string FileName = "";
HtmlForm FrmCompose = (HtmlForm)this.Page.FindControl("NewDocument");
//生成附件目录
if(!System.IO.Directory.Exists(Server.MapPath(".")+"\\AttachFiles"))
{
System.IO.Directory.CreateDirectory(Server.MapPath(".")+"\\AttachFiles");
}
try
{
HtmlInputFile hif = ((HtmlInputFile)(FrmCompose.FindControl("fileTemplate")));
if(hif.PostedFile!=null)
{
if(hif.PostedFile.FileName.Trim()!="")
{
FileName = System.IO.Path.GetFileName(hif.PostedFile.FileName);
//生成用户目录
if(!System.IO.Directory.Exists(Server.MapPath(".")+"\\AttachFiles\\" + UserName))
{
System.IO.Directory.CreateDirectory(Server.MapPath(".")+"\\AttachFiles\\"+ UserName);
}
Random TempNameInt = new Random();
string NewDocDirName = TempNameInt.Next(100000000).ToString();
//生成随机目录
if(!System.IO.Directory.Exists(Server.MapPath(".")+"\\AttachFiles\\" + UserName + "\\" + NewDocDirName))
{
System.IO.Directory.CreateDirectory(Server.MapPath(".")+"\\AttachFiles\\" + UserName + "\\" + NewDocDirName);
}
TempNameInt = null;
//保存文件
hif.PostedFile.SaveAs(Server.MapPath(".")+"\\AttachFiles\\" + UserName + "\\" + NewDocDirName + "\\" + FileName);
UDS.Components.DocAttachFile att = new UDS.Components.DocAttachFile();
UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
// 初始化
att.FileAttribute = 0;
att.FileSize = hif.PostedFile.ContentLength;
att.FileName = FileName;
att.FileAuthor = UserName;
att.FileCatlog = "公文";
att.FileVisualPath = "\\AttachFiles\\" + UserName + "\\" + NewDocDirName + "\\";
att.FileAddedDate = DateTime.Now.ToString();;
df.AddAttach(att,DocID);
df = null;
att = null;
}
hif=null;
}
}
catch(Exception ex)
{
UDS.Components.Error.Log(ex.ToString());
}
finally
{
}
}
private void AddHeadlin()
{
UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
TableRow tr = new TableRow();
TableCell td = new TableCell();
td.Text = df.GetStyleHeadline(FlowID);
td.ColumnSpan = 2;
td.Height = 28;
td.Attributes["BackGround"] = "../../../images/treetopbg.jpg";
tr.Cells.Add(td);
tr.HorizontalAlign = HorizontalAlign.Center;
tr.BackColor = Color.FromArgb(0xff,0xff,0xef);
ht.Rows.Add(tr);
td = null;
tr = null;
df = null;
}
private void AddControl()
{
TableRow tr = new TableRow();
TableCell td = new TableCell();
cmdSave.Style["Top"] = td.Style["Top"];
td.Controls.Add(cmdSave);
td.Controls.Add(cmdSend);
td.Controls.Add(cmdDelete);
td.Controls.Add(cmdReturn);;
td.ColumnSpan = 2;
tr.Cells.Add(td);
tr.HorizontalAlign = HorizontalAlign.Center;
ht.Rows.Add(tr);
// td = null;
// tr = null;
}
private string GetStyleInsertData()
{
string mySql="";
HtmlForm FrmNewDocument = (HtmlForm)this.Page.FindControl("NewDocument");
mySql += "insert into UDS_Flow_Style_Data (";
for(int i=0;i<FieldNum;i++)
{
mySql += al[i].ToString()+",";
}
mySql = mySql.Substring(0,mySql.Length-1)+") values(";
for(int i=0;i<FieldNum;i++)
{
mySql += "'" + ((TextBox)FrmNewDocument.FindControl("txt" + al[i].ToString())).Text.Replace("'","''") + "',";
}
mySql = mySql.Substring(0,mySql.Length-1)+")";
return mySql;
}
private string GetStyleUpdateData(long DocID)
{
string mySql="";
HtmlForm FrmNewDocument = (HtmlForm)this.Page.FindControl("NewDocument");
if( FieldNum>0)
{
mySql += "update UDS_Flow_Style_Data set ";
for(int i=0;i<FieldNum;i++)
{
mySql += al[i].ToString()+"=" + "'" + ((TextBox)FrmNewDocument.FindControl("txt" + al[i].ToString())).Text.Replace("'","''") + "'";
if(i!=(FieldNum-1))
mySql += ",";
}
mySql += " where Doc_ID = " + DocID.ToString();
return mySql;
}
else
{
return "Select 1";
}
}
private void cmdSend_Click(object sender, System.EventArgs e)
{
//发送到下一环节,使程序处于运行中
UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
if(ProjectID>=0)
{
int iResult = df.PostDocument(UserName,DocID,ProjectID);
if(iResult==0)
{
df = null;
Server.Transfer("DisplayDocument.aspx?DocID=" + DocID.ToString());
}
else
{
Response.Write("<script lanuage='javascript'>alert('" + df.DoMessage(iResult,DocID,false) + "');</script>");
}
}
else
Response.Write("<script language='javascript'>alert('用户没有一个项目,不能按项目发送!');</script>");
df = null;
}
private void cmdDelete_Click(object sender, System.EventArgs e)
{
//删除拟稿文档
UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
df.DeleteDocument(DocID);
df = null;
Server.Transfer("FlowTemplate.aspx");
}
private void cmdReturn_Click(object sender, System.EventArgs e)
{
Server.Transfer("DraftList.aspx");
}
private void cmdSave_Click(object sender, System.EventArgs e)
{
UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
string mySql;
if(bEditMode==false)
{
mySql= GetStyleInsertData();
//拟稿
DocID=df.AddDocument(UserName,FlowID,mySql);
//上传文件
UploadFile(DocID);
df = null;
//转到查看稿件
Server.Transfer("NewDocument.aspx?FlowID=" + FlowID.ToString() + "&DocID=" + DocID.ToString());
}
else
{
mySql = GetStyleUpdateData(DocID);
//Response.Write("<script language='javascript'>alert('" + mySql + "');</script>");
df.UpdateDocument(mySql);
string FileName = df.GetAttachName(DocID);
if(FileName.Length>0)
{
df.DeleteAttach(DocID);
if(System.IO.File.Exists(Server.MapPath(@"." + FileName))==true)
System.IO.File.Delete(Server.MapPath(@"." + FileName));
}
//上传文件
UploadFile(DocID);
df = null;
//修改编辑文件
}
Response.AddHeader("Refresh","1");
}
private void PID_ServerChange(object sender, System.EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -