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

334 lines
13 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.Base.Config.AppConfig;
  10. using System.Data.Linq;
  11. using System.Linq;
  12. using ICSSoft.Base.Language.Tool;
  13. using System.Reflection;
  14. using ICSSoft.Base.Config.DBHelper;
  15. using ICSSoft.Base.ReferForm;
  16. using ICSSoft.Base.Report;
  17. using ICSSoft.Base.ReferForm.AppReferForm;
  18. using ICSSoft.Frame.Data.Entity;
  19. using ICSSoft.Frame.Data.BLL;
  20. namespace ICSSoft.Frame.APP
  21. {
  22. public partial class FormICSECGAdd : DevExpress.XtraEditors.XtraForm
  23. {
  24. String guid = "";
  25. FormICSECGUIModel ecgUIModel;
  26. int Flag;
  27. /// <summary>
  28. /// add new
  29. /// </summary>
  30. public FormICSECGAdd()
  31. {
  32. InitializeComponent();
  33. chargeFormState("Add");
  34. Flag = 0;
  35. }
  36. /// <summary>
  37. /// edit
  38. /// </summary>
  39. /// <param name="cPersonCode"></param>
  40. public FormICSECGAdd(string id)
  41. {
  42. InitializeComponent();
  43. chargeFormState("Edit");
  44. SearchEcgInfo(id);
  45. Flag = 1;
  46. }
  47. private void chargeFormState(string state)
  48. {
  49. switch (state)
  50. {
  51. case "Add":
  52. txtECGCODE.Properties.ReadOnly = false;
  53. txtROUTECODE.Properties.ReadOnly = false;
  54. txtOPCODE.Properties.ReadOnly = false;
  55. txtRESCODE.Properties.ReadOnly = false;
  56. txtMUSERName.Text = AppConfig.UserName;
  57. txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString();
  58. txtMUSERName.Properties.ReadOnly = true;
  59. txtMTIME.Properties.ReadOnly = true;
  60. break;
  61. case "Edit":
  62. txtECGCODE.Properties.ReadOnly = true;
  63. txtROUTECODE.Properties.ReadOnly = false;
  64. txtRESCODE.Properties.ReadOnly = false;
  65. txtOPCODE.Properties.ReadOnly = false;
  66. txtMUSERName.Properties.ReadOnly = true;
  67. txtMTIME.Properties.ReadOnly = true;
  68. break;
  69. }
  70. }
  71. #region 移动窗体
  72. private const int WM_NCHITTEST = 0x84;
  73. private const int HTCLIENT = 0x1;
  74. private const int HTCAPTION = 0x2;
  75. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  76. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  77. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  78. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  79. //重写窗体,使窗体可以不通过自带标题栏实现移动
  80. protected override void WndProc(ref Message m)
  81. {
  82. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  83. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  84. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  85. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  86. switch (m.Msg)
  87. {
  88. case WM_NCHITTEST:
  89. base.WndProc(ref m);
  90. if ((int)m.Result == HTCLIENT)
  91. m.Result = (IntPtr)HTCAPTION;
  92. return;
  93. }
  94. //拦截双击标题栏、移动窗体的系统消息
  95. if (m.Msg != 0xA3)
  96. {
  97. base.WndProc(ref m);
  98. }
  99. }
  100. #endregion
  101. #region 途程代码按钮
  102. private void txtROUTECODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  103. {
  104. ButtonEdit btn = (ButtonEdit)sender;
  105. string sql = "select distinct ROUTECODE as [途程代码], ROUTEDESC as [途程描述] from ICSROUTE with(nolock) WHERE 1=1";
  106. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  107. //if (obj == null)
  108. //{
  109. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  110. //}
  111. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  112. FormDataRefer reForm = new FormDataRefer();
  113. reForm.FormTitle = "途程信息";
  114. DataTable menuData = data;
  115. reForm.DataSource = menuData;
  116. reForm.MSelectFlag = false;
  117. reForm.RowIndexWidth = 35;
  118. reForm.HideCols.Add("ID");
  119. reForm.FormWidth = 500;
  120. reForm.FormHeight = 500;
  121. //reForm.FilterKey = btn.Text;
  122. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  123. if (reForm.ShowDialog() == DialogResult.OK)
  124. {
  125. DataTable retData = reForm.ReturnData;
  126. foreach (DataRow dr in retData.Rows)
  127. {
  128. txtROUTECODE.Text = dr["途程代码"].ToString();
  129. }
  130. }
  131. }
  132. #endregion
  133. #region 工序代码按钮
  134. private void txtOPCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  135. {
  136. DataTable dt = ICSECGBLL.SearchPOInfoList(txtROUTECODE.Text, AppConfig.AppConnectString);
  137. FormDataRefer reForm = new FormDataRefer();
  138. reForm.FormTitle = "工序";
  139. reForm.DataSource = dt;
  140. reForm.MSelectFlag = false;
  141. reForm.RowIndexWidth = 35;
  142. reForm.HideCols.Add("guid");
  143. reForm.FormWidth = 500;
  144. reForm.FormHeight = 500;
  145. if (reForm.ShowDialog() == DialogResult.OK)
  146. {
  147. DataTable retData = reForm.ReturnData;
  148. foreach (DataRow dr in retData.Rows)
  149. {
  150. FormICSOPUIModel type = new FormICSOPUIModel();
  151. type.OPCODE = dr["工序代码"].ToString();
  152. type.OPDESC = dr["工序"].ToString();
  153. txtOPCODE.Text = type.OPCODE;
  154. txtOPCODE.Tag = type;
  155. break;
  156. }
  157. }
  158. }
  159. #endregion
  160. #region 资源按钮
  161. private void txtRESCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  162. {
  163. DataTable dt = ICSECGBLL.SearchRESInfoList(txtOPCODE.Text, AppConfig.AppConnectString);
  164. FormDataRefer reForm = new FormDataRefer();
  165. reForm.FormTitle = "资源";
  166. reForm.DataSource = dt;
  167. reForm.MSelectFlag = false;
  168. reForm.RowIndexWidth = 35;
  169. reForm.HideCols.Add("guid");
  170. reForm.FormWidth = 500;
  171. reForm.FormHeight = 500;
  172. if (reForm.ShowDialog() == DialogResult.OK)
  173. {
  174. DataTable retData = reForm.ReturnData;
  175. foreach (DataRow dr in retData.Rows)
  176. {
  177. FormICSRESUIModel type = new FormICSRESUIModel();
  178. type.RESCODE = dr["资源代码"].ToString();
  179. type.RESDESC = dr["资源描述"].ToString();
  180. txtRESCODE.Text = type.RESCODE;
  181. txtRESCODE.Tag = type;
  182. break;
  183. }
  184. }
  185. }
  186. #endregion
  187. private void SearchEcgInfo(string id)
  188. {
  189. ecgUIModel = ICSECGBLL.SearchEcgInfoByCode(id, AppConfig.AppConnectString);
  190. //txtITEMCODE.Tag = shiftUIModel.inventory as FormICSINVENTORYUIModel;
  191. //txtITEMCODE.Text = shiftUIModel.inventory.INVCODE;
  192. //txtOPCODE.Tag = shiftUIModel.op as FormICSOPUIModel;
  193. //txtOPCODE.Text = shiftUIModel.op.OPCODE;
  194. //txtCKGROUP.Tag = shiftUIModel.oqcckgroup as FormICSOQCCKGROUPUIModel;
  195. //txtCKGROUP.Text = shiftUIModel.oqcckgroup.CKGROUP;
  196. guid = ecgUIModel.ID;
  197. txtECGCODE.Text = ecgUIModel.ECGCODE;
  198. txtECGDESC.Text = ecgUIModel.ECGDESC;
  199. txtROUTECODE.Text = ecgUIModel.route.ROUTECODE;
  200. txtOPCODE.Text = ecgUIModel.op.OPCODE;
  201. txtRESCODE.Text = ecgUIModel.res.RESCODE;
  202. txtMUSERName.Text = AppConfig.UserName;
  203. txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString();
  204. }
  205. #region 关闭
  206. private void btnCancle_Click(object sender, EventArgs e)
  207. {
  208. this.Close();
  209. this.DialogResult = DialogResult.Cancel;
  210. }
  211. private void btnClose_Click(object sender, EventArgs e)
  212. {
  213. this.Close();
  214. this.DialogResult = DialogResult.Cancel;
  215. }
  216. #endregion
  217. #region 新增 修改
  218. private void btnOK_Click(object sender, EventArgs e)
  219. {
  220. //if (Flag == 0)
  221. //{
  222. // bool b = ICSMODELOP2CKGROUPBLL.IsIncludingItemOP(txtITEMCODE.Text.Trim(),txtOPCODE.Text.Trim(), AppConfig.AppConnectString);
  223. // if (!b)
  224. // {
  225. // ICSBaseSimpleCode.AppshowMessageBox("该产品的此工序已经存在检验类型");
  226. // return;
  227. // }
  228. //}
  229. //bool a = ICSShiftBLL.IsIncludingInShiftSeq(int.Parse(txtSHIFTSEQ.Text.Trim()), ICSShiftBLL.SelectShiftTypeId(txtSHIFTTYPECODE.Text).Rows[0][0].ToString());
  230. //if (!a)
  231. //{
  232. // ICSBaseSimpleCode.AppshowMessageBox("班次次序在班制中已经存在");
  233. // return;
  234. //}
  235. if (txtECGCODE.Text.Trim() == "")
  236. {
  237. ICSBaseSimpleCode.AppshowMessageBox("不良代码组不能为空!");
  238. return;
  239. }
  240. if (txtECGDESC.Text.Trim() == "")
  241. {
  242. ICSBaseSimpleCode.AppshowMessageBox("不良代码组描述不能为空!");
  243. return;
  244. }
  245. //if (txtCKGROUP.Text.Trim() == "")
  246. //{
  247. // ICSBaseSimpleCode.AppshowMessageBox("检验类型不能为空!");
  248. // return;
  249. //}
  250. //if (txtSEQ.Text == null)
  251. //{
  252. // ICSBaseSimpleCode.AppshowMessageBox("次序不可以为空!");
  253. // return;
  254. //}
  255. FormICSECGUIModel shiftInfo = new FormICSECGUIModel();
  256. //DataTable dt = ICSSoft.Frame.Data.BLL.ICSMODELOP2CKGROUPBLL.SelectItemId(txtITEMCODE.Text,AppConfig.WorkPointCode);
  257. //if (dt != null && dt.Rows.Count > 0)
  258. //{
  259. // shiftInfo.ITEMID = dt.Rows[0][0].ToString();
  260. //}
  261. //DataTable dt1 = ICSSoft.Frame.Data.BLL.ICSMODELOP2CKGROUPBLL.SelectOpId(txtOPCODE.Text, AppConfig.WorkPointCode);
  262. //if (dt1 != null && dt1.Rows.Count > 0)
  263. //{
  264. // shiftInfo.OPID = dt1.Rows[0][0].ToString();
  265. //}
  266. //DataTable dt2 = ICSSoft.Frame.Data.BLL.ICSMODELOP2CKGROUPBLL.SelectCkgroupId(txtCKGROUP.Text, AppConfig.WorkPointCode);
  267. //if (dt2 != null && dt2.Rows.Count > 0)
  268. //{
  269. // shiftInfo.CKGROUPID = dt2.Rows[0][0].ToString();
  270. //}
  271. shiftInfo.ID = guid;
  272. shiftInfo.ECGCODE = txtECGCODE.Text.Trim();
  273. shiftInfo.ECGDESC = txtECGDESC.Text.Trim();
  274. shiftInfo.ROUTECODE = txtROUTECODE.Text.Trim();
  275. shiftInfo.OPCODE = txtOPCODE.Text.Trim();
  276. shiftInfo.RESCODE = txtRESCODE.Text.Trim();
  277. shiftInfo.MUSER = AppConfig.UserId;
  278. shiftInfo.MUSERName = AppConfig.UserName;
  279. shiftInfo.MTIME = System.DateTime.Parse(txtMTIME.Text);
  280. shiftInfo.WorkPoint = AppConfig.WorkPointCode;
  281. shiftInfo.EATTRIBUTE1 = null;
  282. try
  283. {
  284. ICSECGBLL.Add(shiftInfo, AppConfig.AppConnectString);
  285. this.Close();
  286. ICSBaseSimpleCode.AppshowMessageBox("操作成功");
  287. }
  288. catch (Exception ex)
  289. {
  290. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  291. }
  292. }
  293. #endregion
  294. }
  295. }