DefineStyle.aspx.cs
上传用户:xgw_05
上传日期:2009-12-11
资源大小:20208k
文件大小:10k
源码类别:

OA系统

开发平台:

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. /// DefineStyle 的摘要说明。
  17. /// </summary>
  18. public class DefineStyle : System.Web.UI.Page
  19. {
  20. protected System.Web.UI.WebControls.Button cmdAdd;
  21. protected System.Web.UI.WebControls.Button cmdUpdate;
  22. protected System.Web.UI.WebControls.TextBox tbWidth;
  23. protected System.Web.UI.WebControls.TextBox tbHeight;
  24. protected System.Web.UI.WebControls.TextBox tbPosition;
  25. protected System.Web.UI.WebControls.TextBox tbExample;
  26. protected System.Web.UI.WebControls.Table tabDemo;
  27. protected System.Web.UI.WebControls.Button cmdDelete;
  28. public long StyleID;
  29. protected System.Web.UI.WebControls.RadioButton JudgedYes;
  30. protected System.Web.UI.WebControls.RadioButton JudgedNo;
  31. protected System.Web.UI.WebControls.RadioButton MultiLineYes;
  32. protected System.Web.UI.WebControls.RadioButton MultiLineNo;
  33. public long DescriptionID;
  34. protected System.Web.UI.WebControls.DropDownList ddlFieldName;
  35. protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
  36. protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator2;
  37. protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator3;
  38. protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
  39. protected System.Web.UI.WebControls.TextBox tbFieldDescription;
  40. protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator4;
  41. protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator5;
  42. protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator6;
  43. protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
  44. protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator3;
  45. protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator4;
  46. public long Position;
  47. private void Page_Load(object sender, System.EventArgs e)
  48. {
  49. StyleID = Request.QueryString["StyleID"]!=null?Int32.Parse(Request.QueryString["StyleID"]):0;
  50. DescriptionID = Request.QueryString["DescriptionID"]!=null?Int32.Parse(Request.QueryString["DescriptionID"]):0;
  51. Position = Request.QueryString["Position"]!=null?Int32.Parse(Request.QueryString["Position"]):0;
  52. //if(StyleID>0)
  53. if(!Page.IsPostBack)
  54. //FillFieldName();
  55. Bangding();
  56. // 在此处放置用户代码以初始化页面
  57. }
  58. private void Bangding()
  59. {
  60. InitControls();
  61. FillFieldName(ddlFieldName);
  62. // HtmlForm FrmNewDocument   = (HtmlForm)this.Page.FindControl("DefineStyle");
  63. //
  64. SqlDataReader dr; //存放人物的数据
  65. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  66. df.GetStyleDescription(StyleID,out dr); 
  67. // tabDemo.Style["Left"]="1px";
  68. // tabDemo.Style["Top"]="1px";
  69. AddHeadlin();
  70. while(dr.Read())
  71. {
  72. TextBox txt = new TextBox();
  73. txt.ID ="txt" + dr["Field_Name"].ToString();
  74. if(dr["MultiLine"].ToString()!="False")
  75. {
  76. txt.TextMode = TextBoxMode.MultiLine; 
  77. }
  78. txt.Height = Int32.Parse( dr["Height"].ToString());
  79. txt.Width = Int32.Parse( dr["Width"].ToString());
  80. txt.CssClass = "Input3";
  81. TableRow  tr = new TableRow();
  82. TableCell tl = new TableCell();
  83. TableCell tc = new TableCell();
  84. TableCell ta = new TableCell(); 
  85. Literal lt = new Literal();
  86. RadioButton rb = new RadioButton();
  87. if(Position.ToString() ==dr["Position"].ToString())
  88. {
  89. rb.Checked = true;
  90. }
  91. rb.Enabled = false;
  92. rb.GroupName="rbSelect";
  93. rb.Text = "<a href='DefineStyle.aspx?StyleID=" + StyleID.ToString() + "&DescriptionID=" + dr["Description_ID"].ToString() + "&Position=" + dr["Position"].ToString() + "'>" + dr["Position"].ToString() + "</a>";
  94. ta.Controls.Add(rb);
  95. ta.VerticalAlign = VerticalAlign.Top;
  96. ta.Width = Unit.Percentage(5);
  97. lt.Text = dr["Example"].ToString();
  98. tc.Controls.Add(txt);
  99. tc.Controls.Add(lt);
  100. tc.Width = Unit.Percentage(80);
  101. tl.Text = dr["Field_Description"].ToString() + ":";
  102. tl.Width = Unit.Percentage(15);
  103. if(dr["MultiLine"].ToString()!="False")
  104. tl.VerticalAlign = VerticalAlign.Top;
  105. else
  106. tl.VerticalAlign = VerticalAlign.Middle;
  107. tl.HorizontalAlign = HorizontalAlign.Right;
  108. tr.Cells.Add(ta);
  109. tr.Cells.Add(tl);
  110. tr.Cells.Add(tc);
  111. tabDemo.Rows.Add(tr);
  112. tc = null;
  113. tl = null;
  114. tr = null;
  115. }
  116. dr.Close();
  117. dr = null;
  118. AddAttachControl();
  119. // FrmNewDocument.Controls.Add(tabDemo);
  120. if(DescriptionID>0)
  121. GetValue(DescriptionID);
  122. }
  123. private void InitControls()
  124. {
  125. if(DescriptionID>0)
  126. {
  127. cmdUpdate.Enabled = true;
  128. cmdDelete.Enabled = true;
  129. }
  130. else
  131. {
  132. cmdUpdate.Enabled = false;
  133. cmdDelete.Enabled = false;
  134. }
  135. }
  136. private void GetValue(long DescriptionID)
  137. {
  138. SqlDataReader dr;
  139. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  140. df.GetDescription(DescriptionID,out dr);
  141. if(dr.Read())
  142. {
  143. for(int i=0;i<ddlFieldName.Items.Count;i++)
  144. {
  145. if(ddlFieldName.Items[i].Value  == dr["Field_Name"].ToString())
  146. ddlFieldName.SelectedIndex = i;
  147. }
  148. tbFieldDescription.Text = dr["Field_Description"].ToString();
  149. if(dr["judged"].ToString() =="True")
  150. JudgedYes.Checked = true;
  151. else
  152. JudgedNo.Checked = true;
  153. if(dr["multiline"].ToString() =="True")
  154. MultiLineYes.Checked = true;
  155. else
  156. MultiLineNo.Checked = true;
  157. tbWidth.Text = dr["Width"].ToString();
  158. tbHeight.Text = dr["Height"].ToString();
  159. tbPosition.Text = dr["Position"].ToString();
  160. tbExample.Text = dr["Example"].ToString();
  161. }
  162. dr.Close();
  163. dr = null;
  164. }
  165. private void FillFieldName(DropDownList ddl)
  166. {
  167. string text;
  168. ddl.Items.Clear();
  169. for(int i=1;i<=26;i++)
  170. {
  171. text = ((char)((int)'a'+i-1)).ToString();
  172. ddl.Items.Add(new ListItem(i.ToString(),text));
  173. }
  174. }
  175. private void AddAttachControl()
  176. {
  177. string Template;
  178. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  179. Template = df.GetStyleTemplateEx(StyleID);
  180. if(Template!="")
  181. {
  182. TableRow  tr = new TableRow();
  183. TableCell td = new TableCell();
  184. TableCell tl = new TableCell();
  185. TableCell tt = new TableCell();
  186. tt.Text =" ";
  187. tr.Cells.Add(tt);
  188. td.Text  = "<a href='" + Template + "' style='text-decoration: underline' titile='模板下载'>模板</a>:";
  189. td.HorizontalAlign = HorizontalAlign.Right;
  190. tr.Cells.Add(td);
  191. System.Web.UI.HtmlControls.HtmlInputFile hif = new System.Web.UI.HtmlControls.HtmlInputFile();
  192. hif.ID = "fileTemplate";
  193. hif.Name = "fileTemplate";
  194. hif.Style["width"] = "450px";
  195. hif.Style["Class"] = "Input3";
  196. tl.Controls.Add(hif);
  197. tr.Cells.Add(tl);
  198. tabDemo.Rows.Add(tr);
  199. td = null;
  200. tr = null;
  201. }
  202. df = null;
  203. }
  204. private void AddHeadlin()
  205. {
  206. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  207. TableRow  tr = new TableRow();
  208. TableCell td = new TableCell();
  209. td.Text = "自定义表单";
  210. td.ColumnSpan = 3;
  211. td.Height = 28;
  212. tr.Cells.Add(td);
  213. tr.HorizontalAlign = HorizontalAlign.Center;
  214. //tr.BackColor = Color.FromArgb(0xff,0xff,0xef);
  215. td.Attributes["background"]="../../../Images/treetopbg.jpg";
  216. tabDemo.Rows.Add(tr);
  217. td = null;
  218. tr = null;
  219. df = null;
  220. }
  221. #region Web Form Designer generated code
  222. override protected void OnInit(EventArgs e)
  223. {
  224. //
  225. // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
  226. //
  227. InitializeComponent();
  228. base.OnInit(e);
  229. }
  230. /// <summary>
  231. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  232. /// 此方法的内容。
  233. /// </summary>
  234. private void InitializeComponent()
  235. {    
  236. this.cmdAdd.Click += new System.EventHandler(this.cmdAdd_Click);
  237. this.cmdUpdate.Click += new System.EventHandler(this.cmdUpdate_Click);
  238. this.cmdDelete.Click += new System.EventHandler(this.cmdDelete_Click);
  239. this.Load += new System.EventHandler(this.Page_Load);
  240. }
  241. #endregion
  242. private void rb_CheckedChanged(object sender, System.EventArgs e)
  243. {
  244. Server.Transfer("DefineStyle.aspx?StyleID=" + StyleID.ToString() + "&DescriptionID=" + ((RadioButton)sender).Text.ToString() );
  245. }
  246. private void cmdAdd_Click(object sender, System.EventArgs e)
  247. {
  248. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  249. if(df.AddStyleDescription(StyleID,ddlFieldName.SelectedItem.Value ,tbFieldDescription.Text ,JudgedYes.Checked?1:0,MultiLineYes.Checked?1:0,Int32.Parse(tbHeight.Text),Int32.Parse(tbWidth.Text),Int32.Parse(tbPosition.Text),tbExample.Text)!=0)
  250. {
  251. Response.Write("<script language='javascript'>alert('所加的字段有重复!');</script>");
  252. }
  253. Bangding();
  254. }
  255. private void cmdUpdate_Click(object sender, System.EventArgs e)
  256. {
  257. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  258. if(df.UpdateStyleDescription(DescriptionID,StyleID,ddlFieldName.SelectedItem.Value ,tbFieldDescription.Text ,JudgedYes.Checked?1:0,MultiLineYes.Checked?1:0,Int32.Parse(tbHeight.Text),Int32.Parse(tbWidth.Text),Int32.Parse(tbPosition.Text),tbExample.Text)!=0)
  259. {
  260. Response.Write("<script language='javascript'>alert('所修改的字段有重复!');</script>");
  261. }
  262. Bangding();
  263. }
  264. private void cmdDelete_Click(object sender, System.EventArgs e)
  265. {
  266. UDS.Components.DocumentFlow df = new UDS.Components.DocumentFlow();
  267. df.DeleteStyleDescription(DescriptionID);
  268. tbFieldDescription.Text ="";
  269. tbWidth.Text = "450";
  270. tbHeight.Text = "20";
  271. tbPosition.Text  = "1";
  272. Bangding();
  273. }
  274. }
  275. }