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

367 lines
14 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 FormICSMODELOP2CKGROUPAdd : DevExpress.XtraEditors.XtraForm
  23. {
  24. FormICSMODELOP2CKGROUPUIModel shiftUIModel;
  25. int Flag;
  26. /// <summary>
  27. /// add new
  28. /// </summary>
  29. public FormICSMODELOP2CKGROUPAdd()
  30. {
  31. InitializeComponent();
  32. chargeFormState("Add");
  33. Flag = 0;
  34. }
  35. /// <summary>
  36. /// edit
  37. /// </summary>
  38. /// <param name="cPersonCode"></param>
  39. public FormICSMODELOP2CKGROUPAdd(string ITEMCODE,string OPCODE,string CKGROUP)
  40. {
  41. InitializeComponent();
  42. chargeFormState("Edit");
  43. SearchShiftInfo(ITEMCODE,OPCODE,CKGROUP);
  44. Flag = 1;
  45. }
  46. private void chargeFormState(string state)
  47. {
  48. switch (state)
  49. {
  50. case "Add":
  51. txtITEMCODE.Properties.ReadOnly = false;
  52. txtOPCODE.Properties.ReadOnly = false;
  53. txtCKGROUP.Properties.ReadOnly = false;
  54. txtMUSERName.Text = AppConfig.UserName;
  55. txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString();
  56. txtMUSERName.Properties.ReadOnly = true;
  57. txtMTIME.Properties.ReadOnly = true;
  58. break;
  59. case "Edit":
  60. txtITEMCODE.Properties.ReadOnly = true;
  61. txtOPCODE.Properties.ReadOnly = true;
  62. txtCKGROUP.Properties.ReadOnly = true;
  63. txtITEMCODE.Properties.Buttons[0].Visible = false;
  64. txtOPCODE.Properties.Buttons[0].Visible = false;
  65. txtCKGROUP.Properties.Buttons[0].Visible = 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 txtITEMCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  103. {
  104. ButtonEdit btn = (ButtonEdit)sender;
  105. string sql = "select distinct INVCODE as [存货编码], INVNAME as [存货名称] from ICSINVENTORY with(nolock) WHERE INVTYPE='成品'or INVTYPE='半成品'";
  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. txtITEMCODE.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 = ICSMODELOP2CKGROUPBLL.SearchPOInfoList(txtITEMCODE.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 txtCKGROUP_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  162. {
  163. ButtonEdit btn = (ButtonEdit)sender;
  164. string sql = "select distinct CKGROUP as [检验类型], CKGROUPDESC as [检验类型描述] from ICSOQCCKGROUP with(nolock) WHERE 1=1";
  165. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  166. //if (obj == null)
  167. //{
  168. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  169. //}
  170. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  171. FormDataRefer reForm = new FormDataRefer();
  172. reForm.FormTitle = "检验类型信息";
  173. DataTable menuData = data;
  174. reForm.DataSource = menuData;
  175. reForm.MSelectFlag = false;
  176. reForm.RowIndexWidth = 35;
  177. reForm.HideCols.Add("ID");
  178. reForm.FormWidth = 500;
  179. reForm.FormHeight = 500;
  180. //reForm.FilterKey = btn.Text;
  181. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  182. if (reForm.ShowDialog() == DialogResult.OK)
  183. {
  184. DataTable retData = reForm.ReturnData;
  185. foreach (DataRow dr in retData.Rows)
  186. {
  187. txtCKGROUP.Text = dr["检验类型"].ToString();
  188. }
  189. }
  190. }
  191. #endregion
  192. private void SearchShiftInfo(string ITEMCODE,string OPCODE,string CKGROUP)
  193. {
  194. shiftUIModel = ICSMODELOP2CKGROUPBLL.SearchCkgroupInfoByCode(ITEMCODE,OPCODE,CKGROUP, AppConfig.AppConnectString);
  195. //txtITEMCODE.Tag = shiftUIModel.inventory as FormICSINVENTORYUIModel;
  196. //txtITEMCODE.Text = shiftUIModel.inventory.INVCODE;
  197. //txtOPCODE.Tag = shiftUIModel.op as FormICSOPUIModel;
  198. //txtOPCODE.Text = shiftUIModel.op.OPCODE;
  199. //txtCKGROUP.Tag = shiftUIModel.oqcckgroup as FormICSOQCCKGROUPUIModel;
  200. //txtCKGROUP.Text = shiftUIModel.oqcckgroup.CKGROUP;
  201. txtITEMCODE.Text = shiftUIModel.inventory.INVCODE;
  202. txtOPCODE.Text = shiftUIModel.op.OPCODE;
  203. txtCKGROUP.Text = shiftUIModel.oqcckgroup.CKGROUP;
  204. txtSEQ.Text = shiftUIModel.SEQ.ToString();
  205. txtMUSERName.Text = AppConfig.UserName;
  206. txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString();
  207. }
  208. #region 关闭
  209. private void btnCancle_Click(object sender, EventArgs e)
  210. {
  211. this.Close();
  212. this.DialogResult = DialogResult.Cancel;
  213. }
  214. private void btnClose_Click(object sender, EventArgs e)
  215. {
  216. this.Close();
  217. this.DialogResult = DialogResult.Cancel;
  218. }
  219. #endregion
  220. #region 新增 修改
  221. private void btnOK_Click(object sender, EventArgs e)
  222. {
  223. if (Flag == 0)
  224. {
  225. bool b = ICSMODELOP2CKGROUPBLL.IsIncludingItemOP(txtITEMCODE.Text.Trim(),txtOPCODE.Text.Trim(), AppConfig.AppConnectString);
  226. if (!b)
  227. {
  228. ICSBaseSimpleCode.AppshowMessageBox("该产品的此工序已经存在检验类型");
  229. return;
  230. }
  231. }
  232. //bool a = ICSShiftBLL.IsIncludingInShiftSeq(int.Parse(txtSHIFTSEQ.Text.Trim()), ICSShiftBLL.SelectShiftTypeId(txtSHIFTTYPECODE.Text).Rows[0][0].ToString());
  233. //if (!a)
  234. //{
  235. // ICSBaseSimpleCode.AppshowMessageBox("班次次序在班制中已经存在");
  236. // return;
  237. //}
  238. if (txtITEMCODE.Text.Trim() == "")
  239. {
  240. ICSBaseSimpleCode.AppshowMessageBox("存货编码不能为空!");
  241. return;
  242. }
  243. if (txtOPCODE.Text.Trim() == "")
  244. {
  245. ICSBaseSimpleCode.AppshowMessageBox("工序代码不能为空!");
  246. return;
  247. }
  248. if (txtCKGROUP.Text.Trim() == "")
  249. {
  250. ICSBaseSimpleCode.AppshowMessageBox("检验类型不能为空!");
  251. return;
  252. }
  253. if (txtSEQ.Text == null)
  254. {
  255. ICSBaseSimpleCode.AppshowMessageBox("次序不可以为空!");
  256. return;
  257. }
  258. FormICSMODELOP2CKGROUPUIModel shiftInfo = new FormICSMODELOP2CKGROUPUIModel();
  259. DataTable dt = ICSSoft.Frame.Data.BLL.ICSMODELOP2CKGROUPBLL.SelectItemId(txtITEMCODE.Text,AppConfig.WorkPointCode);
  260. if (dt != null && dt.Rows.Count > 0)
  261. {
  262. shiftInfo.ITEMID = dt.Rows[0][0].ToString();
  263. }
  264. DataTable dt1 = ICSSoft.Frame.Data.BLL.ICSMODELOP2CKGROUPBLL.SelectOpId(txtOPCODE.Text, AppConfig.WorkPointCode);
  265. if (dt1 != null && dt1.Rows.Count > 0)
  266. {
  267. shiftInfo.OPID = dt1.Rows[0][0].ToString();
  268. }
  269. DataTable dt2 = ICSSoft.Frame.Data.BLL.ICSMODELOP2CKGROUPBLL.SelectCkgroupId(txtCKGROUP.Text, AppConfig.WorkPointCode);
  270. if (dt2 != null && dt2.Rows.Count > 0)
  271. {
  272. shiftInfo.CKGROUPID = dt2.Rows[0][0].ToString();
  273. }
  274. shiftInfo.ITEMCODE = txtITEMCODE.Text.Trim();
  275. shiftInfo.OPCODE = txtOPCODE.Text.Trim();
  276. shiftInfo.CKGROUP = txtCKGROUP.Text.Trim();
  277. shiftInfo.SEQ = int.Parse(txtSEQ.Text.Trim());
  278. shiftInfo.MUSER = AppConfig.UserId;
  279. shiftInfo.MUSERName = AppConfig.UserName;
  280. shiftInfo.MTIME = System.DateTime.Parse(txtMTIME.Text);
  281. shiftInfo.WorkPoint = AppConfig.WorkPointCode;
  282. shiftInfo.EATTRIBUTE1 = null;
  283. try
  284. {
  285. ICSMODELOP2CKGROUPBLL.Add(shiftInfo, AppConfig.AppConnectString);
  286. this.Close();
  287. ICSBaseSimpleCode.AppshowMessageBox("操作成功");
  288. }
  289. catch (Exception ex)
  290. {
  291. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  292. }
  293. }
  294. #endregion
  295. //private void FormICSShiftAdd_Load()
  296. //{
  297. // DataTable dt = new DataTable();
  298. // dt = ICSShiftBLL.GetShiftCode();
  299. // string str = dt.Rows[0]["SHIFTCODE"].ToString();
  300. // if (str == "1101000001")
  301. // {
  302. // txtSHIFTCODE.Text = (int.Parse(str) + 1).ToString();
  303. // }
  304. // else
  305. // {
  306. // str = "1101000001";
  307. // }
  308. }
  309. }