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

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