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

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