NewDocument.aspx.cs
上传用户:cha0314
上传日期:2014-03-02
资源大小:12522k
文件大小:21k
源码类别:

C#编程

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Web;
  7. using System.Web.SessionState;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.HtmlControls;
  11. using System.IO;
  12. using UDS.Components;
  13. using System.Data.SqlClient;
  14. namespace UDS.SubModule.UnitiveDocument.DocumentFlow
  15. {
  16. /// <summary>
  17. /// NewDocument 的摘要说明。
  18. /// </summary>
  19. public class NewDocument : System.Web.UI.Page
  20. {
  21. protected System.Web.UI.WebControls.Table ht;
  22. protected System.Web.UI.WebControls.TextBox TextBox1;
  23. protected System.Web.UI.WebControls.Label Label1;
  24. protected System.Web.UI.WebControls.Button cmdDelete;
  25. protected System.Web.UI.WebControls.Button cmdReturn;
  26. protected System.Web.UI.WebControls.Button cmdSend;
  27. protected System.Web.UI.WebControls.Button cmdSave;
  28. private long StepID;
  29. private long FlowID;
  30. private long FieldNum=0;
  31. private long DocID;
  32. private bool bEditMode;
  33. private string UserName;
  34. protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
  35. protected System.Web.UI.WebControls.TextBox TextBox2;
  36. private long ProjectID=-1;
  37. protected System.Web.UI.HtmlControls.HtmlInputHidden PID;
  38. protected System.Web.UI.HtmlControls.HtmlSelect ddlProject;
  39. private ArrayList al = new ArrayList(); 
  40. private void Page_Load(object sender, System.EventArgs e)
  41. {
  42. FlowID = Int32.Parse(Request.QueryString["FlowID"]==null?"0":Request.QueryString["FlowID"].ToString());
  43. DocID = Int32.Parse(Request.QueryString["DocID"]==null?"0":Request.QueryString["DocID"].ToString());
  44. UserName = Request.Cookies["UserName"].Value.ToString(); 
  45. //动态添加控件
  46. //if(!Page.IsPostBack)
  47. Bind();
  48. InitControl(DocID);
  49. }
  50. private void Bind()
  51. {
  52. UDS.Components.DocumentFlow df =new UDS.Components.DocumentFlow();
  53. if(DocID>0)
  54. {
  55. //读取稿件内容
  56. FlowID = df.GetDocumentFlowID(DocID);
  57. StepID = df.GetDocumentStepID(DocID);
  58. ProjectID = 0;
  59. cmdSend.Enabled = true;
  60. cmdDelete.Enabled = true;
  61. bEditMode = true;
  62. if(df.IsProject(UserName,DocID))
  63. {
  64. ProjectID = Int32.Parse(PID.Value);
  65. if(!Page.IsPostBack)
  66. {
  67. DataTable dt;
  68. ddlProject.Visible = true;
  69. ddlProject.Items.Clear();
  70. df.GetProject(UserName,out dt);
  71. ddlProject.DataSource = dt.DefaultView;
  72. ddlProject.DataTextField = "ClassName";
  73. ddlProject.DataValueField = "ClassID";
  74. ddlProject.DataBind();
  75. // for(int i=0;i<ddlProject.Items.Count;i++)
  76. // {
  77. // if(ddlProject.Items[i].Value.ToString()==UDS.Components.DocumentFlow.GetDocumentProjectID(DocID).ToString())
  78. // ddlProject.SelectedIndex = i;
  79. // }
  80. if(ddlProject.Items.Count>0)
  81. {
  82. PID.Value = ddlProject.Items[0].Value.ToString(); 
  83. }
  84. }
  85. }
  86. else
  87. {
  88. // StepID = 1;
  89. // cmdSend.Enabled = false;
  90. // cmdDelete.Enabled = false;
  91. // bEditMode = false;
  92. ddlProject.Visible = false;
  93. ddlProject.EnableViewState = false;
  94. }
  95. }
  96. else
  97. {
  98. StepID = 1;
  99. cmdSend.Enabled = false;
  100. cmdDelete.Enabled = false;
  101. bEditMode = false;
  102. ddlProject.EnableViewState = false;
  103. ddlProject.Visible = false;
  104. }
  105. df = null;
  106. }
  107. private void InitControl(long DocID)
  108. {
  109. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  110. SqlDataReader dr; //存放人物的数据
  111. DataTable dt = null;
  112. df.GetStyleDescription(FlowID,0,out dr); 
  113. if(DocID>0)
  114. df.GetDocumentInfo(DocID,out dt);
  115. ht.Style["Left"]="1px";
  116. ht.Style["Top"]="1px";
  117. al.Clear();
  118. AddHeadlin();
  119. while(dr.Read())
  120. {
  121. TextBox txt = new TextBox();
  122. txt.ID ="txt" + dr["Field_Name"].ToString();
  123. al.Add(dr["Field_Name"].ToString());
  124. if(dr["MultiLine"].ToString()!="False")
  125. {
  126. txt.TextMode = TextBoxMode.MultiLine; 
  127. }
  128. txt.Height = Int32.Parse( dr["Height"].ToString());
  129. txt.Width = Int32.Parse( dr["Width"].ToString());
  130. txt.CssClass = "Input3";
  131. if(DocID>0)
  132. {
  133. if(dt.Rows.Count >0)
  134. txt.Text = dt.Rows[0][dr["Field_Name"].ToString()].ToString();
  135. else
  136. txt.Text ="不存在";
  137. }
  138. else
  139. txt.Text ="";
  140. TableRow  tr = new TableRow();
  141. TableCell tl = new TableCell();
  142. TableCell tc = new TableCell();
  143. Literal lt = new Literal();
  144. lt.Text = dr["Example"].ToString();
  145. tc.Controls.Add(txt);
  146. if(FieldNum==0||dr["judged"].ToString()=="True")
  147. {
  148. RequiredFieldValidator  rfv = new RequiredFieldValidator(); 
  149. rfv.ControlToValidate = txt.ID;
  150. rfv.ErrorMessage = "(*)";
  151. rfv.Display = ValidatorDisplay.Dynamic;
  152. rfv.EnableClientScript = true;
  153. tc.Controls.Add(rfv);
  154. }
  155. if(dr["judged"].ToString()=="True")
  156. {
  157. RegularExpressionValidator rev = new RegularExpressionValidator();
  158. rev.ErrorMessage = "填写数字";
  159. rev.ControlToValidate = txt.ID;
  160. rev.ValidationExpression = @"d+";
  161. rev.Display = ValidatorDisplay.Dynamic;
  162. tc.Controls.Add(rev);
  163. }
  164. tc.Controls.Add(lt);
  165. tl.Text = dr["Field_Description"].ToString() + ":";
  166. if(dr["MultiLine"].ToString()!="False")
  167. tl.VerticalAlign = VerticalAlign.Top;
  168. else
  169. tl.VerticalAlign = VerticalAlign.Middle;
  170. tl.HorizontalAlign = HorizontalAlign.Right;
  171. tr.Cells.Add(tl);
  172. tr.Cells.Add(tc);
  173. ht.Rows.Add(tr);
  174. tc = null;
  175. tl = null;
  176. tr = null;
  177. FieldNum +=1;
  178. }
  179. dr.Close();
  180. dr = null;
  181. if(DocID>0)
  182. AddAttach(DocID);
  183. AddAttachControl();
  184. AddProjectControl();
  185. AddControl();
  186. //=============================//
  187. // 添加批注
  188. //=============================//
  189. DataTable dtPostil;
  190. df.GetDocumentPostil(DocID,out dtPostil); 
  191. if(dtPostil!=null)
  192. {
  193. if(dtPostil.Rows.Count>0)
  194. {
  195. Table tb = new Table();
  196. tb.CssClass ="GbText";
  197. tb.Width = Unit.Percentage(98);
  198. AddRow(tb,"审批意见");
  199. AddPostitleHead(tb);
  200. for(int i=0;i<dtPostil.Rows.Count;i++)
  201. {
  202. AddRow(tb,dtPostil.Rows[i]["RealName"].ToString(),dtPostil.Rows[i]["Postil_Date"].ToString(),dtPostil.Rows[i]["Postil_Content"].ToString(),Int32.Parse(dtPostil.Rows[i]["Postil_Type"].ToString() ),dtPostil.Rows[i]["FileName"].ToString(),dtPostil.Rows[i]["FileVisualPath"].ToString(),dtPostil.Rows[i]["UsedTime"].ToString());
  203. }
  204. AddTable(ht,tb);
  205. }
  206. }
  207. dtPostil = null;
  208. }
  209. #region Web Form Designer generated code
  210. override protected void OnInit(EventArgs e)
  211. {
  212. //
  213. // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
  214. //
  215. InitializeComponent();
  216. base.OnInit(e);
  217. }
  218. /// <summary>
  219. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  220. /// 此方法的内容。
  221. /// </summary>
  222. private void InitializeComponent()
  223. {    
  224. this.cmdSave.Click += new System.EventHandler(this.cmdSave_Click);
  225. this.cmdSend.Click += new System.EventHandler(this.cmdSend_Click);
  226. this.cmdDelete.Click += new System.EventHandler(this.cmdDelete_Click);
  227. this.cmdReturn.Click += new System.EventHandler(this.cmdReturn_Click);
  228. this.PID.ServerChange += new System.EventHandler(this.PID_ServerChange);
  229. this.Load += new System.EventHandler(this.Page_Load);
  230. }
  231. #endregion
  232. private void AddTable(Table tab,Table tb)
  233. {
  234. TableRow tr = new TableRow();
  235. TableCell tl = new TableCell();
  236. tl.ColumnSpan = 2;
  237. tl.Width = Unit.Percentage(100);
  238. tl.HorizontalAlign  = HorizontalAlign.Center;
  239. //tl.Attributes["background"]="../../../Images/treetopbg.jpg";
  240. tl.Controls.Add(tb);
  241. //tl.BackColor = Color.FromArgb(0xff,0xff,0xef);
  242. tr.Height = 28;
  243. tr.Cells.Add(tl);
  244. tab.Rows.Add(tr);
  245. tl = null;
  246. tr = null;
  247. }
  248. private void AddRow(Table tab,string Caption)
  249. {
  250. TableRow tr = new TableRow();
  251. TableCell tl = new TableCell();
  252. tl.Text = Caption;
  253. tl.ColumnSpan = 6 ;
  254. tl.Width = Unit.Percentage(100);
  255. tl.HorizontalAlign  = HorizontalAlign.Center;
  256. tl.Attributes["background"]="../../../Images/treetopbg.jpg";
  257. //tl.BackColor = Color.FromArgb(0xff,0xff,0xef);
  258. tr.Height = 28;
  259. tr.Cells.Add(tl);
  260. tab.Rows.Add(tr);
  261. tl = null;
  262. tr = null;
  263. }
  264. private void AddRow(Table tab,string Postiler,string PostilTime,string PostilContent,int PostilType,string FileName,string FileVisualPath,string UsedTime)
  265. {
  266. TableRow tr = new TableRow();
  267. TableCell tdPotiler = new TableCell();
  268. TableCell tdPostilTime = new TableCell();
  269. TableCell tdPotilType = new TableCell();
  270. TableCell tdPotilContent = new TableCell();
  271. TableCell tdAttachFiles = new TableCell();
  272. TableCell tdTime = new TableCell();
  273. tdPotiler.Text = Postiler;
  274. tdPotiler.HorizontalAlign = HorizontalAlign.Center;
  275. tdPotiler.Width = Unit.Percentage(20);
  276. tdPostilTime.Text = PostilTime;
  277. tdPostilTime.HorizontalAlign = HorizontalAlign.Center;
  278. tdPostilTime.Width = Unit.Percentage(20);
  279. switch(PostilType)
  280. {
  281. case 1:
  282. tdPotilType.Text = "同意";
  283. break;
  284. case 2:
  285. tdPotilType.Text = "拒绝";
  286. break;
  287. case 3:
  288. tdPotilType.Text = "完成";
  289. break;
  290. case 4:
  291. tdPotilType.Text = "回退";
  292. break;
  293. default:
  294. break;
  295. }
  296. tdPotilType.HorizontalAlign = HorizontalAlign.Center;
  297. tdPotilType.Width = Unit.Percentage(10);
  298. tdPotilContent.Text = PostilContent;
  299. tdPotilContent.HorizontalAlign = HorizontalAlign.Left;
  300. tdPotilContent.Width = Unit.Percentage(30);
  301. tr.Height  =22;
  302. tr.BackColor = Color.FromArgb(0xe8,0xf4,0xff);
  303. string FilePath = FileVisualPath + FileName;
  304. tdAttachFiles.Text = "<a href='" +"." + FilePath.Replace("\","/") +"' target='_blank'>" + FileName + "</a>";
  305. tdAttachFiles.HorizontalAlign = HorizontalAlign.Center  ;
  306. tdAttachFiles.Width = Unit.Percentage(10);
  307. tdTime.Text = UsedTime;
  308. tdTime.HorizontalAlign = HorizontalAlign.Center  ;
  309. tdTime.Width = Unit.Percentage(10);
  310. tr.Cells.Add(tdPotiler);
  311. tr.Cells.Add(tdPostilTime);
  312. tr.Cells.Add(tdPotilType);
  313. tr.Cells.Add(tdPotilContent);
  314. tr.Cells.Add(tdAttachFiles);
  315. tr.Cells.Add(tdTime);
  316. tab.Rows.Add(tr);
  317. tdPotiler = null;
  318. tdPostilTime = null;
  319. tdPotilType = null;
  320. tdPotilContent = null;
  321. tdAttachFiles = null;
  322. tdTime = null;
  323. tr = null;
  324. }
  325. private void AddPostitleHead(Table tab)
  326. {
  327. TableRow tr = new TableRow();
  328. TableCell tdPotiler = new TableCell();
  329. TableCell tdPostilTime = new TableCell();
  330. TableCell tdPotilType = new TableCell();
  331. TableCell tdPotilContent = new TableCell();
  332. TableCell tdAttachFiles = new TableCell();
  333. TableCell tdTime = new TableCell();
  334. tdPotiler.Text ="批阅人";
  335. tdPotiler.HorizontalAlign = HorizontalAlign.Center;
  336. tdPotiler.Width = Unit.Percentage(20);
  337. tdPostilTime.Text ="批阅时间";
  338. tdPostilTime.HorizontalAlign = HorizontalAlign.Center;
  339. tdPostilTime.Width = Unit.Percentage(20);
  340. tdPotilType.Text ="批阅类型";
  341. tdPotilType.HorizontalAlign = HorizontalAlign.Center;
  342. tdPotilType.Width = Unit.Percentage(10);
  343. tdPotilContent.Text ="批阅内容";
  344. tdPotilContent.HorizontalAlign = HorizontalAlign.Left ;
  345. tdPotilContent.Width = Unit.Percentage(30);
  346. tdAttachFiles.Text ="附件";
  347. tdAttachFiles.HorizontalAlign = HorizontalAlign.Center  ;
  348. tdAttachFiles.Width = Unit.Percentage(10);
  349. tdTime.Text ="用时(分)";
  350. tdTime.HorizontalAlign = HorizontalAlign.Center  ;
  351. tdTime.Width = Unit.Percentage(10);
  352. tr.Height  =22;
  353. tr.BackColor = Color.FromArgb(0xe8,0xf4,0xff);
  354. tr.Cells.Add(tdPotiler);
  355. tr.Cells.Add(tdPostilTime);
  356. tr.Cells.Add(tdPotilType);
  357. tr.Cells.Add(tdPotilContent);
  358. tr.Cells.Add(tdAttachFiles);
  359. tr.Cells.Add(tdTime);
  360. tab.Rows.Add(tr);
  361. tdPotiler = null;
  362. tdPostilTime = null;
  363. tdPotilType = null;
  364. tdPotilContent = null;
  365. tr = null;
  366. }
  367. private void AddProjectControl()
  368. {
  369. if(ddlProject.Visible == true)
  370. {
  371. TableRow  tr = new TableRow();
  372. TableCell td = new TableCell();
  373. TableCell tl = new TableCell();
  374. td.Text  = "请选择所属项目:";
  375. td.HorizontalAlign = HorizontalAlign.Right;
  376. tr.Cells.Add(td);
  377. ddlProject.Style["Width"] = "450px";
  378. ddlProject.Style["Class"] = "Input3";
  379. tl.Controls.Add(ddlProject);
  380. tr.Cells.Add(tl);
  381. ht.Rows.Add(tr);
  382. td = null;
  383. tr = null;
  384. //ddlProject.EnableViewState =true;
  385.  
  386. }
  387. }
  388. private void AddAttach(long DocID)
  389. {
  390. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  391. DataTable dt = new DataTable();
  392. df.GetDocumentAttach(DocID,out dt);
  393. for(int i=0;i<dt.Rows.Count;i++)
  394. {
  395. TableRow  tr = new TableRow();
  396. TableCell td = new TableCell();
  397. TableCell tc = new TableCell();
  398. td.Text ="附件:";
  399. td.HorizontalAlign = HorizontalAlign.Right;
  400. string FilePath = dt.Rows[i]["FileVisualPath"].ToString() + dt.Rows[i]["FileName"].ToString();
  401. tc.Text = "<a href='" +"." + FilePath.Replace("\","/") +"' target='_blank'>" + dt.Rows[i]["FileName"].ToString() + "</a>";
  402. tc.HorizontalAlign = HorizontalAlign.Left;
  403. tr.Cells.Add(td);
  404. tr.Cells.Add(tc);
  405. tr.Height = 22;
  406. tr.HorizontalAlign = HorizontalAlign.Center;
  407. ht.Rows.Add(tr);
  408. }
  409. dt = null;
  410. df = null;
  411. }
  412. private void AddAttachControl()
  413. {
  414. string Template;
  415. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  416. Template = df.GetStyleTemplate(FlowID);
  417. if(Template!="")
  418. {
  419. TableRow  tr = new TableRow();
  420. TableCell td = new TableCell();
  421. TableCell tl = new TableCell();
  422. td.Text  = "<a href='" + Template + "' style='text-decoration: underline' titile='模板下载' target='_blank'>模板</a>:";
  423. td.HorizontalAlign = HorizontalAlign.Right;
  424. tr.Cells.Add(td);
  425. System.Web.UI.HtmlControls.HtmlInputFile hif = new System.Web.UI.HtmlControls.HtmlInputFile();
  426. hif.ID = "fileTemplate";
  427. hif.Name = "fileTemplate";
  428. hif.Style["width"] = "450px";
  429. hif.Style["Class"] = "Input3";
  430. tl.Controls.Add(hif);
  431. tr.Cells.Add(tl);
  432. ht.Rows.Add(tr);
  433. td = null;
  434. tr = null;
  435. }
  436. df = null;
  437. }
  438. private void UploadFile(long DocID)
  439. {
  440. string FileName = "";
  441. HtmlForm FrmCompose   = (HtmlForm)this.Page.FindControl("NewDocument");
  442. //生成附件目录
  443. if(!System.IO.Directory.Exists(Server.MapPath(".")+"\AttachFiles"))
  444. {
  445. System.IO.Directory.CreateDirectory(Server.MapPath(".")+"\AttachFiles");
  446. }
  447. try
  448. {
  449. HtmlInputFile hif = ((HtmlInputFile)(FrmCompose.FindControl("fileTemplate")));
  450. if(hif.PostedFile!=null)
  451. {
  452. if(hif.PostedFile.FileName.Trim()!="")
  453. {
  454. FileName = System.IO.Path.GetFileName(hif.PostedFile.FileName);
  455. //生成用户目录
  456. if(!System.IO.Directory.Exists(Server.MapPath(".")+"\AttachFiles\" + UserName))
  457. {
  458. System.IO.Directory.CreateDirectory(Server.MapPath(".")+"\AttachFiles\"+ UserName);
  459. }
  460. Random TempNameInt    = new Random(); 
  461. string NewDocDirName  = TempNameInt.Next(100000000).ToString();
  462. //生成随机目录
  463. if(!System.IO.Directory.Exists(Server.MapPath(".")+"\AttachFiles\" + UserName + "\" + NewDocDirName))
  464. {
  465. System.IO.Directory.CreateDirectory(Server.MapPath(".")+"\AttachFiles\" + UserName  + "\" + NewDocDirName);
  466. }
  467. TempNameInt = null;
  468. //保存文件
  469. hif.PostedFile.SaveAs(Server.MapPath(".")+"\AttachFiles\" + UserName  + "\" + NewDocDirName + "\" + FileName);
  470. UDS.Components.DocAttachFile att = new UDS.Components.DocAttachFile();
  471. UDS.Components.DocumentFlow  df  = new UDS.Components.DocumentFlow();
  472. // 初始化
  473. att.FileAttribute = 0;
  474. att.FileSize = hif.PostedFile.ContentLength;
  475. att.FileName = FileName;
  476. att.FileAuthor = UserName;
  477. att.FileCatlog = "公文";
  478. att.FileVisualPath = "\AttachFiles\" + UserName  + "\" + NewDocDirName + "\";
  479. att.FileAddedDate = DateTime.Now.ToString();;
  480. df.AddAttach(att,DocID);
  481. df = null;
  482. att = null;
  483. }
  484. hif=null;
  485. }
  486. }
  487. catch(Exception ex)
  488. {
  489. UDS.Components.Error.Log(ex.ToString());
  490. }
  491. finally
  492. {
  493. }
  494. }
  495. private void AddHeadlin()
  496. {
  497. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  498. TableRow  tr = new TableRow();
  499. TableCell td = new TableCell();
  500. td.Text = df.GetStyleHeadline(FlowID);
  501. td.ColumnSpan = 2;
  502. td.Height = 28;
  503. td.Attributes["BackGround"] = "../../../images/treetopbg.jpg";
  504. tr.Cells.Add(td);
  505. tr.HorizontalAlign = HorizontalAlign.Center;
  506. tr.BackColor = Color.FromArgb(0xff,0xff,0xef);
  507. ht.Rows.Add(tr);
  508. td = null;
  509. tr = null;
  510. df = null;
  511. }
  512. private void AddControl()
  513. {
  514. TableRow  tr = new TableRow();
  515. TableCell td = new TableCell();
  516. cmdSave.Style["Top"] = td.Style["Top"]; 
  517. td.Controls.Add(cmdSave);
  518. td.Controls.Add(cmdSend);
  519. td.Controls.Add(cmdDelete);
  520. td.Controls.Add(cmdReturn);;
  521. td.ColumnSpan = 2;
  522. tr.Cells.Add(td);
  523. tr.HorizontalAlign = HorizontalAlign.Center;
  524. ht.Rows.Add(tr);
  525. // td = null;
  526. // tr = null;
  527. }
  528. private string GetStyleInsertData()
  529. {
  530. string mySql="";
  531. HtmlForm FrmNewDocument   = (HtmlForm)this.Page.FindControl("NewDocument");
  532. mySql += "insert into UDS_Flow_Style_Data (";
  533. for(int i=0;i<FieldNum;i++)
  534. {
  535. mySql += al[i].ToString()+",";
  536. }
  537. mySql = mySql.Substring(0,mySql.Length-1)+") values(";
  538. for(int i=0;i<FieldNum;i++)
  539. {
  540. mySql += "'" + ((TextBox)FrmNewDocument.FindControl("txt" + al[i].ToString())).Text.Replace("'","''") + "',"; 
  541. }
  542. mySql = mySql.Substring(0,mySql.Length-1)+")";
  543. return mySql;
  544. }
  545. private string GetStyleUpdateData(long DocID)
  546. {
  547. string mySql="";
  548. HtmlForm FrmNewDocument   = (HtmlForm)this.Page.FindControl("NewDocument");
  549. if( FieldNum>0)
  550. {
  551. mySql += "update UDS_Flow_Style_Data set ";
  552. for(int i=0;i<FieldNum;i++)
  553. {
  554. mySql += al[i].ToString()+"=" + "'" + ((TextBox)FrmNewDocument.FindControl("txt" + al[i].ToString())).Text.Replace("'","''") + "'";
  555. if(i!=(FieldNum-1))
  556. mySql += ",";
  557. }
  558. mySql += " where Doc_ID = " + DocID.ToString();
  559. return mySql;
  560. }
  561. else
  562. {
  563. return "Select 1";
  564. }
  565. }
  566. private void cmdSend_Click(object sender, System.EventArgs e)
  567. {
  568. //发送到下一环节,使程序处于运行中
  569. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  570. if(ProjectID>=0)
  571. {
  572. int iResult = df.PostDocument(UserName,DocID,ProjectID);
  573. if(iResult==0)
  574. {
  575. df = null;
  576. Server.Transfer("DisplayDocument.aspx?DocID=" + DocID.ToString());
  577. }
  578. else
  579. {
  580. Response.Write("<script lanuage='javascript'>alert('" + df.DoMessage(iResult,DocID,false) + "');</script>");
  581. }
  582. }
  583. else
  584. Response.Write("<script language='javascript'>alert('用户没有一个项目,不能按项目发送!');</script>");
  585. df = null;
  586. }
  587. private void cmdDelete_Click(object sender, System.EventArgs e)
  588. {
  589. //删除拟稿文档
  590. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  591. df.DeleteDocument(DocID);
  592. df = null;
  593. Server.Transfer("FlowTemplate.aspx");
  594. }
  595. private void cmdReturn_Click(object sender, System.EventArgs e)
  596. {
  597. Server.Transfer("DraftList.aspx");
  598. }
  599. private void cmdSave_Click(object sender, System.EventArgs e)
  600. {
  601. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  602. string mySql;
  603. if(bEditMode==false)
  604. {
  605. mySql= GetStyleInsertData();
  606. //拟稿
  607. DocID=df.AddDocument(UserName,FlowID,mySql);
  608. //上传文件
  609. UploadFile(DocID);
  610. df = null;
  611. //转到查看稿件
  612. Server.Transfer("NewDocument.aspx?FlowID=" + FlowID.ToString() + "&DocID=" + DocID.ToString());
  613. }
  614. else
  615. {
  616. mySql = GetStyleUpdateData(DocID);
  617. //Response.Write("<script language='javascript'>alert('" + mySql + "');</script>");
  618. df.UpdateDocument(mySql);
  619. string FileName = df.GetAttachName(DocID);
  620. if(FileName.Length>0)
  621. {
  622. df.DeleteAttach(DocID);
  623. if(System.IO.File.Exists(Server.MapPath(@"." + FileName))==true)
  624. System.IO.File.Delete(Server.MapPath(@"." + FileName));
  625. }
  626. //上传文件
  627. UploadFile(DocID);
  628. df = null;
  629. //修改编辑文件
  630. }
  631. Response.AddHeader("Refresh","1");
  632. }
  633. private void PID_ServerChange(object sender, System.EventArgs e)
  634. {
  635. }
  636. }
  637. }