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

231 lines
7.9 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 FormICSFIRSTCHECKBYMOAdd : DevExpress.XtraEditors.XtraForm
  21. {
  22. FormICSFIRSTCHECKBYMOUIModel shiftUIModel;
  23. int Flag;
  24. string a = "";
  25. /// <summary>
  26. /// add new
  27. /// </summary>
  28. public FormICSFIRSTCHECKBYMOAdd()
  29. {
  30. InitializeComponent();
  31. chargeFormState("Add");
  32. Flag = 0;
  33. }
  34. /// <summary>
  35. /// edit
  36. /// </summary>
  37. /// <param name="cPersonCode"></param>
  38. public FormICSFIRSTCHECKBYMOAdd(string id)
  39. {
  40. InitializeComponent();
  41. chargeFormState("Edit");
  42. SearchShipToStockInfo(id);
  43. Flag = 1;
  44. }
  45. private void chargeFormState(string state)
  46. {
  47. switch (state)
  48. {
  49. case "Add":
  50. txtMOCODE.Properties.ReadOnly = false;
  51. txtMUSERName.Text = AppConfig.UserName;
  52. txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString();
  53. txtMUSERName.Properties.ReadOnly = true;
  54. txtMTIME.Properties.ReadOnly = true;
  55. break;
  56. case "Edit":
  57. txtMOCODE.Properties.ReadOnly = true;
  58. txtMUSERName.Properties.ReadOnly = true;
  59. txtMTIME.Properties.ReadOnly = true;
  60. break;
  61. }
  62. }
  63. #region 移动窗体
  64. private const int WM_NCHITTEST = 0x84;
  65. private const int HTCLIENT = 0x1;
  66. private const int HTCAPTION = 0x2;
  67. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  68. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  69. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  70. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  71. //重写窗体,使窗体可以不通过自带标题栏实现移动
  72. protected override void WndProc(ref Message m)
  73. {
  74. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  75. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  76. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  77. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  78. switch (m.Msg)
  79. {
  80. case WM_NCHITTEST:
  81. base.WndProc(ref m);
  82. if ((int)m.Result == HTCLIENT)
  83. m.Result = (IntPtr)HTCAPTION;
  84. return;
  85. }
  86. //拦截双击标题栏、移动窗体的系统消息
  87. if (m.Msg != 0xA3)
  88. {
  89. base.WndProc(ref m);
  90. }
  91. }
  92. #endregion
  93. private void SearchShipToStockInfo(string id)
  94. {
  95. shiftUIModel = ICSFIRSTCHECKBYMOBLL.SearchCheckByCode(id, AppConfig.AppConnectString);
  96. a = shiftUIModel.ID;
  97. txtMOCODE.Text = shiftUIModel.icsmo.MOCODE;
  98. txtCHECKDATE.Text = shiftUIModel.CHECKDATE.ToString(); ;
  99. txtCHECKRESULT.Text = shiftUIModel.CHECKRESULT.ToString();
  100. txtMUSERName.Text = AppConfig.UserName;
  101. txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString();
  102. }
  103. #region 关闭
  104. private void btnCancle_Click(object sender, EventArgs e)
  105. {
  106. this.Close();
  107. this.DialogResult = DialogResult.Cancel;
  108. }
  109. private void btnClose_Click(object sender, EventArgs e)
  110. {
  111. this.Close();
  112. this.DialogResult = DialogResult.Cancel;
  113. }
  114. #endregion
  115. #region 生产订单号按钮
  116. private void txtMOCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  117. {
  118. ButtonEdit btn = (ButtonEdit)sender;
  119. string sql = "select distinct MOCODE as [生产订单号],MOMEMO as [工单备注] from dbo.ICSMO with(nolock) WHERE 1=1";
  120. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  121. //if (obj == null)
  122. //{
  123. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  124. //}
  125. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  126. FormDataRefer reForm = new FormDataRefer();
  127. reForm.FormTitle = "工单信息";
  128. DataTable menuData = data;
  129. reForm.DataSource = menuData;
  130. reForm.MSelectFlag = false;
  131. reForm.RowIndexWidth = 35;
  132. reForm.HideCols.Add("ID");
  133. reForm.FormWidth = 500;
  134. reForm.FormHeight = 500;
  135. //reForm.FilterKey = btn.Text;
  136. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  137. if (reForm.ShowDialog() == DialogResult.OK)
  138. {
  139. DataTable retData = reForm.ReturnData;
  140. foreach (DataRow dr in retData.Rows)
  141. {
  142. txtMOCODE.Text = dr["生产订单号"].ToString();
  143. //txtItemName.Text = dr["存货名称"].ToString();
  144. }
  145. }
  146. }
  147. #endregion
  148. #region 新增 修改 的保存
  149. private void btnOK_Click(object sender, EventArgs e)
  150. {
  151. if (txtMOCODE.Text.Trim() == "")
  152. {
  153. ICSBaseSimpleCode.AppshowMessageBox("生产订单号不能为空!");
  154. return;
  155. }
  156. if (txtCHECKDATE.Text.Trim() == "")
  157. {
  158. ICSBaseSimpleCode.AppshowMessageBox("首检日期不能为空!");
  159. return;
  160. }
  161. if (txtCHECKRESULT.Text.Trim() == "")
  162. {
  163. ICSBaseSimpleCode.AppshowMessageBox("检验结果不能为空!");
  164. return;
  165. }
  166. FormICSFIRSTCHECKBYMOUIModel shiftInfo = new FormICSFIRSTCHECKBYMOUIModel();
  167. shiftInfo.ID = a;
  168. shiftInfo.MOCODE = txtMOCODE.Text.Trim();
  169. shiftInfo.CHECKDATE = Convert.ToDateTime(txtCHECKDATE.Text.Trim());
  170. shiftInfo.CHECKRESULT = txtCHECKRESULT.Text.Trim();
  171. shiftInfo.MUSER = AppConfig.UserId;
  172. shiftInfo.MUSERName = AppConfig.UserName;
  173. shiftInfo.MTIME = System.DateTime.Parse(txtMTIME.Text);
  174. shiftInfo.WorkPoint = AppConfig.WorkPointCode;
  175. shiftInfo.EATTRIBUTE1 = null;
  176. try
  177. {
  178. ICSFIRSTCHECKBYMOBLL.Add(shiftInfo, AppConfig.AppConnectString);
  179. this.Close();
  180. ICSBaseSimpleCode.AppshowMessageBox("操作成功");
  181. }
  182. catch (Exception ex)
  183. {
  184. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  185. }
  186. }
  187. #endregion
  188. }
  189. }