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

296 lines
11 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 FormICSEquipmentRepair : DevExpress.XtraEditors.XtraForm
  21. {
  22. FormICSEquipmentUIModel equipmentUIModel;
  23. int Flag;
  24. string eqpid;
  25. /// <summary>
  26. /// add new
  27. /// </summary>
  28. public FormICSEquipmentRepair()
  29. {
  30. InitializeComponent();
  31. chargeFormState("Add");
  32. Flag = 0;
  33. }
  34. /// <summary>
  35. /// edit
  36. /// </summary>
  37. /// <param name="cPersonCode"></param>
  38. public FormICSEquipmentRepair(string id)
  39. {
  40. InitializeComponent();
  41. chargeFormState("Edit");
  42. SearchShiftInfo(id);
  43. Flag = 1;
  44. }
  45. private void chargeFormState(string state)
  46. {
  47. switch (state)
  48. {
  49. case "Add":
  50. //txtModel.Properties.ReadOnly = false;
  51. //txtEQPStatus.Properties.ReadOnly = false;
  52. txtFINDUSER.Text = AppConfig.UserName;
  53. txtFINDMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString();
  54. txtFINDUSER.Properties.ReadOnly = true;
  55. txtFINDMTIME.Properties.ReadOnly = true;
  56. //txtEQPStatus.Text = "新增";
  57. //txtEQPStatus.Properties.ReadOnly = true;
  58. //txtType.Text = "001";
  59. //txtType.Properties.ReadOnly = true;
  60. break;
  61. case "Edit":
  62. //txtModel.Properties.ReadOnly = true;
  63. //txtEQPStatus.Properties.ReadOnly = false;
  64. txtFINDUSER.Properties.ReadOnly = true;
  65. txtFINDMTIME.Properties.ReadOnly = true;
  66. break;
  67. }
  68. }
  69. #region 移动窗体
  70. private const int WM_NCHITTEST = 0x84;
  71. private const int HTCLIENT = 0x1;
  72. private const int HTCAPTION = 0x2;
  73. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  74. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  75. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  76. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  77. //重写窗体,使窗体可以不通过自带标题栏实现移动
  78. protected override void WndProc(ref Message m)
  79. {
  80. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  81. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  82. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  83. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  84. switch (m.Msg)
  85. {
  86. case WM_NCHITTEST:
  87. base.WndProc(ref m);
  88. if ((int)m.Result == HTCLIENT)
  89. m.Result = (IntPtr)HTCAPTION;
  90. return;
  91. }
  92. //拦截双击标题栏、移动窗体的系统消息
  93. if (m.Msg != 0xA3)
  94. {
  95. base.WndProc(ref m);
  96. }
  97. }
  98. #endregion
  99. private void SearchShiftInfo(string id)
  100. {
  101. //equipmentUIModel = ICSEquipmentBLL.SearchEquipmentInfoByCode(id, AppConfig.AppConnectString);
  102. //txtEQPCode.Text = equipmentUIModel.EQPCode;
  103. //txtModel.Text = equipmentUIModel.Model;
  104. //txtType.Text = equipmentUIModel.Type;
  105. //txtEQPStatus.Text = equipmentUIModel.EQPStatus;
  106. //txtEQPDESC.Text = equipmentUIModel.EQPDESC;
  107. //txtEType.Text = equipmentUIModel.EType;
  108. //txtCompany.Text = equipmentUIModel.Company;
  109. //txtAddress.Text = equipmentUIModel.Address;
  110. //txtTelPhone.Text = equipmentUIModel.TelPhone;
  111. //txtSSCode.Text = equipmentUIModel.SS.SSCODE;
  112. //txtFINDUSER.Text = AppConfig.UserName;
  113. //txtFINDMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString();
  114. //eqpid = equipmentUIModel.EQPID;
  115. }
  116. #region 关闭
  117. private void btnCancle_Click(object sender, EventArgs e)
  118. {
  119. this.Close();
  120. this.DialogResult = DialogResult.Cancel;
  121. }
  122. private void btnClose_Click(object sender, EventArgs e)
  123. {
  124. this.Close();
  125. this.DialogResult = DialogResult.Cancel;
  126. }
  127. #endregion
  128. #region 设备按钮
  129. private void txtEQPCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  130. {
  131. ButtonEdit btn = (ButtonEdit)sender;
  132. string sql = "select distinct EQPID as [guid],EQPCode as [设备],EQPName as [设备名称] from dbo.ICSEquipment with(nolock) WHERE EType='" + txtEType.Text + "' and 1=1";
  133. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  134. //if (obj == null)
  135. //{
  136. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  137. //}
  138. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  139. FormDataRefer reForm = new FormDataRefer();
  140. reForm.FormTitle = "设备信息";
  141. DataTable menuData = data;
  142. reForm.DataSource = menuData;
  143. reForm.MSelectFlag = false;
  144. reForm.RowIndexWidth = 35;
  145. reForm.HideCols.Add("guid");
  146. reForm.FormWidth = 500;
  147. reForm.FormHeight = 500;
  148. //reForm.FilterKey = btn.Text;
  149. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  150. if (reForm.ShowDialog() == DialogResult.OK)
  151. {
  152. DataTable retData = reForm.ReturnData;
  153. foreach (DataRow dr in retData.Rows)
  154. {
  155. txtEQPCode.Text = dr["设备"].ToString();
  156. txtEQPDESC.Text = dr["设备名称"].ToString();
  157. eqpid = dr["guid"].ToString();
  158. }
  159. }
  160. }
  161. #endregion
  162. #region 设备类型按钮
  163. private void txtEType_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  164. {
  165. ButtonEdit btn = (ButtonEdit)sender;
  166. string sql = "select distinct EnumValue as [类型编码],EnumText as [设备类型] from dbo.Sys_EnumValues with(nolock) WHERE EnumKey='001' and 1=1";
  167. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  168. //if (obj == null)
  169. //{
  170. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  171. //}
  172. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  173. FormDataRefer reForm = new FormDataRefer();
  174. reForm.FormTitle = "设备类型信息";
  175. DataTable menuData = data;
  176. reForm.DataSource = menuData;
  177. reForm.MSelectFlag = false;
  178. reForm.RowIndexWidth = 35;
  179. reForm.HideCols.Add("设备ID");
  180. reForm.FormWidth = 500;
  181. reForm.FormHeight = 500;
  182. //reForm.FilterKey = btn.Text;
  183. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  184. if (reForm.ShowDialog() == DialogResult.OK)
  185. {
  186. DataTable retData = reForm.ReturnData;
  187. foreach (DataRow dr in retData.Rows)
  188. {
  189. txtEType.Text = dr["设备类型"].ToString();
  190. //txtItemName.Text = dr["存货名称"].ToString();
  191. }
  192. }
  193. }
  194. #endregion
  195. #region 新增 修改
  196. private void btnOK_Click(object sender, EventArgs e)
  197. {
  198. if (txtEType.Text.Trim() == "")
  199. {
  200. ICSBaseSimpleCode.AppshowMessageBox("设备类型不能为空!");
  201. return;
  202. }
  203. if (txtEQPCode.Text.Trim() == "")
  204. {
  205. ICSBaseSimpleCode.AppshowMessageBox("设备编号不能为空!");
  206. return;
  207. }
  208. FormICSEQPTSUIModel equipmentInfo = new FormICSEQPTSUIModel();
  209. equipmentInfo.GUID = AppConfig.GetGuid();
  210. equipmentInfo.EQPID = eqpid;
  211. equipmentInfo.EQPCode = txtEQPCode.Text.Trim();
  212. equipmentInfo.FINDUSER = txtFINDUSER.Text.Trim();
  213. equipmentInfo.FINDMTIME =Convert.ToDateTime(txtFINDMTIME.Text.Trim());
  214. equipmentInfo.TSINFO = txtTSINFO.Text.Trim();
  215. equipmentInfo.REASON = "";
  216. equipmentInfo.Solution = "";
  217. equipmentInfo.Result = "";
  218. equipmentInfo.TSType = "";
  219. equipmentInfo.STATUS = "NEW";
  220. equipmentInfo.Duration = 0;
  221. equipmentInfo.MUSER = AppConfig.UserId;
  222. equipmentInfo.MUSERName = AppConfig.UserName;
  223. equipmentInfo.MTIME = System.DateTime.Parse(txtFINDMTIME.Text);
  224. equipmentInfo.WorkPoint = AppConfig.WorkPointCode;
  225. equipmentInfo.EATTRIBUTE1 = null;
  226. try
  227. {
  228. ICSEQPTSBLL.Add(equipmentInfo, AppConfig.AppConnectString);
  229. this.Close();
  230. ICSBaseSimpleCode.AppshowMessageBox("操作成功");
  231. }
  232. catch (Exception ex)
  233. {
  234. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  235. }
  236. }
  237. #endregion
  238. private void FormICSShiftAdd_Load()
  239. {
  240. DataTable dt = new DataTable();
  241. dt = ICSShiftBLL.GetShiftCode();
  242. string str = dt.Rows[0]["SHIFTCODE"].ToString();
  243. if (str == "1101000001")
  244. {
  245. //txtModel.Text = (int.Parse(str) + 1).ToString();
  246. }
  247. else
  248. {
  249. str = "1101000001";
  250. }
  251. }
  252. }
  253. }