锐腾搅拌上料功能
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.

242 lines
8.9 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=new ICSSS();
  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 (SEGid=="")
  101. {
  102. ICSBaseSimpleCode.AppshowMessageBox("请选择车间!");
  103. return;
  104. }
  105. if (txtSSCODE.Text.Trim() == "")
  106. {
  107. ICSBaseSimpleCode.AppshowMessageBox("产线代码不可为空!");
  108. return;
  109. }
  110. if (txtSSDESC.Text == "")
  111. {
  112. ICSBaseSimpleCode.AppshowMessageBox("产线名称不可为空!");
  113. return;
  114. }
  115. if (flag == 0 && i != 0)
  116. {
  117. ICSBaseSimpleCode.AppshowMessageBox("[产线代码]已存在!");
  118. return;
  119. }
  120. try
  121. {
  122. personInfo.SEGID = SEGid;
  123. personInfo.SSCODE = txtSSCODE.Text;
  124. personInfo.SSDESC = txtSSDESC.Text;
  125. personInfo.MUSER = AppConfig.UserCode;
  126. personInfo.MUSERName = AppConfig.UserName;
  127. personInfo.MTIME = System.DateTime.Parse(txtUseTime.Text);
  128. personInfo.WorkPoint = AppConfig.WorkPointCode;
  129. ICSSSBLL.Add(personInfo, AppConfig.AppConnectString);
  130. ICSBaseSimpleCode.AppshowMessageBox("保存成功!");
  131. }
  132. catch (Exception ex)
  133. {
  134. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  135. return;
  136. }
  137. this.Close();
  138. this.DialogResult = DialogResult.Yes;
  139. }
  140. private void txtItemCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  141. {
  142. }
  143. // #region 班制信息
  144. // private void btnShift_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  145. // {
  146. // if(txtSegCode.Text=="")
  147. // {
  148. // ICSBaseSimpleCode.AppshowMessageBox("请先选择[车间代码]!");
  149. // return;
  150. // }
  151. // txtShiftTypeCode.Text = "";
  152. // ButtonEdit btn = (ButtonEdit)sender;
  153. // string str = ICSSSBLL.SelectShiftTypeId1(txtSegCode.Text).Rows[0][0].ToString();
  154. // string sql = @"select SHIFTTYPECODE as [班制代码],SHIFTTYPEDESC as [描述],EFFDATE as [开始时间],IVLDATE as [结束时间]
  155. // from dbo.ICSSHIFTTYPE
  156. // where ID='" +str+"'";
  157. // sql = string.Format(sql);
  158. // DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  159. // FormDataRefer reForm = new FormDataRefer();
  160. // reForm.FormTitle = "班制信息";
  161. // DataTable menuData = data;
  162. // reForm.DataSource = menuData;
  163. // reForm.MSelectFlag = false;
  164. // reForm.RowIndexWidth = 35;
  165. // reForm.HideCols.Add("ID");
  166. // reForm.FormWidth = 800;
  167. // reForm.FormHeight = 600;
  168. // reForm.FilterKey = btn.Text;
  169. // if (reForm.ShowDialog() == DialogResult.OK)
  170. // {
  171. // DataTable retData = reForm.ReturnData;
  172. // foreach (DataRow dr in retData.Rows)
  173. // {
  174. // txtShiftTypeCode.Text = dr["班制代码"].ToString();
  175. // }
  176. // }
  177. // }
  178. // #endregion
  179. string SEGid = "";
  180. #region 车间信息
  181. private void txtSEGCODE_Click(object sender, EventArgs e)
  182. {
  183. if (txtShiftTypeCode.Text != "")
  184. {
  185. txtShiftTypeCode.Text = "";
  186. }
  187. txtSEGCODE.Text = "";
  188. ButtonEdit btn = (ButtonEdit)sender;
  189. string sql = @"select ID,SEGCODE as [车间代码],SEGDESC as [描述]
  190. from dbo.ICSSEG
  191. where 1=1 AND WorkPoint='{0}'";
  192. sql = string.Format(sql,AppConfig.WorkPointCode);
  193. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  194. FormDataRefer reForm = new FormDataRefer();
  195. reForm.FormTitle = "车间信息";
  196. DataTable menuData = data;
  197. reForm.DataSource = menuData;
  198. reForm.MSelectFlag = false;
  199. reForm.RowIndexWidth = 35;
  200. reForm.HideCols.Add("ID");
  201. reForm.FormWidth = 800;
  202. reForm.FormHeight = 600;
  203. reForm.FilterKey = btn.Text;
  204. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  205. if (reForm.ShowDialog() == DialogResult.OK)
  206. {
  207. DataTable retData = reForm.ReturnData;
  208. foreach (DataRow dr in retData.Rows)
  209. {
  210. SEGid = dr["ID"].ToString();
  211. txtSEGCODE.Text = dr["车间代码"].ToString();
  212. }
  213. }
  214. }
  215. #endregion
  216. }
  217. }