EditTache.aspx.cs
上传用户:xuming1973
上传日期:2014-02-27
资源大小:17511k
文件大小:12k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

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 UDS.Components;
  12. using System.Data.SqlClient;
  13. namespace UDS.SubModule.UnitiveDocument.DocumentFlow
  14. {
  15. /// <summary>
  16. /// EditTache 的摘要说明。
  17. /// </summary>
  18. public class EditTache : System.Web.UI.Page
  19. {
  20. protected System.Web.UI.WebControls.Label Label1;
  21. protected System.Web.UI.WebControls.Label Label2;
  22. protected System.Web.UI.WebControls.Label Label3;
  23. protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
  24. protected System.Web.UI.WebControls.TextBox txtTacheName;
  25. protected System.Web.UI.WebControls.DropDownList cboFlowRule;
  26. protected System.Web.UI.WebControls.RadioButton chkFinishYes;
  27. protected System.Web.UI.WebControls.RadioButton chkFinishNO;
  28. protected System.Web.UI.WebControls.Label Label5;
  29. protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
  30. protected System.Web.UI.WebControls.Label Label4;
  31. protected System.Web.UI.WebControls.TextBox txtRemark;
  32. protected System.Web.UI.WebControls.Button cmdPrevious;
  33. protected System.Web.UI.WebControls.Button cmdFinish;
  34. protected System.Web.UI.WebControls.Button cmdDelete;
  35. protected System.Web.UI.WebControls.Button cmdCancel;
  36. protected System.Web.UI.WebControls.Button cmdNext;
  37. protected System.Web.UI.WebControls.RadioButton radPassNumYes;
  38. protected System.Web.UI.WebControls.RadioButton radPassNumNo;
  39. protected System.Web.UI.HtmlControls.HtmlGenericControl PassNum;
  40. protected System.Web.UI.WebControls.TextBox txtPassNum;
  41. private long FlowID;
  42. private long StepID;
  43. protected System.Web.UI.WebControls.Label labStep;
  44. protected System.Web.UI.HtmlControls.HtmlInputCheckBox chkAllPass;
  45. protected System.Web.UI.WebControls.Label labFlowName;
  46. protected System.Web.UI.WebControls.Button cmdReturn;
  47. protected System.Web.UI.WebControls.CheckBox chkLocalAlert;
  48. protected System.Web.UI.WebControls.CheckBox chkUrgencyAlert;
  49. protected System.Web.UI.WebControls.TextBox txtBaseHour;
  50. protected System.Web.UI.HtmlControls.HtmlGenericControl spanAlert;
  51. protected System.Web.UI.WebControls.TextBox txtPeriod;
  52. protected System.Web.UI.WebControls.TextBox txtCycTimes;
  53. protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
  54. protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator3;
  55. protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator4;
  56. protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator2;
  57. protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator3;
  58. protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator4;
  59. private bool bIsExistStep;
  60. private void Page_Load(object sender, System.EventArgs e)
  61. {
  62. // 在此处放置用户代码以初始化页面
  63. FlowID = Request.QueryString["FlowID"]!=null?Int32.Parse(Request.QueryString["FlowID"].ToString()):0;
  64. StepID = Request.QueryString["StepID"]!=null?Int32.Parse(Request.QueryString["StepID"].ToString()):0;
  65. if(!Page.IsPostBack)
  66. Bangding();
  67. }
  68. #region Web Form Designer generated code
  69. override protected void OnInit(EventArgs e)
  70. {
  71. //
  72. // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
  73. //
  74. InitializeComponent();
  75. base.OnInit(e);
  76. }
  77. /// <summary>
  78. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  79. /// 此方法的内容。
  80. /// </summary>
  81. private void InitializeComponent()
  82. {    
  83. this.radPassNumYes.CheckedChanged += new System.EventHandler(this.radPassNumYes_CheckedChanged);
  84. this.radPassNumNo.CheckedChanged += new System.EventHandler(this.radPassNumNo_CheckedChanged);
  85. this.chkUrgencyAlert.CheckedChanged += new System.EventHandler(this.chkUrgencyAlert_CheckedChanged);
  86. this.cmdPrevious.Click += new System.EventHandler(this.cmdPrevious_Click);
  87. this.cmdNext.Click += new System.EventHandler(this.cmdNext_Click);
  88. this.cmdDelete.Click += new System.EventHandler(this.cmdDelete_Click);
  89. this.cmdFinish.Click += new System.EventHandler(this.cmdFinish_Click);
  90. this.cmdCancel.Click += new System.EventHandler(this.cmdCancel_Click);
  91. this.cmdReturn.Click += new System.EventHandler(this.cmdReturn_Click);
  92. this.Load += new System.EventHandler(this.Page_Load);
  93. }
  94. #endregion
  95. private void Bangding()
  96. {
  97. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  98. bIsExistStep = StepID>df.GetMaxStep(FlowID)?false:true;
  99. labStep.Text = "步骤:第" + StepID.ToString() + "步";
  100. labFlowName.Text = df.GetFlowTitle(FlowID);
  101. if(bIsExistStep==true)
  102. {
  103. DataTable dt;
  104. df.GetStep(FlowID,StepID,out dt);
  105. if(dt.Rows.Count >0)
  106. {
  107. txtTacheName.Text = dt.Rows[0]["Step_Name"].ToString();
  108. txtRemark.Text   = dt.Rows[0]["Step_Remark"].ToString();
  109. if(dt.Rows[0]["RightToFinish"].ToString()=="True")
  110. {
  111. chkFinishYes.Checked = true;
  112. chkFinishNO.Checked  = false;
  113. }
  114. else
  115. {
  116. chkFinishYes.Checked = false;
  117. chkFinishNO.Checked  = true;
  118. }
  119. txtPassNum.Text = dt.Rows[0]["PassNum"].ToString();
  120. if(Int32.Parse(txtPassNum.Text)==0)
  121. {
  122. radPassNumYes.Checked = false;
  123. radPassNumNo.Checked = true;
  124. PassNum.Style["display"] = "none";
  125. }
  126. else
  127. {
  128. radPassNumNo.Checked = false;
  129. radPassNumYes.Checked = true;
  130. PassNum.Style["display"] = "";
  131. if(Int32.Parse(txtPassNum.Text)==-1)
  132. {
  133. chkAllPass.Checked = true;
  134. }
  135. else
  136. {
  137. chkAllPass.Checked = false;
  138. }
  139. }
  140. for(int i=0;i<cboFlowRule.Items.Count;i++)
  141. {
  142. if(cboFlowRule.Items[i].Value.ToString()==dt.Rows [0]["Flow_Rule"].ToString() )
  143. cboFlowRule.SelectedIndex = i;
  144. }
  145. if(dt.Rows[0]["localalert"].ToString()=="True")
  146. chkLocalAlert.Checked = true;
  147. else
  148. chkLocalAlert.Checked = false;
  149. if(Int32.Parse(dt.Rows[0]["cycTimes"].ToString())>0)
  150. {
  151. chkUrgencyAlert.Checked = true;
  152. spanAlert.Style["display"] = "";
  153. txtBaseHour.Text = dt.Rows[0]["BaseHour"].ToString();
  154. txtCycTimes.Text = dt.Rows[0]["CycTimes"].ToString();
  155. txtPeriod.Text = dt.Rows[0]["Period"].ToString();
  156. }
  157. else
  158. {
  159. chkUrgencyAlert.Checked = false;
  160. spanAlert.Style["display"] = "none";
  161. txtBaseHour.Text = "0";
  162. txtCycTimes.Text = "0";
  163. txtPeriod.Text = "0";
  164. }
  165. }
  166. df = null;
  167. cmdDelete.Enabled =true;
  168. }
  169. else
  170. {
  171. spanAlert.Style["display"] = "none";
  172. txtBaseHour.Text = "0";
  173. txtCycTimes.Text = "0";
  174. txtPeriod.Text = "0";
  175. cmdDelete.Enabled = false;
  176. }
  177. cmdCancel.Attributes.Add("onclick","return confirm('是否删除此流程?');");
  178. }
  179. private void cmdNext_Click(object sender, System.EventArgs e)
  180. {
  181. String UserName = Request.Cookies["UserName"].Value.ToString();
  182. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  183. int iPassNum;
  184. if(radPassNumNo.Checked ==true)
  185. {
  186. iPassNum = 0;
  187. }
  188. else
  189. {
  190. iPassNum = Int32.Parse(txtPassNum.Text);
  191. }
  192. int iBaseHour;
  193. int iCycTimes;
  194. int iPeriod;
  195. if(chkUrgencyAlert.Checked ==true)
  196. {
  197. iBaseHour = Int32.Parse(txtBaseHour.Text);
  198. iCycTimes = Int32.Parse(txtCycTimes.Text);
  199. iPeriod = Int32.Parse(txtPeriod.Text);
  200. }
  201. else
  202. {
  203. iBaseHour = 0;
  204. iCycTimes = 0;
  205. iPeriod = 0;
  206. }
  207. //判断此流程的步骤是否存在
  208. if(StepID>df.GetMaxStep(FlowID))
  209. {
  210. if(df.AddStep(FlowID,txtTacheName.Text,txtRemark.Text,chkFinishYes.Checked?1:0,Int32.Parse(cboFlowRule.SelectedItem.Value),iPassNum,chkLocalAlert.Checked?1:0,iBaseHour,iCycTimes,iPeriod)>0)
  211. {
  212. StepID +=1;
  213. Server.Transfer("EditTache.aspx?FlowID=" + FlowID.ToString() + "&StepID=" + StepID.ToString());
  214. }
  215. else
  216. {
  217. Server.Transfer("../../Error.aspx");
  218. }
  219. }
  220. else
  221. {
  222. if(df.UpdateStep(FlowID,StepID,txtTacheName.Text,txtRemark.Text,chkFinishYes.Checked?1:0,Int32.Parse(cboFlowRule.SelectedItem.Value),iPassNum,chkLocalAlert.Checked?1:0,iBaseHour,iCycTimes,iPeriod)==0)
  223. {
  224. StepID +=1;
  225. Server.Transfer("EditTache.aspx?FlowID=" + FlowID.ToString() + "&StepID=" + StepID.ToString());
  226. }
  227. else
  228. {
  229. Server.Transfer("../../Error.aspx");
  230. }
  231. }
  232. }
  233. private void cmdFinish_Click(object sender, System.EventArgs e)
  234. {
  235. String UserName = Request.Cookies["UserName"].Value.ToString();
  236. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  237. int iPassNum;
  238. if(radPassNumNo.Checked ==true)
  239. {
  240. iPassNum = 0;
  241. }
  242. else
  243. {
  244. iPassNum = Int32.Parse(txtPassNum.Text);
  245. }
  246. int iBaseHour;
  247. int iCycTimes;
  248. int iPeriod;
  249. if(chkUrgencyAlert.Checked ==true)
  250. {
  251. iBaseHour = Int32.Parse(txtBaseHour.Text);
  252. iCycTimes = Int32.Parse(txtCycTimes.Text);
  253. iPeriod = Int32.Parse(txtPeriod.Text);
  254. }
  255. else
  256. {
  257. iBaseHour = 0;
  258. iCycTimes = 0;
  259. iPeriod = 0;
  260. }
  261. //判断此流程的步骤是否存在
  262. if(StepID>df.GetMaxStep(FlowID))
  263. {
  264. if(df.AddStep(FlowID,txtTacheName.Text,txtRemark.Text,chkFinishYes.Checked?1:0,Int32.Parse(cboFlowRule.SelectedItem.Value),iPassNum,chkLocalAlert.Checked?1:0,iBaseHour,iCycTimes,iPeriod)>0)
  265. {
  266. Server.Transfer("ManageFlow.aspx?FlowID=" + FlowID.ToString()); }
  267. else
  268. {
  269. Server.Transfer("../../Error.aspx");
  270. }
  271. }
  272. else
  273. {
  274. if(df.UpdateStep(FlowID,StepID,txtTacheName.Text,txtRemark.Text,chkFinishYes.Checked?1:0,Int32.Parse(cboFlowRule.SelectedItem.Value),iPassNum,chkLocalAlert.Checked?1:0,iBaseHour,iCycTimes,iPeriod)==0)
  275. {
  276. Server.Transfer("ManageFlow.aspx?FlowID=" + FlowID.ToString());
  277. }
  278. else
  279. {
  280. Server.Transfer("../../Error.aspx");
  281. }
  282. }
  283. }
  284. private void radPassNumYes_CheckedChanged(object sender, System.EventArgs e)
  285. {
  286. PassNum.Style["display"] = "";
  287. }
  288. private void radPassNumNo_CheckedChanged(object sender, System.EventArgs e)
  289. {
  290. PassNum.Style["display"] = "none";
  291. }
  292. private void chkAllMember_ServerChange(object sender, System.EventArgs e)
  293. {
  294. }
  295. private void cmdCancel_Click(object sender, System.EventArgs e)
  296. {
  297. //删除流程
  298. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  299. if(df.DeleteFlow(FlowID)==0)
  300. {
  301. Server.Transfer("Listview.aspx");
  302. }
  303. else
  304. {
  305. Server.Transfer("../../Error.aspx");
  306. }
  307. }
  308. private void cmdDelete_Click(object sender, System.EventArgs e)
  309. {
  310. //删除此步
  311. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  312. df.DeleteStep(FlowID,StepID);
  313. df = null;
  314. if(StepID>1)
  315. {
  316. StepID -=1;
  317. Server.Transfer("EditTache.aspx?FlowID=" + FlowID.ToString() + "&StepID=" + StepID.ToString());
  318. }
  319. else
  320. {
  321. Server.Transfer("EditFlow.aspx?FlowID=" + FlowID.ToString());
  322. }
  323. }
  324. private void cmdPrevious_Click(object sender, System.EventArgs e)
  325. {
  326. if(StepID>1)
  327. {
  328. StepID -=1;
  329. Server.Transfer("EditTache.aspx?FlowID=" + FlowID.ToString() + "&StepID=" + StepID.ToString());
  330. }
  331. else
  332. {
  333. Server.Transfer("EditFlow.aspx?FlowID=" + FlowID.ToString());
  334. }
  335. }
  336. private void cmdReturn_Click(object sender, System.EventArgs e)
  337. {
  338. Server.Transfer("ManageFlow.aspx?FlowID=" + FlowID.ToString());
  339. }
  340. private void chkUrgencyAlert_CheckedChanged(object sender, System.EventArgs e)
  341. {
  342. if(chkUrgencyAlert.Checked ==true)
  343. spanAlert.Style["display"] = "";
  344. else
  345. spanAlert.Style["display"] = "none";
  346. }
  347. }
  348. }