UIF041030.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using CoreFS.CA06;
  10. using Common;
  11. namespace Core.LZMes.Client.UIF
  12. {
  13. public partial class UIF041030 : CoreFS.CA06.FrmBase
  14. {
  15. public UIF041030()
  16. {
  17. InitializeComponent();
  18. }
  19. #region "ComboBox Event"
  20. private void cmb_GrpType_ValueChanged(object sender, EventArgs e)
  21. {
  22. try
  23. {
  24. if (cmb_GrpType.Value.ToString() == "厚度")
  25. {
  26. this.ugrd_Group.DataMember = "TBF02_ROLL_THK_GRP";
  27. label6.Text = "厚度组";
  28. this.txt_Mini.Mask = "9.999";
  29. this.txt_Maxi.Mask = "9.999";
  30. this.label1.Visible = true;
  31. this.cmb_Type.Visible = true;
  32. this.cmb_GrpType.Value = "厚度";
  33. }
  34. else
  35. {
  36. this.ugrd_Group.DataMember = "TBF02_ROLL_WTH_GRP";
  37. label6.Text = "宽度组";
  38. this.txt_Mini.Mask = "9999";
  39. this.txt_Maxi.Mask = "9999";
  40. this.label1.Visible = false;
  41. this.cmb_Type.Visible = false;
  42. }
  43. }
  44. catch (System.Exception ex)
  45. {
  46. System.Diagnostics.Debug.WriteLine(ex.ToString());
  47. }
  48. }
  49. #endregion
  50. #region "ToolBar Event"
  51. public override void ToolBar_Click(object sender, string ToolbarKey)
  52. {
  53. try
  54. {
  55. switch (ToolbarKey)
  56. {
  57. case "Query":
  58. Query_GrpInfo();
  59. break;
  60. case "Add":
  61. Add_GrpInfo();
  62. break;
  63. case "Edit":
  64. Edit_GrpInfo();
  65. break;
  66. case "Delete":
  67. Del_GrpInfo();
  68. break;
  69. case "Exit":
  70. this.Close();
  71. break;
  72. }
  73. }
  74. catch (System.Exception ex)
  75. {
  76. System.Diagnostics.Debug.WriteLine(ex.ToString());
  77. }
  78. }
  79. private void Query_GrpInfo()
  80. {
  81. try
  82. {
  83. CoreClientParam ccp = new CoreClientParam();
  84. ccp.ServerName = "UIF.UIF04.UIF041030";
  85. ccp.MethodName = "Query_Group_Info";
  86. ccp.ServerParams = new object[] { "",this.cmb_GrpType.Value.ToString() };
  87. CoreClientParam obj = this.ExecuteQuery(ccp, CoreInvokeType.Internal);
  88. if (obj.ReturnInfo.Length == 0)
  89. {
  90. if (this.cmb_GrpType.Value.ToString() == "厚度")
  91. {
  92. this.dataSet1.Tables["TBF02_ROLL_THK_GRP"].Clear();
  93. System.Data.DataTable tab0 = FixDBManager.ConvertToDataTable(obj.ReturnObject as System.Collections.ArrayList, this.dataSet1.Tables["TBF02_ROLL_THK_GRP"]);
  94. tab0.TableName = "TBF02_ROLL_THK_GRP";
  95. this.dataSet1.Tables["TBF02_ROLL_THK_GRP"].Merge(tab0);
  96. this.dataSet1.AcceptChanges();
  97. }
  98. else
  99. {
  100. this.dataSet1.Tables["TBF02_ROLL_WTH_GRP"].Clear();
  101. System.Data.DataTable tab0 = FixDBManager.ConvertToDataTable(obj.ReturnObject as System.Collections.ArrayList, this.dataSet1.Tables["TBF02_ROLL_WTH_GRP"]);
  102. tab0.TableName = "TBF02_ROLL_WTH_GRP";
  103. this.dataSet1.Tables["TBF02_ROLL_WTH_GRP"].Merge(tab0);
  104. this.dataSet1.AcceptChanges();
  105. }
  106. }
  107. }
  108. catch (System.Exception ex)
  109. {
  110. System.Diagnostics.Debug.WriteLine(ex.ToString());
  111. }
  112. }
  113. private void Add_GrpInfo()
  114. {
  115. try
  116. {
  117. if (!CheckValue())
  118. return;
  119. string sql = "";
  120. if (this.cmb_GrpType.Value.ToString() == "厚度")
  121. {
  122. if (!CheckValueConstraints(FixDBManager.CheckNullStr(this.txt_Mini.Text), FixDBManager.CheckNullStr(this.txt_Maxi.Text), "TBF02_ROLL_THK_GRP","ADD"))
  123. return;
  124. sql = "INSERT INTO TBF02_ROLL_THK_GRP(PLT,THK_GRP_CD,MINI,MAXI,REG_DTIME,REG_ID,MOD_DTIME,MOD_ID,TYPE_) "
  125. + "VALUES('C',"
  126. + "'" + this.txt_GrpName.Text.Trim().ToUpper() + "',"
  127. + FixDBManager.CheckNullStr(this.txt_Mini.Text) + ","
  128. + FixDBManager.CheckNullStr(this.txt_Maxi.Text) + ","
  129. + "TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'),"
  130. + "'" + CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName() + "',"
  131. + "NULL,"
  132. + "NULL,"
  133. + "'" + this.cmb_Type.Value.ToString() + "'"
  134. + ")";
  135. }
  136. else
  137. {
  138. if (!CheckValueConstraints(FixDBManager.CheckNullStr(this.txt_Mini.Text), FixDBManager.CheckNullStr(this.txt_Maxi.Text), "TBF02_ROLL_WTH_GRP","ADD"))
  139. return;
  140. sql = "INSERT INTO TBF02_ROLL_WTH_GRP(PLT,WTH_GRP_CD,MINI,MAXI,REG_DTIME,REG_ID,MOD_DTIME,MOD_ID) "
  141. + "VALUES('C',"
  142. + "'" + this.txt_GrpName.Text.Trim().ToUpper() + "',"
  143. + FixDBManager.CheckNullStr(this.txt_Mini.Text) + ","
  144. + FixDBManager.CheckNullStr(this.txt_Maxi.Text) + ","
  145. + "TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'),"
  146. + "'" + CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName() + "',"
  147. + "NULL,"
  148. + "NULL"
  149. + ")";
  150. }
  151. CoreClientParam ccp = new CoreClientParam();
  152. ccp.ServerName = "UIF.UIF04.UIF041030";
  153. ccp.MethodName = "Add_Group_Info";
  154. ccp.ServerParams = new object[] { sql };
  155. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  156. if(ccp.ReturnInfo.Length==0)
  157. Query_GrpInfo();
  158. }
  159. catch (System.Exception ex)
  160. {
  161. System.Diagnostics.Debug.WriteLine(ex.ToString());
  162. }
  163. }
  164. private void Edit_GrpInfo()
  165. {
  166. try
  167. {
  168. if (this.ugrd_Group.ActiveRow == null)
  169. {
  170. MessageBox.Show("请选择您要修改的记录行");
  171. return;
  172. }
  173. if (!CheckValue())
  174. return;
  175. string sql = "";
  176. if (this.cmb_GrpType.Value.ToString() == "厚度")
  177. {
  178. if (!CheckValueConstraints(FixDBManager.CheckNullStr(this.txt_Mini.Text), FixDBManager.CheckNullStr(this.txt_Maxi.Text), "TBF02_ROLL_THK_GRP","EDIT"))
  179. return;
  180. sql = "UPDATE TBF02_ROLL_THK_GRP SET THK_GRP_CD='" + this.txt_GrpName.Text.Trim().ToUpper() + "',"
  181. + "MINI=" + FixDBManager.CheckNullStr(this.txt_Mini.Text) + ","
  182. + "MAXI=" + FixDBManager.CheckNullStr(this.txt_Maxi.Text) + ","
  183. + "MOD_DTIME=TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'),"
  184. + "MOD_ID='" + CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName() + "',"
  185. + "TYPE_='" + this.cmb_Type.Value.ToString() + "' "
  186. + "WHERE PLT='C' AND THK_GRP_CD='" + FixDBManager.CheckNullStr(this.ugrd_Group.ActiveRow.Cells["THK_GRP_CD"].Value) + "'";
  187. }
  188. else
  189. {
  190. if (!CheckValueConstraints(FixDBManager.CheckNullStr(this.txt_Mini.Text), FixDBManager.CheckNullStr(this.txt_Maxi.Text), "TBF02_ROLL_WTH_GRP","EDIT"))
  191. return;
  192. sql = "UPDATE TBF02_ROLL_WTH_GRP SET WTH_GRP_CD='" + this.txt_GrpName.Text.Trim().ToUpper() + "',"
  193. + "MINI=" + FixDBManager.CheckNullStr(this.txt_Mini.Text) + ","
  194. + "MAXI=" + FixDBManager.CheckNullStr(this.txt_Maxi.Text) + ","
  195. + "MOD_DTIME=TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'),"
  196. + "MOD_ID='" + CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName() + "' "
  197. + "WHERE PLT='C' AND WTH_GRP_CD='" + FixDBManager.CheckNullStr(this.ugrd_Group.ActiveRow.Cells["WTH_GRP_CD"].Value) + "'";
  198. }
  199. CoreClientParam ccp = new CoreClientParam();
  200. ccp.ServerName = "UIF.UIF04.UIF041030";
  201. ccp.MethodName = "Edit_Group_Info";
  202. ccp.ServerParams = new object[] { sql };
  203. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  204. if(ccp.ReturnInfo.Length==0)
  205. Query_GrpInfo();
  206. }
  207. catch (System.Exception ex)
  208. {
  209. System.Diagnostics.Debug.WriteLine(ex.ToString());
  210. }
  211. }
  212. private void Del_GrpInfo()
  213. {
  214. try
  215. {
  216. if (this.ugrd_Group.ActiveRow == null)
  217. {
  218. MessageBox.Show("请选择您要删除的记录行");
  219. return;
  220. }
  221. string sql = "";
  222. if (this.cmb_GrpType.Value.ToString() == "厚度")
  223. {
  224. sql = "DELETE FROM TBF02_ROLL_THK_GRP WHERE PLT='C' AND THK_GRP_CD='" + FixDBManager.CheckNullStr(this.ugrd_Group.ActiveRow.Cells["THK_GRP_CD"].Value) + "'";
  225. }
  226. else
  227. {
  228. sql = "DELETE FROM TBF02_ROLL_WTH_GRP WHERE PLT='C' AND WTH_GRP_CD='" + FixDBManager.CheckNullStr(this.ugrd_Group.ActiveRow.Cells["WTH_GRP_CD"].Value) + "'";
  229. }
  230. CoreClientParam ccp = new CoreClientParam();
  231. ccp.ServerName = "UIF.UIF04.UIF041030";
  232. ccp.MethodName = "Delete_Group_Info";
  233. ccp.ServerParams = new object[] { sql };
  234. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  235. if(ccp.ReturnInfo.Length==0)
  236. Query_GrpInfo();
  237. }
  238. catch (System.Exception ex)
  239. {
  240. System.Diagnostics.Debug.WriteLine(ex.ToString());
  241. }
  242. }
  243. private bool CheckValue()
  244. {
  245. if (this.txt_GrpName.Text.Trim().Length == 0)
  246. {
  247. MessageBox.Show("请您确认组名");
  248. return false;
  249. }
  250. if (this.txt_Mini.Text.Trim().Length == 0)
  251. {
  252. MessageBox.Show("请您确认下限值");
  253. return false;
  254. }
  255. if (this.txt_Mini.Text.Trim().Length == 0)
  256. {
  257. MessageBox.Show("请您确认上限值");
  258. return false;
  259. }
  260. if (this.cmb_GrpType.Value.ToString() == "厚度")
  261. {
  262. if (this.cmb_Type.Text.Trim().Length == 0)
  263. {
  264. MessageBox.Show("请您确认厚度组的区分");
  265. return false;
  266. }
  267. }
  268. return true;
  269. }
  270. private bool CheckValueConstraints(string Mini,string Maxi,string TableName,string type)
  271. {
  272. string Condition = " AND ((MINI<=" + Mini + " AND " + Mini + "<MAXI) OR (MINI<=" + Maxi + " AND " + Maxi + "<MAXI)) ";
  273. if (type == "EDIT")
  274. {
  275. if(this.cmb_GrpType.Value.ToString()=="厚度")
  276. Condition = Condition + " AND THK_GRP_CD<>'" + Common.FixDBManager.CheckNullStr(this.ugrd_Group.ActiveRow.Cells["THK_GRP_CD"].Value) + "'";
  277. else
  278. Condition = Condition + " AND WTH_GRP_CD<>'" + Common.FixDBManager.CheckNullStr(this.ugrd_Group.ActiveRow.Cells["WTH_GRP_CD"].Value) + "'";
  279. }
  280. CoreClientParam ccp = new CoreClientParam();
  281. ccp.ServerName = "UIF.UIF04.UIF041030";
  282. ccp.MethodName = "Query_Group_Info";
  283. ccp.ServerParams = new object[] { Condition, this.cmb_GrpType.Value.ToString() };
  284. CoreClientParam obj = this.ExecuteQuery(ccp, CoreInvokeType.Internal);
  285. if (obj.ReturnInfo.Length == 0)
  286. {
  287. System.Data.DataTable tab = FixDBManager.ConvertToDataTable(obj.ReturnObject as System.Collections.ArrayList, this.dataSet1.Tables[TableName]);
  288. if (tab.Rows.Count> 0)
  289. {
  290. MessageBox.Show("维护数据与已存在数据有交集,请检查");
  291. return false;
  292. }
  293. }
  294. return true;
  295. }
  296. #endregion
  297. #region "Init"
  298. private void UIF041030_Load(object sender, EventArgs e)
  299. {
  300. try
  301. {
  302. this.cmb_GrpType.DisplayLayout.Bands[0].Columns[0].Band.ColHeadersVisible = false;
  303. this.cmb_GrpType.DisplayLayout.Bands[0].Columns[0].Width = this.cmb_GrpType.Width;
  304. this.cmb_Type.DisplayLayout.Bands[0].Columns[0].Band.ColHeadersVisible = false;
  305. this.cmb_Type.DisplayLayout.Bands[0].Columns[0].Width = this.cmb_Type.Width;
  306. cmb_GrpType.Value = "厚度";
  307. }
  308. catch (System.Exception ex)
  309. {
  310. System.Diagnostics.Debug.WriteLine(ex.ToString());
  311. }
  312. }
  313. #endregion
  314. #region "Grid Event"
  315. private void ugrd_Group_AfterRowActivate(object sender, EventArgs e)
  316. {
  317. try
  318. {
  319. if (this.ugrd_Group.ActiveRow != null)
  320. {
  321. if (this.cmb_GrpType.Text == "厚度")
  322. {
  323. this.txt_GrpName.Text = this.ugrd_Group.ActiveRow.Cells["THK_GRP_CD"].Value.ToString();
  324. this.cmb_Type.Value = this.ugrd_Group.ActiveRow.Cells["TYPE_"].Value.ToString();
  325. }
  326. else
  327. {
  328. this.txt_GrpName.Text = this.ugrd_Group.ActiveRow.Cells["WTH_GRP_CD"].Value.ToString();
  329. }
  330. this.txt_Mini.Text = this.ugrd_Group.ActiveRow.Cells["MINI"].Value.ToString();
  331. this.txt_Maxi.Text = this.ugrd_Group.ActiveRow.Cells["MAXI"].Value.ToString();
  332. }
  333. }
  334. catch (System.Exception ex)
  335. {
  336. System.Diagnostics.Debug.WriteLine(ex.ToString());
  337. }
  338. }
  339. #endregion
  340. }
  341. }