华恒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.

313 lines
13 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.Entity;
  15. using ICSSoft.Base.ReferForm.AppReferForm;
  16. using ICSSoft.Frame.Data.BLL;
  17. using ICSSoft.Frame.Helper;
  18. namespace ICSSoft.Frame.APP
  19. {
  20. public partial class FormICSEquipmentAdd : DevExpress.XtraEditors.XtraForm
  21. {
  22. FormICSEquipmentUIModel equipmentUIModel;
  23. int Flag;
  24. string eqpid;
  25. #region 构造函数
  26. /// <summary>
  27. /// add new
  28. /// </summary>
  29. public FormICSEquipmentAdd()
  30. {
  31. InitializeComponent();
  32. chargeFormState("Add");
  33. Flag = 0;
  34. }
  35. /// <summary>
  36. /// edit
  37. /// </summary>
  38. /// <param name="cPersonCode"></param>
  39. public FormICSEquipmentAdd(string id)
  40. {
  41. InitializeComponent();
  42. chargeFormState("Edit");
  43. SearchShiftInfo(id);
  44. Flag = 1;
  45. }
  46. #endregion
  47. private void chargeFormState(string state)
  48. {
  49. switch (state)
  50. {
  51. case "Add":
  52. //txtModel.Properties.ReadOnly = false;
  53. //txtEQPStatus.Properties.ReadOnly = false;
  54. txtMUSERName.Text = AppConfig.UserName;
  55. txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString();
  56. txtMUSERName.Properties.ReadOnly = true;
  57. txtMTIME.Properties.ReadOnly = true;
  58. txtEQPStatus.Text = "新增";
  59. txtEQPStatus.Properties.ReadOnly = true;
  60. txtType.Text = "001";
  61. txtType.Properties.ReadOnly = true;
  62. break;
  63. case "Edit":
  64. txtEQPCode.Properties.ReadOnly = true;
  65. txtType.Properties.ReadOnly = true;
  66. txtEQPStatus.Properties.ReadOnly = true;
  67. txtMUSERName.Properties.ReadOnly = true;
  68. txtMTIME.Properties.ReadOnly = true;
  69. break;
  70. }
  71. }
  72. #region 移动窗体
  73. private const int WM_NCHITTEST = 0x84;
  74. private const int HTCLIENT = 0x1;
  75. private const int HTCAPTION = 0x2;
  76. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  77. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  78. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  79. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  80. //重写窗体,使窗体可以不通过自带标题栏实现移动
  81. protected override void WndProc(ref Message m)
  82. {
  83. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  84. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  85. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  86. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  87. switch (m.Msg)
  88. {
  89. case WM_NCHITTEST:
  90. base.WndProc(ref m);
  91. if ((int)m.Result == HTCLIENT)
  92. m.Result = (IntPtr)HTCAPTION;
  93. return;
  94. }
  95. //拦截双击标题栏、移动窗体的系统消息
  96. if (m.Msg != 0xA3)
  97. {
  98. base.WndProc(ref m);
  99. }
  100. }
  101. #endregion
  102. #region 页面加载
  103. private void FormICSEquipmentAdd_Load(object sender, EventArgs e)
  104. {
  105. #region 设备属性
  106. string sql = @"SELECT EnumText as 设备属性 FROM Sys_EnumValues WHERE EnumKey='00009'";
  107. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  108. txtProperty.Properties.ValueMember = "设备属性";
  109. txtProperty.Properties.DisplayMember = "设备属性";
  110. txtProperty.Properties.DataSource = dt;
  111. txtProperty.Properties.NullText = "";//空时的值
  112. txtProperty.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  113. txtProperty.Properties.ValidateOnEnterKey = true;//回车确认
  114. txtProperty.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  115. txtProperty.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  116. //自适应宽度
  117. txtProperty.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  118. #endregion
  119. }
  120. #endregion
  121. private void SearchShiftInfo(string id)
  122. {
  123. equipmentUIModel = ICSEquipmentBLL.SearchEquipmentInfoByCode(id, AppConfig.AppConnectString);
  124. txtEQPCode.Text = equipmentUIModel.EQPCode;
  125. txtEQPName.Text = equipmentUIModel.EQPName;
  126. txtModel.Text = equipmentUIModel.Model;
  127. txtType.Text = equipmentUIModel.Type;
  128. txtEQPStatus.Text = equipmentUIModel.EQPStatus;
  129. txtEQPDESC.Text = equipmentUIModel.EQPDESC;
  130. txtEQPTypeCode.Text = equipmentUIModel.EType;
  131. txtCompany.Text = equipmentUIModel.Company;
  132. txtAddress.Text = equipmentUIModel.Address;
  133. txtTelPhone.Text = equipmentUIModel.TelPhone;
  134. txtMUSERName.Text = AppConfig.UserName;
  135. txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString();
  136. eqpid = equipmentUIModel.EQPID;
  137. if (equipmentUIModel.MTStatus == "是")
  138. txtISFW.Checked = true;
  139. else
  140. txtISFW.Checked = false;
  141. txtProperty.Text = equipmentUIModel.EATTRIBUTE1;//设备属性
  142. }
  143. #region 关闭
  144. private void btnCancle_Click(object sender, EventArgs e)
  145. {
  146. this.Close();
  147. this.DialogResult = DialogResult.Cancel;
  148. }
  149. private void btnClose_Click(object sender, EventArgs e)
  150. {
  151. this.Close();
  152. this.DialogResult = DialogResult.Cancel;
  153. }
  154. #endregion
  155. #region 产线代码按钮
  156. private void txtSSCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  157. {
  158. ButtonEdit btn = (ButtonEdit)sender;
  159. string sql = "select distinct SSCODE as [产线代码],SSDESC as [产线描述] from dbo.ICSSS with(nolock) WHERE 1=1";
  160. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  161. //if (obj == null)
  162. //{
  163. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  164. //}
  165. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  166. FormDataRefer reForm = new FormDataRefer();
  167. reForm.FormTitle = "产线信息";
  168. DataTable menuData = data;
  169. reForm.DataSource = menuData;
  170. reForm.MSelectFlag = false;
  171. reForm.RowIndexWidth = 35;
  172. reForm.HideCols.Add("ID");
  173. reForm.FormWidth = 500;
  174. reForm.FormHeight = 500;
  175. //reForm.FilterKey = btn.Text;
  176. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  177. if (reForm.ShowDialog() == DialogResult.OK)
  178. {
  179. DataTable retData = reForm.ReturnData;
  180. foreach (DataRow dr in retData.Rows)
  181. {
  182. txtSSCode.Text = dr["产线代码"].ToString();
  183. //txtItemName.Text = dr["存货名称"].ToString();
  184. }
  185. }
  186. }
  187. #endregion
  188. #region 设备类型按钮
  189. private void txtEType_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  190. {
  191. ButtonEdit btn = (ButtonEdit)sender;
  192. string sql = "select distinct TypeCODE as [设备组编码],TypeDESC as [设备组描述] from ICSEquipmentType with(nolock) WHERE 1=1";
  193. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  194. //if (obj == null)
  195. //{
  196. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  197. //}
  198. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  199. FormDataRefer reForm = new FormDataRefer();
  200. reForm.FormTitle = "设备类型信息";
  201. DataTable menuData = data;
  202. reForm.DataSource = menuData;
  203. reForm.MSelectFlag = false;
  204. reForm.RowIndexWidth = 35;
  205. reForm.HideCols.Add("ID");
  206. reForm.FormWidth = 500;
  207. reForm.FormHeight = 500;
  208. //reForm.FilterKey = btn.Text;
  209. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  210. if (reForm.ShowDialog() == DialogResult.OK)
  211. {
  212. DataTable retData = reForm.ReturnData;
  213. foreach (DataRow dr in retData.Rows)
  214. {
  215. txtEQPTypeCode.Text = dr["设备组编码"].ToString();
  216. //txtItemName.Text = dr["存货名称"].ToString();
  217. }
  218. }
  219. }
  220. #endregion
  221. #region 新增 修改
  222. private void btnOK_Click(object sender, EventArgs e)
  223. {
  224. if (txtEQPCode.Text.Trim() == "")
  225. {
  226. ICSBaseSimpleCode.AppshowMessageBox("设备编号不能为空!");
  227. return;
  228. }
  229. if (txtEQPName.Text.Trim() == "")
  230. {
  231. ICSBaseSimpleCode.AppshowMessageBox("设备名称不能为空!");
  232. return;
  233. }
  234. FormICSEquipmentUIModel equipmentInfo = new FormICSEquipmentUIModel();
  235. equipmentInfo.EQPID = eqpid;
  236. equipmentInfo.EQPCode = txtEQPCode.Text.Trim();
  237. equipmentInfo.EQPName = txtEQPName.Text.Trim();
  238. equipmentInfo.Model = txtModel.Text.Trim();
  239. equipmentInfo.Type = txtType.Text.Trim();
  240. equipmentInfo.EQPStatus = txtEQPStatus.Text.Trim();
  241. equipmentInfo.EQPDESC = txtEQPDESC.Text.Trim();
  242. equipmentInfo.EType = txtEQPTypeCode.Text.Trim();
  243. equipmentInfo.Company = txtCompany.Text.Trim();
  244. equipmentInfo.Address = txtAddress.Text.Trim();
  245. equipmentInfo.TelPhone = txtTelPhone.Text.Trim();
  246. //equipmentInfo.SSCode = txtSSCode.Text.Trim();
  247. equipmentInfo.MUSER = AppConfig.UserId;
  248. equipmentInfo.MUSERName = AppConfig.UserName;
  249. equipmentInfo.MTIME = System.DateTime.Parse(txtMTIME.Text);
  250. equipmentInfo.WorkPoint = AppConfig.WorkPointCode;
  251. equipmentInfo.EATTRIBUTE1 = txtProperty.Text.Trim();//设备属性
  252. if (txtISFW.Checked)
  253. {
  254. equipmentInfo.MTStatus="是";
  255. }
  256. else {
  257. equipmentInfo.MTStatus = "否";
  258. }
  259. try
  260. {
  261. ICSEquipmentBLL.Add(equipmentInfo, AppConfig.AppConnectString);
  262. this.Close();
  263. ICSBaseSimpleCode.AppshowMessageBox("操作成功");
  264. }
  265. catch (Exception ex)
  266. {
  267. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  268. }
  269. }
  270. #endregion
  271. private void FormICSShiftAdd_Load()
  272. {
  273. DataTable dt = new DataTable();
  274. dt = ICSShiftBLL.GetShiftCode();
  275. string str = dt.Rows[0]["SHIFTCODE"].ToString();
  276. if (str == "1101000001")
  277. {
  278. txtModel.Text = (int.Parse(str) + 1).ToString();
  279. }
  280. else
  281. {
  282. str = "1101000001";
  283. }
  284. }
  285. }
  286. }