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

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