华恒Mes鼎捷代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

267 lines
9.7 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using DevExpress.XtraEditors;
  9. using ICSSoft.Frame.WorkPoint.Entity;
  10. using ICSSoft.Frame.WorkPoint.BLL;
  11. using ICSSoft.Base.Config.AppConfig;
  12. using ICSSoft.Base.Config.DBHelper;
  13. using System.Text.RegularExpressions;
  14. using ICSSoft.Frame.Data.BLL;
  15. using ICSSoft.Frame.Data.Entity;
  16. using ICSSoft.Base.ReferForm.AppReferForm;
  17. namespace ICSSoft.Frame.APP
  18. {
  19. public partial class FormICSSSAdd : DevExpress.XtraEditors.XtraForm
  20. {
  21. ICSSS personInfo;
  22. int flag;
  23. public FormICSSSAdd()
  24. {
  25. InitializeComponent();
  26. flag = 0;
  27. txtSSCODE.ReadOnly = false;
  28. DataTable dv = ICSSSBLL.SelectICSSSCode();
  29. MUSER.Text = AppConfig.UserName;
  30. txtUseTime.Text = DateTime.Now.ToString();
  31. }
  32. public FormICSSSAdd(string id)
  33. {
  34. InitializeComponent();
  35. flag = 1;
  36. txtSSCODE.ReadOnly = true;
  37. labTop.Text = "修改产线信息";
  38. //comSSType.Items.Clear();
  39. //comSSType.DropDownStyle = ComboBoxStyle.DropDown;
  40. SearchMandayInfo(id);
  41. }
  42. private void SearchMandayInfo(string Id)
  43. {
  44. personInfo = ICSSSBLL.SearchPersonInfoByCode(Id, AppConfig.AppConnectString);
  45. txtSSCODE.Text= personInfo.SSCODE;
  46. txtSSDESC.Text = personInfo.SSDESC;
  47. MUSER.Text = personInfo.MUSERName;
  48. txtUseTime.Text = personInfo.MTIME.ToString();
  49. }
  50. #region 移动窗体
  51. private const int WM_NCHITTEST = 0x84;
  52. private const int HTCLIENT = 0x1;
  53. private const int HTCAPTION = 0x2;
  54. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  55. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  56. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  57. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  58. //重写窗体,使窗体可以不通过自带标题栏实现移动
  59. protected override void WndProc(ref Message m)
  60. {
  61. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  62. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  63. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  64. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  65. switch (m.Msg)
  66. {
  67. case WM_NCHITTEST:
  68. base.WndProc(ref m);
  69. if ((int)m.Result == HTCLIENT)
  70. m.Result = (IntPtr)HTCAPTION;
  71. return;
  72. }
  73. //拦截双击标题栏、移动窗体的系统消息
  74. if (m.Msg != 0xA3)
  75. {
  76. base.WndProc(ref m);
  77. }
  78. }
  79. #endregion
  80. private void btnClose_Click(object sender, EventArgs e)
  81. {
  82. this.Close();
  83. }
  84. private void btnCancle_Click(object sender, EventArgs e)
  85. {
  86. this.Close();
  87. this.DialogResult = DialogResult.Cancel;
  88. }
  89. private void btnOK_Click(object sender, EventArgs e)
  90. {
  91. int i = 0;
  92. DataTable dt = ICSSSBLL.SelectICSSSCode();
  93. foreach (DataRow dr in dt.Rows)
  94. {
  95. if (txtSSCODE.Text == dr[0].ToString())
  96. {
  97. i++;
  98. }
  99. }
  100. if (txtSSCODE.Text.Trim() == "")
  101. {
  102. ICSBaseSimpleCode.AppshowMessageBox("产线代码不可为空!");
  103. return;
  104. }
  105. if (txtSSDESC.Text == "" )
  106. {
  107. ICSBaseSimpleCode.AppshowMessageBox("产线名称不可为空!");
  108. return;
  109. }
  110. else if (i != 0 && flag==0)
  111. {
  112. ICSBaseSimpleCode.AppshowMessageBox("[产线代码]已存在!");
  113. return;
  114. }
  115. else
  116. {
  117. if (flag == 0)
  118. {
  119. try
  120. {
  121. ICSSS personInfo = new ICSSS();
  122. personInfo.SSCODE = txtSSCODE.Text;
  123. personInfo.SSDESC = txtSSDESC.Text;
  124. personInfo.MUSER = AppConfig.UserCode;
  125. personInfo.MUSERName = AppConfig.UserName;
  126. personInfo.MTIME = System.DateTime.Parse(txtUseTime.Text);
  127. personInfo.WorkPoint = AppConfig.WorkPointCode;
  128. ICSSSBLL.Add(personInfo, AppConfig.AppConnectString);
  129. }
  130. catch (Exception ex)
  131. {
  132. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  133. }
  134. }
  135. if (flag == 1)
  136. {
  137. try
  138. {
  139. personInfo.SSCODE = txtSSCODE.Text;
  140. personInfo.SSDESC = txtSSDESC.Text;
  141. personInfo.MUSER = AppConfig.UserCode;
  142. personInfo.MUSERName = AppConfig.UserName;
  143. personInfo.MTIME = System.DateTime.Parse(txtUseTime.Text);
  144. personInfo.WorkPoint = AppConfig.WorkPointCode;
  145. ICSSSBLL.Add(personInfo, AppConfig.AppConnectString);
  146. }
  147. catch (Exception ex)
  148. {
  149. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  150. }
  151. }
  152. this.Close();
  153. this.DialogResult = DialogResult.Yes;
  154. }
  155. }
  156. private void txtItemCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  157. {
  158. }
  159. // #region 班制信息
  160. // private void btnShift_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  161. // {
  162. // if(txtSegCode.Text=="")
  163. // {
  164. // ICSBaseSimpleCode.AppshowMessageBox("请先选择[车间代码]!");
  165. // return;
  166. // }
  167. // txtShiftTypeCode.Text = "";
  168. // ButtonEdit btn = (ButtonEdit)sender;
  169. // string str = ICSSSBLL.SelectShiftTypeId1(txtSegCode.Text).Rows[0][0].ToString();
  170. // string sql = @"select SHIFTTYPECODE as [班制代码],SHIFTTYPEDESC as [描述],EFFDATE as [开始时间],IVLDATE as [结束时间]
  171. // from dbo.ICSSHIFTTYPE
  172. // where ID='" +str+"'";
  173. // sql = string.Format(sql);
  174. // DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  175. // FormDataRefer reForm = new FormDataRefer();
  176. // reForm.FormTitle = "班制信息";
  177. // DataTable menuData = data;
  178. // reForm.DataSource = menuData;
  179. // reForm.MSelectFlag = false;
  180. // reForm.RowIndexWidth = 35;
  181. // reForm.HideCols.Add("ID");
  182. // reForm.FormWidth = 800;
  183. // reForm.FormHeight = 600;
  184. // reForm.FilterKey = btn.Text;
  185. // if (reForm.ShowDialog() == DialogResult.OK)
  186. // {
  187. // DataTable retData = reForm.ReturnData;
  188. // foreach (DataRow dr in retData.Rows)
  189. // {
  190. // txtShiftTypeCode.Text = dr["班制代码"].ToString();
  191. // }
  192. // }
  193. // }
  194. // #endregion
  195. // #region 车间信息
  196. // private void txtSegCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  197. // {
  198. // if (txtShiftTypeCode.Text != "")
  199. // {
  200. // txtShiftTypeCode.Text = "";
  201. // }
  202. // txtSegCode.Text = "";
  203. // ButtonEdit btn = (ButtonEdit)sender;
  204. // string sql = @"select SEGCODE as [车间代码],SEGDESC as [描述]
  205. // from dbo.ICSSEG
  206. // where 1=1";
  207. // sql = string.Format(sql);
  208. // DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  209. // FormDataRefer reForm = new FormDataRefer();
  210. // reForm.FormTitle = "车间信息";
  211. // DataTable menuData = data;
  212. // reForm.DataSource = menuData;
  213. // reForm.MSelectFlag = false;
  214. // reForm.RowIndexWidth = 35;
  215. // reForm.HideCols.Add("ID");
  216. // reForm.FormWidth = 800;
  217. // reForm.FormHeight = 600;
  218. // reForm.FilterKey = btn.Text;
  219. // //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  220. // if (reForm.ShowDialog() == DialogResult.OK)
  221. // {
  222. // DataTable retData = reForm.ReturnData;
  223. // foreach (DataRow dr in retData.Rows)
  224. // {
  225. // txtSegCode.Text = dr["车间代码"].ToString();
  226. // }
  227. // }
  228. // }
  229. // #endregion
  230. private void label2_Click(object sender, EventArgs e)
  231. {
  232. }
  233. }
  234. }