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

1270 lines
60 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 System.Data.SqlClient;
  10. using ICSSoft.Frame.Data.BLL;
  11. using ICSSoft.Base.Language.Tool;
  12. using ICSSoft.Base.UserControl.MessageControl;
  13. using ICSSoft.Base.Report.Filter;
  14. using ICSSoft.Base.Config.DBHelper;
  15. using ICSSoft.Base.UserControl.FormControl;
  16. using ICSSoft.Base.ReferForm.AppReferForm;
  17. using ICSSoft.Base.Lable.PrintTool;
  18. using ICSSoft.Base.Config.AppConfig;
  19. using ICSSoft.Base.Report.GridReport;
  20. using ICSSoft.Frame.APP.Entity;
  21. using ICSSoft.Frame.APP;
  22. using ICSSoft.Frame.Data.Entity;
  23. using System.Linq;
  24. namespace ICSSoft.Frame.APP
  25. {
  26. public partial class FormICSEQPSTPAdd : DevExpress.XtraEditors.XtraForm
  27. {
  28. FormICSEQPSTPUIModelNew EQPSTPUIModel;
  29. int flag = 0;
  30. string eqpstpid;
  31. bool first = true;
  32. public FormICSEQPSTPAdd()
  33. {
  34. InitializeComponent();
  35. init();
  36. chargeFormState("Add");
  37. flag = 0;
  38. eqpstpid = AppConfig.GetGuid();
  39. cboEQPSetting.SelectedIndex = 0;
  40. tabControl1.ItemSize = new Size(0, 1);
  41. }
  42. public FormICSEQPSTPAdd(string id)
  43. {
  44. InitializeComponent();
  45. init();
  46. chargeFormState("Edit");
  47. SearchTypeInfo(id);
  48. flag = 1;
  49. eqpstpid = id;
  50. tabControl1.ItemSize = new Size(0, 1);
  51. }
  52. private void chargeFormState(string state)
  53. {
  54. switch (state)
  55. {
  56. case "Add":
  57. txtMUSERName.Text = AppConfig.UserName;
  58. txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss").ToString();
  59. txtMUSERName.Properties.ReadOnly = true;
  60. txtMTIME.Properties.ReadOnly = true;
  61. break;
  62. case "Edit":
  63. txtItemCode.Properties.Buttons[0].Visible = false;
  64. txtItemCode.Enabled = false;
  65. txtROUTECODE.Properties.Buttons[0].Visible = false;
  66. txtROUTECODE.Enabled = false;
  67. txtOPCODE.Properties.Buttons[0].Visible = false;
  68. txtOPCODE.Enabled = false;
  69. //txtEQPCODE.Properties.Buttons[0].Visible = false;
  70. //txtEQPCODE.Enabled = false;
  71. //txtEQPTypeCode.Properties.Buttons[0].Visible = false;
  72. //txtEQPTypeCode.Enabled = false;
  73. txtMUSERName.Properties.ReadOnly = true;
  74. txtMTIME.Properties.ReadOnly = true;
  75. break;
  76. }
  77. }
  78. private void SearchTypeInfo(string id)
  79. {
  80. DataTable dt = ICSEQPSTPBLL.searchInfoByID(id, AppConfig.AppConnectString);
  81. if (dt != null && dt.Rows.Count > 0)
  82. {
  83. eqpstpid = dt.Rows[0]["ID"].ToString();
  84. //txtItemCode.Text = dt.Rows[0]["ITEMCODE"].ToString();
  85. //cboRouteCode.Text = dt.Rows[0]["EATTRIBUTE1"].ToString();
  86. txtItemCode.Text = dt.Rows[0]["ITEMCODE"].ToString();
  87. txtItemName.Text = dt.Rows[0]["ItemName"].ToString();
  88. txtROUTECODE.Text = dt.Rows[0]["ROUTECODE"].ToString();
  89. txtRouteName.Text = dt.Rows[0]["ROUTECODE"].ToString();
  90. txtROUTEMEMO.Text = dt.Rows[0]["ROUTEMEMO"].ToString();
  91. txtOPCODE.Text = dt.Rows[0]["OPCODE"].ToString();
  92. txtOPDESC.Text = dt.Rows[0]["OPDESC"].ToString();
  93. //txtEQPTypeCode.Text = dt.Rows[0]["EQPTypeCode"].ToString();
  94. //txtEQPTypeName.Text = dt.Rows[0]["EQPTypeName"].ToString();
  95. //JiaGongTime,JianYanTime,TiaoJiTime,JiaZhuangTime
  96. //txtSTIME.Text = dt.Rows[0]["STIME"].ToString();
  97. //txtRTIME.Text = dt.Rows[0]["RTIME"].ToString();
  98. txtJiagongTime.Text = dt.Rows[0]["JiaGongTime"].ToString();
  99. txtJiazhuangTime.Text = dt.Rows[0]["JiaZhuangTime"].ToString();
  100. txtJianyanTime.Text = dt.Rows[0]["JianYanTime"].ToString();
  101. txtTiaojiTime.Text = dt.Rows[0]["TiaoJiTime"].ToString();
  102. lookupOPLVL.Text = dt.Rows[0]["OPLVL"].ToString();
  103. cboIsRef.Checked = dt.Rows[0]["ISREF"].ToString() == "是" ? true : false; ;
  104. txtMUSERName.Text = AppConfig.UserName;
  105. txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss").ToString();
  106. lookupOPLVL.Text = dt.Rows[0]["OPLVL"].ToString();
  107. if (dt.Rows[0]["EQPTypeCode"].ToString() == "固定设备")
  108. {
  109. cboEQPSetting.SelectedIndex = 0;
  110. lookupClass.Text = dt.Rows[0]["cClass"].ToString();
  111. lookupHandles.Text = dt.Rows[0]["cHandles"].ToString();
  112. lookupAxis.Text = dt.Rows[0]["cAxis"].ToString();
  113. lookupToolMagazine.Text = dt.Rows[0]["cToolMagazine"].ToString();
  114. lookupMachinableProfiles.Text = dt.Rows[0]["cMachinableProfiles"].ToString();
  115. lookupAccuracy.Text = dt.Rows[0]["cAccuracy"].ToString();
  116. }
  117. else if (dt.Rows[0]["EQPTypeCode"].ToString() == "加工中心" || dt.Rows[0]["EQPTypeCode"].ToString() == "设备类型")
  118. {
  119. cboEQPSetting.SelectedIndex = 1;
  120. txtEQPCODE.Text = dt.Rows[0]["EQPCODE"].ToString();
  121. }
  122. else if (dt.Rows[0]["EQPTypeCode"].ToString() == "车削中心") {
  123. cboEQPSetting.SelectedIndex =2;
  124. txtcxjd.EditValue = dt.Rows[0]["CXJD"].ToString();
  125. txtcxtype.EditValue = dt.Rows[0]["CXType"].ToString();
  126. if(!string.IsNullOrEmpty(dt.Rows[0]["CXBrand1"].ToString()))
  127. txtpp1.EditValue = dt.Rows[0]["CXBrand1"].ToString();
  128. if (!string.IsNullOrEmpty(dt.Rows[0]["CXBrand2"].ToString()))
  129. txtpp2.EditValue = dt.Rows[0]["CXBrand2"].ToString();
  130. if (!string.IsNullOrEmpty(dt.Rows[0]["CXBrand3"].ToString()))
  131. txtpp3.EditValue = dt.Rows[0]["CXBrand3"].ToString();
  132. }
  133. //txtETTRCODE.Text = dt.Rows[0]["ETTRCOde"].ToString();
  134. //txtBladeModelAndBrand.Text = dt.Rows[0]["BladeModelAndBrand"].ToString();
  135. //txtOutsourcingProperties.Text = dt.Rows[0]["OutsourcingProperties"].ToString();
  136. //txtToolingNo.Text = dt.Rows[0]["ToolingNo"].ToString();
  137. }
  138. }
  139. private string check()
  140. {
  141. string msg = "";
  142. Decimal decValue = 0m;
  143. if (txtItemCode.Text.Trim() == "")
  144. msg += "存货编码不能为空!\n";
  145. if (txtROUTECODE.Text.Trim() == "")
  146. {
  147. msg += "工艺不能为空!\n";
  148. }
  149. if (txtOPCODE.Text.Trim() == "")
  150. msg += "工序代码不能为空!\n";
  151. //if (txtEQPTypeCode.Text.Trim() == "")
  152. // msg += "设备类型不能为空!\n";
  153. //if (txtSTIME.Text.Trim() == "")
  154. // msg += "标准工时不能为空!\n";
  155. //else
  156. //{
  157. // if (!Decimal.TryParse(txtSTIME.Text.Trim(), out decValue))
  158. // {
  159. // msg += "标准工时格式不正确!\n";
  160. // }
  161. //}
  162. //if (txtRTIME.Text.Trim() == "")
  163. // msg += "准备工时不能为空!\n";
  164. //else
  165. //{
  166. // if (!Decimal.TryParse(txtRTIME.Text.Trim(), out decValue))
  167. // {
  168. // msg += "准备工时格式不正确!\n";
  169. // }
  170. //}
  171. //if (txtJianyanTime.Text == "0")
  172. //{
  173. // msg += "请填写工时,且不可为 0 !\n";
  174. //}
  175. //if (flag == 0)
  176. //{
  177. // //if (!ICSEQPSTPBLL.IsIncluding(txtItemCode.Text.Trim(), txtOPCODE.Text.Trim(), txtEQPCODE.Text.Trim(), AppConfig.AppConnectString))
  178. // if (!ICSEQPSTPBLL.IsIncluding(txtItemCode.Text.Trim(), txtOPCODE.Text.Trim(), txtEQPTypeCode.Text.Trim(), AppConfig.AppConnectString))
  179. // msg += "该产品工序设备类型内对应的标准工时信息已存在!\n";
  180. //}
  181. //if (!cboIsRef.Checked)
  182. //{
  183. // msg += "请选择是否为默认标准工时!\n";
  184. //}
  185. return msg;
  186. }
  187. private void btnOK_Click(object sender, EventArgs e)
  188. {
  189. string EQPTypeCode = "";
  190. string eqpCode = "";
  191. string eqpName = "";
  192. string cClass = "";
  193. string cHandles = "";
  194. string cAxis = "";
  195. string cToolMagazine = "";
  196. string cMachinableProfiles = "";
  197. string cAccuracy = "";
  198. decimal? WTIME = 0;
  199. string OPLVL = "";
  200. string cxpp1 = "";
  201. string cxpp2 = "";
  202. string cxpp3 = "";
  203. string cxtype = "";
  204. string cxjd = "";
  205. try
  206. {
  207. string msg = check();
  208. if (!string.IsNullOrEmpty(msg))
  209. {
  210. ICSBaseSimpleCode.AppshowMessageBox(msg);
  211. return;
  212. }
  213. if (!chkIsWW.Checked)
  214. {
  215. if (cboEQPSetting.SelectedIndex == 0)
  216. {
  217. EQPTypeCode = "加工中心";
  218. cClass = lookupClass.Text;
  219. cHandles = lookupHandles.Text;
  220. cAxis = lookupAxis.Text;
  221. cToolMagazine = lookupToolMagazine.Text;
  222. cMachinableProfiles = lookupMachinableProfiles.Text;
  223. cAccuracy = lookupAccuracy.Text;
  224. if (cClass == "")
  225. {
  226. ICSBaseSimpleCode.AppshowMessageBox("类别不能为空!");
  227. return;
  228. }
  229. if (cHandles == "")
  230. {
  231. ICSBaseSimpleCode.AppshowMessageBox("刀柄不能为空!");
  232. return;
  233. }
  234. if (cAxis == "")
  235. {
  236. ICSBaseSimpleCode.AppshowMessageBox("轴数不能为空!");
  237. return;
  238. }
  239. if (cToolMagazine == "")
  240. {
  241. ICSBaseSimpleCode.AppshowMessageBox("刀库不能为空!");
  242. return;
  243. }
  244. if (cMachinableProfiles == "")
  245. {
  246. ICSBaseSimpleCode.AppshowMessageBox("可加工外形不能为空!");
  247. return;
  248. }
  249. if (cAccuracy == "")
  250. {
  251. ICSBaseSimpleCode.AppshowMessageBox("精度不能为空!");
  252. return;
  253. }
  254. }
  255. else if (cboEQPSetting.SelectedIndex == 1)
  256. {
  257. EQPTypeCode = "固定设备";
  258. eqpCode = txtEQPCODE.Text;
  259. eqpName = txtEQPNAME.Text;
  260. if (eqpCode == "" || eqpName == "")
  261. {
  262. ICSBaseSimpleCode.AppshowMessageBox("请选择设备");
  263. return;
  264. }
  265. }
  266. else if(cboEQPSetting.SelectedIndex ==2)
  267. {
  268. EQPTypeCode = "车削中心";
  269. if (string.IsNullOrEmpty(txtcxtype.Text)) {
  270. ICSBaseSimpleCode.AppshowMessageBox("车削类型不能为空");
  271. return;
  272. }
  273. if (string.IsNullOrEmpty(txtcxjd.Text))
  274. {
  275. ICSBaseSimpleCode.AppshowMessageBox("车削精度不能为空");
  276. return;
  277. }
  278. List<string> pp = new List<string>();
  279. if (!string.IsNullOrEmpty(txtpp1.Text))
  280. {
  281. pp.Add(txtpp1.Text);
  282. cxpp1 = txtpp1.Text;
  283. }
  284. else {
  285. cxpp1 = "00";
  286. }
  287. if (!string.IsNullOrEmpty(txtpp2.Text))
  288. {
  289. pp.Add(txtpp2.Text);
  290. cxpp2 = txtpp2.Text;
  291. }
  292. else
  293. cxpp2 = "00";
  294. if (!string.IsNullOrEmpty(txtpp3.Text))
  295. {
  296. pp.Add(txtpp3.Text);
  297. cxpp3 = txtpp3.Text;
  298. }
  299. else
  300. cxpp3 = "00";
  301. IEnumerable<IGrouping<string,string>> count=pp.GroupBy(a => a);
  302. foreach (var B in count) {
  303. if (B.Count() > 1) {
  304. ICSBaseSimpleCode.AppshowMessageBox("存在重复车床品牌,请确认!");
  305. return;
  306. }
  307. }
  308. cxjd = txtcxjd.Text;
  309. cxtype = txtcxtype.Text;
  310. }
  311. OPLVL = lookupOPLVL.Text;
  312. if (OPLVL == "")
  313. {
  314. ICSBaseSimpleCode.AppshowMessageBox("工序等级不能为空!");
  315. return;
  316. }
  317. WTIME = 3;
  318. }
  319. else
  320. {
  321. EQPTypeCode = "委外";
  322. string WWTIME = txtWWTIME.Text;
  323. if (WWTIME == "" || WWTIME == "0")
  324. {
  325. throw new Exception("委外工序时,委外工时必须填写");
  326. }
  327. WTIME = Convert.ToDecimal(WWTIME);
  328. if (WTIME <= 0)
  329. {
  330. throw new Exception("委外工时必须大于 0");
  331. }
  332. OPLVL = null;
  333. }
  334. ICSEQPSTP eqpstp = new ICSEQPSTP();
  335. eqpstp.ID = eqpstpid;
  336. eqpstp.ITEMCODE = txtItemCode.Text;
  337. eqpstp.OPCODE = txtOPCODE.Text;
  338. eqpstp.EQPCODE = eqpCode;
  339. eqpstp.ETTRCODE = txtETTRCODE.Text;
  340. eqpstp.ISREF = cboIsRef.Checked ? "是" : "否";
  341. eqpstp.JiaGongTime =
  342. eqpstp.STIME = Convert.ToDecimal(txtJiagongTime.Text.Equals("") ? "0" : txtJiagongTime.Text);
  343. eqpstp.TiaoJiTime =
  344. eqpstp.RTIME = Convert.ToDecimal(txtTiaojiTime.Text.Equals("") ? "0" : txtTiaojiTime.Text);
  345. eqpstp.JiaZhuangTime = Convert.ToDecimal(txtJiazhuangTime.Text.Equals("") ? "0" : txtJiazhuangTime.Text);
  346. eqpstp.JianYanTime = Convert.ToDecimal(txtJianyanTime.Text.Equals("") ? "0" : txtJianyanTime.Text);
  347. eqpstp.MUSER = AppConfig.UserCode;
  348. eqpstp.MUSERName = AppConfig.UserName;
  349. eqpstp.MTIME = DateTime.Now;
  350. eqpstp.WorkPoint = AppConfig.WorkPointCode;
  351. eqpstp.EQPTypeCode = EQPTypeCode;//此处不在存设备类型,设备类型是6大维度决定
  352. eqpstp.cClass = cClass;
  353. eqpstp.cHandles = cHandles;
  354. eqpstp.cAxis = cAxis;
  355. eqpstp.cToolMagazine = cToolMagazine;
  356. eqpstp.cMachinableProfiles = cMachinableProfiles;
  357. eqpstp.cAccuracy = cAccuracy;
  358. eqpstp.OPLVL = OPLVL;
  359. eqpstp.WTIME = WTIME;
  360. eqpstp.EATTRIBUTE1 = txtROUTECODE.Text;
  361. eqpstp.ToolingNo = txtROUTEMEMO.Text;
  362. eqpstp.CXBrand1 = cxpp1;
  363. eqpstp.CXBrand2 = cxpp2;
  364. eqpstp.CXBrand3 = cxpp3;
  365. eqpstp.CXJD = cxjd;
  366. eqpstp.CXType = cxtype;
  367. ////20180626新增
  368. //eqpstp.BladeModelAndBrand = this.txtBladeModelAndBrand.Text.Trim();
  369. //eqpstp.OutsourcingProperties = this.txtOutsourcingProperties.Text.Trim();
  370. //eqpstp.ToolingNo = this.txtToolingNo.Text.Trim();
  371. ICSEQPSTPBLL.Add(eqpstp, AppConfig.AppConnectString);
  372. //this.Close();
  373. //this.DialogResult = DialogResult.Yes;
  374. first = false;
  375. if (flag == 0)
  376. {
  377. ICSBaseSimpleCode.AppshowMessageBox("增加成功");
  378. txtItemCode.Properties.Buttons[0].Visible = false;
  379. txtItemCode.Enabled = false;
  380. txtROUTECODE.Properties.Buttons[0].Visible = false;
  381. txtROUTECODE.Enabled = false;
  382. eqpstpid = AppConfig.GetGuid();
  383. txtROUTEMEMO.Text = "";
  384. txtOPCODE.Text = "";
  385. txtOPDESC.Text = "";
  386. //cboEQPSetting.SelectedIndex = 0;
  387. lookupClass.Text = lookupAxis.Text = lookupAccuracy.Text = lookupHandles.Text = lookupToolMagazine.Text = "";
  388. txtJiagongTime.Text = txtJiazhuangTime.Text = "0";
  389. if (cboEQPSetting.SelectedIndex == 1)
  390. {
  391. cboTiaojiPRT.SelectedIndex = cboTiaojiBaseTime.SelectedIndex = cboJianyanPRT.SelectedIndex = -1;
  392. txtJiagongTime.Text = txtJiazhuangTime.Text = txtJianyanTime.Text = txtTiaojiTime.Text = "0";
  393. lookupMachinableProfiles.Text = "";
  394. }
  395. lookupOPLVL.Text = "";
  396. chkIsWW.Checked = false;
  397. cboIsRef.Checked = true;
  398. }
  399. else if (flag == 1)
  400. {
  401. ICSBaseSimpleCode.AppshowMessageBox("修改成功");
  402. this.Close();
  403. this.DialogResult = DialogResult.Yes;
  404. }
  405. }
  406. catch (Exception ex)
  407. {
  408. MessageBox.Show(ex.Message);
  409. }
  410. }
  411. #region 关闭
  412. private void btnCancle_Click(object sender, EventArgs e)
  413. {
  414. this.Close();
  415. //this.DialogResult = DialogResult.Cancel;
  416. }
  417. private void btnClose_Click(object sender, EventArgs e)
  418. {
  419. this.Close();
  420. //this.DialogResult = DialogResult.Cancel;
  421. }
  422. #endregion
  423. #region 存货编码按钮
  424. // private void txtItemCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  425. // {
  426. // ButtonEdit btn = (ButtonEdit)sender;
  427. // string sql = "select distinct guid as 产品ID,ItemCode as 存货编码,ItemName as 存货名称 from dbo.Base_Inventory with(nolock) WHERE 1=1";
  428. // //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  429. // //if (obj == null)
  430. // //{
  431. // // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  432. // //}
  433. // DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  434. // FormDataRefer reForm = new FormDataRefer();
  435. // reForm.FormTitle = "产品信息";
  436. // DataTable menuData = data;
  437. // reForm.DataSource = menuData;
  438. // reForm.MSelectFlag = false;
  439. // reForm.RowIndexWidth = 35;
  440. // reForm.HideCols.Add("产品ID");
  441. // reForm.FormWidth = 500;
  442. // reForm.FormHeight = 500;
  443. // //reForm.FilterKey = btn.Text;
  444. // //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  445. // if (reForm.ShowDialog() == DialogResult.OK)
  446. // {
  447. // DataTable retData = reForm.ReturnData;
  448. // foreach (DataRow dr in retData.Rows)
  449. // {
  450. // txtItemCode.Text = dr["存货编码"].ToString();
  451. // //itemid = dr["产品ID"].ToString();
  452. // txtItemName.Text = dr["存货名称"].ToString();
  453. // }
  454. // }
  455. // }
  456. #endregion
  457. #region 工序代码按钮
  458. // private void txtOPCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  459. // {
  460. // ButtonEdit btn = (ButtonEdit)sender;
  461. // string sql = "";
  462. // sql = @"select distinct a.OPID as [工序ID],
  463. // a.OPCODE as [工序代码],
  464. // b.OPDESC as [工序]
  465. // from ICSITEMROUTE2OP a
  466. // left join ICSOP b on a.OPCODE=b.OPCODE
  467. //where a.ITEMCODE='" + gluItemCode.Text + "' and 1=1";
  468. // //where a.ITEMCODE='" + txtItemCode.Text + "' and 1=1";
  469. // DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  470. // // if (data == null || data.Rows.Count == 0)
  471. // // {
  472. // // sql = @"select distinct a.OPID as [工序ID],
  473. // // a.OPCODE as [工序代码],
  474. // // c.OPDESC as [工序]
  475. // // from ICSMODELROUTE2OP a
  476. // // left join Base_Inventory b on a.MODELCODE=b.ItemMainCategoryCode
  477. // // left join ICSOP c on a.OPCODE=c.OPCODE
  478. // //where b.ITEMCODE='" + gluItemCode.Text + "' and 1=1";
  479. // ////where b.ITEMCODE='" + txtItemCode.Text + "' and 1=1";
  480. // // //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  481. // // //if (obj == null)
  482. // // //{
  483. // // // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  484. // // //}
  485. // // data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  486. // // }
  487. // FormDataRefer reForm = new FormDataRefer();
  488. // reForm.FormTitle = "工序信息";
  489. // DataTable menuData = data;
  490. // reForm.DataSource = menuData;
  491. // reForm.MSelectFlag = false;
  492. // reForm.RowIndexWidth = 35;
  493. // reForm.HideCols.Add("工序ID");
  494. // reForm.FormWidth = 500;
  495. // reForm.FormHeight = 500;
  496. // //reForm.FilterKey = btn.Text;
  497. // //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  498. // if (reForm.ShowDialog() == DialogResult.OK)
  499. // {
  500. // DataTable retData = reForm.ReturnData;
  501. // foreach (DataRow dr in retData.Rows)
  502. // {
  503. // txtOPCODE.Text = dr["工序代码"].ToString();
  504. // //opid = dr["工序ID"].ToString();
  505. // txtOPDESC.Text = dr["工序"].ToString();
  506. // }
  507. // }
  508. // }
  509. #endregion
  510. #region 设备编号按钮
  511. // private void txtEQPCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  512. // {
  513. // ButtonEdit btn = (ButtonEdit)sender;
  514. // string sql = @"select distinct EQPID as [设备ID], EQPCode as [设备编号],EQPName as [设备名称] from dbo.ICSEquipment
  515. // where EType='" + txtEQPTypeName.Text + "'";
  516. // DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  517. // FormDataRefer reForm = new FormDataRefer();
  518. // reForm.FormTitle = "设备信息";
  519. // DataTable menuData = data;
  520. // reForm.DataSource = menuData;
  521. // reForm.MSelectFlag = false;
  522. // reForm.RowIndexWidth = 35;
  523. // reForm.HideCols.Add("设备ID");
  524. // reForm.FormWidth = 500;
  525. // reForm.FormHeight = 500;
  526. // //reForm.FilterKey = btn.Text;
  527. // //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  528. // if (reForm.ShowDialog() == DialogResult.OK)
  529. // {
  530. // DataTable retData = reForm.ReturnData;
  531. // foreach (DataRow dr in retData.Rows)
  532. // {
  533. // txtEQPCODE.Text = dr["设备编号"].ToString();
  534. // //opid = dr["设备ID"].ToString();
  535. // txtEQPDESC.Text = dr["设备名称"].ToString();
  536. // }
  537. // }
  538. // }
  539. #endregion
  540. private void gluItemCode_EditValueChanged(object sender, EventArgs e)
  541. {
  542. var o = txtItemCode.Properties.GetRowByKeyValue(txtItemCode.EditValue);
  543. if (o is DataRowView)
  544. {
  545. DataRowView RowView = o as DataRowView;
  546. txtItemName.Text = RowView.Row["存货名称"].ToString();
  547. #region 工艺
  548. string sql = @"
  549. SELECT DISTINCT
  550. A.ROUTECODE ,
  551. B.ROUTEDESC ,
  552. C.ISREF
  553. FROM dbo.ICSITEMROUTE2OP A
  554. LEFT JOIN dbo.ICSITEM2ROUTE C ON C.ITEMCODE=A.ITEMCODE AND C.ROUTECODE=A.ROUTECODE AND C.WorkPoint=A.WorkPoint
  555. LEFT JOIN dbo.ICSROUTE B ON B.ROUTECODE=A.ROUTECODE AND B.WorkPoint=A.WorkPoint
  556. WHERE A.ITEMCODE='{0}' AND A.WorkPoint='{1}' AND C.ISREF IS NOT NULL
  557. ";
  558. sql = string.Format(sql, txtItemCode.Text, AppConfig.WorkPointCode);
  559. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  560. DataRow[] drs = data.Select("默认=1 ");
  561. txtROUTECODE.Properties.ValueMember = "工艺代码";
  562. txtROUTECODE.Properties.DisplayMember = "工艺代码";
  563. txtROUTECODE.Properties.DataSource = data;
  564. txtROUTECODE.Properties.NullText = "";//空时的值
  565. txtROUTECODE.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  566. txtROUTECODE.Properties.ValidateOnEnterKey = true;//回车确认
  567. txtROUTECODE.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  568. txtROUTECODE.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  569. //自适应宽度
  570. //txtROUTECODE.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  571. #endregion
  572. if (drs.Length > 0)
  573. {
  574. txtROUTECODE.Text = drs[0]["工艺代码"].ToString();
  575. }
  576. }
  577. }
  578. #region 初始化查询条件
  579. private void init()
  580. {
  581. #region 存货编码
  582. //string sql = "SELECT DISTINCT INVCODE AS [存货编码],INVNAME AS [存货名称] FROM ICSINVENTORY WHERE WorkPoint='{0}' ORDER BY INVCODE";
  583. string sql = @"
  584. SELECT DISTINCT A.ITEMCODE AS ,B.INVNAME AS FROM dbo.ICSITEMROUTE2OP A
  585. LEFT JOIN ICSINVENTORY B ON A.ITEMCODE=B.INVCODE AND A.WorkPoint=B.WorkPoint
  586. WHERE A.WorkPoint='{0}' ORDER BY A.ITEMCODE ASC";
  587. sql = string.Format(sql, AppConfig.WorkPointCode);
  588. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  589. txtItemCode.Properties.ValueMember = "存货编码";
  590. txtItemCode.Properties.DisplayMember = "存货编码";
  591. txtItemCode.Properties.DataSource = dt;
  592. txtItemCode.Properties.NullText = "";//空时的值
  593. txtItemCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  594. txtItemCode.Properties.ValidateOnEnterKey = true;//回车确认
  595. txtItemCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  596. txtItemCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  597. //自适应宽度
  598. txtItemCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  599. #endregion
  600. #region 调机基础值
  601. DataTable dt1 = ICSOPBLL.SearchDataByEnumKey(AppConfig.AppConnectString, "20001");
  602. if (dt1 == null || dt1.Rows.Count == 0)
  603. {
  604. throw new Exception("自定义档案20001调机工时基础值,未维护");
  605. }
  606. foreach (DataRow item in dt1.Rows)
  607. {
  608. string val = item["EnumText"].ToString();
  609. decimal d;
  610. try
  611. {
  612. d = Convert.ToDecimal(val);
  613. }
  614. catch (Exception)
  615. {
  616. throw new Exception("自定义档案20001调机工时计算比率,维护了错误的值'" + val + "'");
  617. }
  618. if (d < 0)
  619. {
  620. throw new Exception("自定义档案20001调机工时基础值,维护了错误的值'" + val + "'");
  621. }
  622. cboTiaojiBaseTime.Properties.Items.Add(d);
  623. }
  624. #endregion
  625. #region 调机计算比例
  626. DataTable dt2 = ICSOPBLL.SearchDataByEnumKey(AppConfig.AppConnectString, "20002");
  627. if (dt2 == null || dt2.Rows.Count == 0)
  628. {
  629. throw new Exception("自定义档案20002调机工时计算比率,未维护");
  630. }
  631. foreach (DataRow item in dt2.Rows)
  632. {
  633. string val = item["EnumText"].ToString();
  634. decimal d;
  635. try
  636. {
  637. d = Convert.ToDecimal(val);
  638. }
  639. catch (Exception)
  640. {
  641. throw new Exception("自定义档案20002调机工时计算比率,维护了错误的值'" + val + "'");
  642. }
  643. if (d < 0)
  644. {
  645. throw new Exception("自定义档案20002调机工时计算比率,维护了错误的值'" + val + "'");
  646. }
  647. cboTiaojiPRT.Properties.Items.Add(d);
  648. }
  649. #endregion
  650. #region 检验计算比例
  651. DataTable dt3 = ICSOPBLL.SearchDataByEnumKey(AppConfig.AppConnectString, "20003");
  652. if (dt3 == null || dt3.Rows.Count == 0)
  653. {
  654. throw new Exception("自定义档案20003检验工时计算比率,未维护");
  655. }
  656. foreach (DataRow item in dt3.Rows)
  657. {
  658. string val = item["EnumText"].ToString();
  659. decimal d;
  660. try
  661. {
  662. d = Convert.ToDecimal(val);
  663. }
  664. catch (Exception)
  665. {
  666. throw new Exception("自定义档案20003调机工时计算比率,维护了错误的值'" + val + "'");
  667. }
  668. if (d < 0)
  669. {
  670. throw new Exception("自定义档案20003检验工时计算比率,维护了错误的值'" + val + "'");
  671. }
  672. cboJianyanPRT.Properties.Items.Add(d);
  673. }
  674. #endregion
  675. #region 设备类型代码
  676. ////string sql1 = "select distinct EnumValue as [类型编码],EnumText as [设备类型] from dbo.Sys_EnumValues with(nolock) WHERE EnumKey='001' and 1=1";
  677. //string sql4 = "SELECT TypeCODE as [设备类型编码],TypeDESC as [设备类型] FROM ICSEquipmentType WHERE WorkPoint = '" + AppConfig.WorkPointCode + "' and 1=1 ";
  678. //DataTable dt4 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql4).Tables[0];
  679. ////txtEQPTypeCode.Properties.ValueMember = "类型编码";
  680. ////txtEQPTypeCode.Properties.DisplayMember = "类型编码";
  681. //txtEQPTypeCode.Properties.ValueMember = "设备类型编码";
  682. //txtEQPTypeCode.Properties.DisplayMember = "设备类型编码";
  683. //txtEQPTypeCode.Properties.DataSource = dt4;
  684. //txtEQPTypeCode.Properties.NullText = "";//空时的值
  685. //txtEQPTypeCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  686. //txtEQPTypeCode.Properties.ValidateOnEnterKey = true;//回车确认
  687. //txtEQPTypeCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  688. //txtEQPTypeCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  689. ////自适应宽度
  690. //txtEQPTypeCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  691. #endregion
  692. #region 六大维度
  693. string sql3 = @"SELECT LTRIM(RTRIM(EnumText)) as 类型 FROM Sys_EnumValues WHERE EnumKey='30001' AND LTRIM(RTRIM(EnumText))<>'' AND WorkPointCode='" + AppConfig.WorkPointCode + "' ORDER BY EnumValue";
  694. DataTable dt30001 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql3).Tables[0];
  695. lookupClass.Properties.ValueMember = "类型";
  696. lookupClass.Properties.DisplayMember = "类型";
  697. lookupClass.Properties.DataSource = dt30001;
  698. lookupClass.Properties.NullText = "";
  699. lookupClass.Properties.ImmediatePopup = true;
  700. lookupClass.Properties.ValidateOnEnterKey = true;
  701. sql3 = @"SELECT LTRIM(RTRIM(EnumText)) as 刀柄 FROM Sys_EnumValues WHERE EnumKey='30002' AND LTRIM(RTRIM(EnumText))<>'' AND WorkPointCode='" + AppConfig.WorkPointCode + "' ORDER BY EnumValue";
  702. DataTable dt30002 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql3).Tables[0];
  703. lookupHandles.Properties.ValueMember = "刀柄";
  704. lookupHandles.Properties.DisplayMember = "刀柄";
  705. lookupHandles.Properties.DataSource = dt30002;
  706. lookupHandles.Properties.NullText = "";
  707. lookupHandles.Properties.ImmediatePopup = true;
  708. lookupHandles.Properties.ValidateOnEnterKey = true;
  709. sql3 = @"SELECT LTRIM(RTRIM(EnumText)) as 轴数 FROM Sys_EnumValues WHERE EnumKey='30003' AND LTRIM(RTRIM(EnumText))<>'' AND WorkPointCode='" + AppConfig.WorkPointCode + "' ORDER BY EnumValue";
  710. DataTable dt30003 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql3).Tables[0];
  711. lookupAxis.Properties.ValueMember = "轴数";
  712. lookupAxis.Properties.DisplayMember = "轴数";
  713. lookupAxis.Properties.DataSource = dt30003;
  714. lookupAxis.Properties.NullText = "";
  715. lookupAxis.Properties.ImmediatePopup = true;
  716. lookupAxis.Properties.ValidateOnEnterKey = true;
  717. //sql3 = @"SELECT LTRIM(RTRIM(EnumText)) as 刀库数量 FROM Sys_EnumValues WHERE EnumKey='30004' AND LTRIM(RTRIM(EnumText))<>'' AND WorkPointCode='" + AppConfig.WorkPointCode + "' ORDER BY EnumValue";
  718. //DataTable dt30004 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql3).Tables[0];
  719. //lookupToolMagazine.Properties.ValueMember = "刀库数量";
  720. //lookupToolMagazine.Properties.DisplayMember = "刀库数量";
  721. //lookupToolMagazine.Properties.DataSource = dt30004;
  722. //lookupToolMagazine.Properties.NullText = "";
  723. //lookupToolMagazine.Properties.ImmediatePopup = true;
  724. //lookupToolMagazine.Properties.ValidateOnEnterKey = true;
  725. //sql3 = @"SELECT LTRIM(RTRIM(EnumText)) as 可加工外形 FROM Sys_EnumValues WHERE EnumKey='30005' AND LTRIM(RTRIM(EnumText))<>'' AND WorkPointCode='" + AppConfig.WorkPointCode + "' ORDER BY EnumValue";
  726. //DataTable dt30005 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql3).Tables[0];
  727. //lookupMachinableProfiles.Properties.ValueMember = "可加工外形";
  728. //lookupMachinableProfiles.Properties.DisplayMember = "可加工外形";
  729. //lookupMachinableProfiles.Properties.DataSource = dt30005;
  730. //lookupMachinableProfiles.Properties.NullText = "";
  731. //lookupMachinableProfiles.Properties.ImmediatePopup = true;
  732. //lookupMachinableProfiles.Properties.ValidateOnEnterKey = true;
  733. sql3 = @"SELECT LTRIM(RTRIM(EnumText)) as 精度 FROM Sys_EnumValues WHERE EnumKey='30006' AND LTRIM(RTRIM(EnumText))<>'' AND WorkPointCode='" + AppConfig.WorkPointCode + "' ORDER BY EnumValue";
  734. DataTable dt30006 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql3).Tables[0];
  735. lookupAccuracy.Properties.ValueMember = "精度";
  736. lookupAccuracy.Properties.DisplayMember = "精度";
  737. lookupAccuracy.Properties.DataSource = dt30006;
  738. lookupAccuracy.Properties.NullText = "";
  739. lookupAccuracy.Properties.ImmediatePopup = true;
  740. lookupAccuracy.Properties.ValidateOnEnterKey = true;
  741. #endregion
  742. #region 工序等级(原产品等级)
  743. string sql00019 = @"SELECT LTRIM(RTRIM(EnumValue)) as 类型,EnumText 说明 FROM Sys_EnumValues WHERE EnumKey='00019' AND LTRIM(RTRIM(EnumText))<>'' AND WorkPointCode='" + AppConfig.WorkPointCode + "' ORDER BY EnumValue";
  744. DataTable dt00019 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql00019).Tables[0];
  745. lookupOPLVL.Properties.ValueMember = "类型";
  746. lookupOPLVL.Properties.DisplayMember = "类型";
  747. lookupOPLVL.Properties.DataSource = dt00019;
  748. lookupOPLVL.Properties.NullText = "";
  749. lookupOPLVL.Properties.ImmediatePopup = true;
  750. lookupOPLVL.Properties.ValidateOnEnterKey = true;
  751. #endregion
  752. #region 设备
  753. string sqlEqp = @"SELECT EQPCODE AS 设备代码,EQPNAME AS 设备名称 FROM [dbo].[ICSEquipment] WHERE WorkPoint='" + AppConfig.WorkPointCode + "' ORDER BY EQPCode";
  754. DataTable dtEqp = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sqlEqp).Tables[0];
  755. txtEQPCODE.Properties.ValueMember = "设备代码";
  756. txtEQPCODE.Properties.DisplayMember = "设备代码";
  757. txtEQPCODE.Properties.DataSource = dtEqp;
  758. txtEQPCODE.Properties.NullText = "";
  759. txtEQPCODE.Properties.ImmediatePopup = true;
  760. txtEQPCODE.Properties.ValidateOnEnterKey = true;
  761. txtItemCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;
  762. //txtItemCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True;
  763. #endregion
  764. #region 品牌
  765. sql = @"select EnumValue as 品牌代码,EnumText as 品牌名称 from Sys_EnumValues where EnumKey='30007' and WorkPointCode='" + AppConfig.WorkPointCode + "' ";
  766. dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  767. txtpp1.Properties.ValueMember = "品牌代码";
  768. txtpp1.Properties.DisplayMember = "品牌代码";
  769. txtpp1.Properties.DataSource = dt;
  770. txtpp1.Properties.NullText = "";//空时的值
  771. txtpp1.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  772. txtpp1.Properties.ValidateOnEnterKey = true;//回车确认
  773. txtpp1.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  774. txtpp1.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容 //自适应宽度
  775. txtpp1.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  776. txtpp2.Properties.ValueMember = "品牌代码";
  777. txtpp2.Properties.DisplayMember = "品牌代码";
  778. txtpp2.Properties.DataSource = dt;
  779. txtpp2.Properties.NullText = "";//空时的值
  780. txtpp2.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  781. txtpp2.Properties.ValidateOnEnterKey = true;//回车确认
  782. txtpp2.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  783. txtpp2.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容 //自适应宽度
  784. txtpp2.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  785. txtpp3.Properties.ValueMember = "品牌代码";
  786. txtpp3.Properties.DisplayMember = "品牌代码";
  787. txtpp3.Properties.DataSource = dt;
  788. txtpp3.Properties.NullText = "";//空时的值
  789. txtpp3.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  790. txtpp3.Properties.ValidateOnEnterKey = true;//回车确认
  791. txtpp3.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  792. txtpp3.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容 //自适应宽度
  793. txtpp3.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  794. #endregion
  795. #region 车削类型
  796. sql = @"select EnumText as 车削类型 from Sys_EnumValues where enumkey='300010' and WorkPointcode='" + AppConfig.WorkPointCode + "' ";
  797. dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  798. txtcxtype.Properties.ValueMember = "车削类型";
  799. txtcxtype.Properties.DisplayMember = "车削类型";
  800. txtcxtype.Properties.DataSource = dt;
  801. txtcxtype.Properties.NullText = "";
  802. txtcxtype.Properties.ImmediatePopup = true;
  803. txtcxtype.Properties.ValidateOnEnterKey = true;
  804. #endregion
  805. #region 车削精度
  806. sql = @"select EnumText as 车削精度 from Sys_EnumValues where enumkey='300011' and WorkPointcode='" + AppConfig.WorkPointCode + "' order by EnumText";
  807. dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  808. txtcxjd.Properties.ValueMember = "车削精度";
  809. txtcxjd.Properties.DisplayMember = "车削精度";
  810. txtcxjd.Properties.DataSource = dt;
  811. txtcxjd.Properties.NullText = "";
  812. txtcxjd.Properties.ImmediatePopup = true;
  813. txtcxjd.Properties.ValidateOnEnterKey = true;
  814. #endregion
  815. }
  816. #endregion
  817. //设备类型按钮
  818. private void txtEQPType_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  819. {
  820. ButtonEdit btn = (ButtonEdit)sender;
  821. string sql = "select distinct EnumValue as [类型编码],EnumText as [设备类型] from dbo.Sys_EnumValues with(nolock) WHERE EnumKey='001' AND WorkPointCode='" + AppConfig.WorkPointCode + "' ORDER BY EnumValue";
  822. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  823. //if (obj == null)
  824. //{
  825. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  826. //}
  827. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  828. FormDataRefer reForm = new FormDataRefer();
  829. reForm.FormTitle = "设备类型信息";
  830. DataTable menuData = data;
  831. reForm.DataSource = menuData;
  832. reForm.MSelectFlag = false;
  833. reForm.RowIndexWidth = 35;
  834. reForm.HideCols.Add("ID");
  835. reForm.FormWidth = 500;
  836. reForm.FormHeight = 500;
  837. //reForm.FilterKey = btn.Text;
  838. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  839. if (reForm.ShowDialog() == DialogResult.OK)
  840. {
  841. DataTable retData = reForm.ReturnData;
  842. foreach (DataRow dr in retData.Rows)
  843. {
  844. txtEQPTypeCode.Text = dr["类型编码"].ToString();
  845. txtEQPTypeName.Text = dr["设备类型"].ToString();
  846. }
  847. }
  848. }
  849. private void txtEQPTypeCode_EditValueChanged(object sender, EventArgs e)
  850. {
  851. var o = txtEQPTypeCode.Properties.GetRowByKeyValue(txtEQPTypeCode.EditValue);
  852. if (o is DataRowView)
  853. {
  854. DataRowView RowView = o as DataRowView;
  855. //txtEQPTypeName.Text = RowView.Row["设备类型"].ToString();
  856. txtEQPTypeName.Text = RowView.Row["设备类型"].ToString();
  857. txtEQPTypeCode.Text = RowView.Row["设备类型编码"].ToString();
  858. }
  859. init2();
  860. }
  861. private void init2()
  862. {
  863. #region 设备编号
  864. string sql2 = @"select distinct EQPCode as [设备编号],EQPName as [设备名称] from dbo.ICSEquipment
  865. where EType='" + txtEQPTypeName.Text + "' AND WorkPoint='" + AppConfig.WorkPointCode + "'";
  866. DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql2).Tables[0];
  867. txtEQPCODE.Properties.ValueMember = "设备编号";
  868. txtEQPCODE.Properties.DisplayMember = "设备编号";
  869. txtEQPCODE.Properties.DataSource = dt2;
  870. txtEQPCODE.Properties.NullText = "";//空时的值
  871. txtEQPCODE.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  872. txtEQPCODE.Properties.ValidateOnEnterKey = true;//回车确认
  873. txtEQPCODE.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  874. txtEQPCODE.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  875. //自适应宽度
  876. txtEQPCODE.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  877. #endregion
  878. }
  879. private void txtEQPCODE_EditValueChanged(object sender, EventArgs e)
  880. {
  881. var o = txtEQPCODE.Properties.GetRowByKeyValue(txtEQPCODE.EditValue);
  882. if (o is DataRowView)
  883. {
  884. DataRowView RowView = o as DataRowView;
  885. txtEQPNAME.Text = RowView.Row["设备名称"].ToString();
  886. }
  887. }
  888. //计算比例不再与工序绑定
  889. //private void txtOPCODE_EditValueChanged(object sender, EventArgs e)
  890. //{
  891. // var o = txtOPCODE.Properties.GetRowByKeyValue(txtOPCODE.EditValue);
  892. // if (o is DataRowView)
  893. // {
  894. // DataRowView RowView = o as DataRowView;
  895. // txtOPCODE.Text = RowView.Row["工序代码"].ToString();
  896. // txtOPDESC.Text = RowView.Row["工序"].ToString();
  897. // string calcType = RowView.Row["工序属性"].ToString();
  898. // calcType = string.IsNullOrEmpty(calcType) ? "A" : calcType;
  899. // DataTable dt = ICSOPBLL.SearchDataByEnumValue(AppConfig.AppConnectString, "00023", calcType);
  900. // if (dt != null && dt.Rows.Count > 0)
  901. // {
  902. // txtCalc.Text = dt.Rows[0]["EnumText"].ToString();
  903. // decimal D;
  904. // if (Decimal.TryParse(txtCalc.Text, out D))
  905. // {
  906. // throw new Exception("工序:" + txtOPCODE.Text + "对应的工序属性'" + calcType + "'维护了错误的值'" + txtCalc.Text + "'");
  907. // }
  908. // }
  909. // else
  910. // {
  911. // throw new Exception("工序:" + txtOPCODE.Text + "对应的工序属性'" + calcType + "'未维护");
  912. // }
  913. // }
  914. //}
  915. private void cboTiaojiBaseTime_SelectedIndexChanged(object sender, EventArgs e)
  916. {
  917. ComboBoxEdit cbo = sender as ComboBoxEdit;
  918. if (cbo.SelectedIndex == -1)
  919. {
  920. return;
  921. }
  922. try
  923. {
  924. decimal baseTime = Convert.ToDecimal(cbo.SelectedItem.ToString());
  925. decimal rate = 0;
  926. decimal stime = Convert.ToDecimal(txtJiagongTime.Text);
  927. if (cboTiaojiPRT.SelectedIndex == -1)
  928. {
  929. rate = 0;
  930. }
  931. else
  932. {
  933. rate = Convert.ToDecimal(cboTiaojiPRT.SelectedItem.ToString());
  934. }
  935. decimal res = baseTime + stime * rate;
  936. txtTiaojiTime.Text = res.ToString();
  937. }
  938. catch (Exception ex)
  939. {
  940. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  941. }
  942. }
  943. private void cboTiaojiPRT_SelectedIndexChanged(object sender, EventArgs e)
  944. {
  945. ComboBoxEdit cbo = sender as ComboBoxEdit;
  946. if (cbo.SelectedIndex == -1)
  947. {
  948. return;
  949. }
  950. try
  951. {
  952. decimal baseTime = 0;
  953. if (cboTiaojiBaseTime.SelectedIndex == -1)
  954. {
  955. baseTime = 0;
  956. }
  957. else
  958. {
  959. baseTime = Convert.ToDecimal(cboTiaojiBaseTime.SelectedItem.ToString());
  960. }
  961. decimal rate = rate = Convert.ToDecimal(cbo.SelectedItem.ToString());
  962. decimal stime = Convert.ToDecimal(txtJiagongTime.Text);
  963. decimal res = baseTime + stime * rate;
  964. txtTiaojiTime.Text = res.ToString();
  965. }
  966. catch (Exception ex)
  967. {
  968. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  969. }
  970. }
  971. private void cboJianyanPRT_SelectedIndexChanged(object sender, EventArgs e)
  972. {
  973. ComboBoxEdit cbo = sender as ComboBoxEdit;
  974. if (cbo.SelectedIndex == -1)
  975. {
  976. return;
  977. }
  978. try
  979. {
  980. decimal rate = Convert.ToDecimal(cbo.SelectedItem.ToString());
  981. decimal stime = Convert.ToDecimal(txtJiagongTime.Text);
  982. decimal res = stime * rate;
  983. txtJianyanTime.Text = res.ToString();
  984. }
  985. catch (Exception ex)
  986. {
  987. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  988. }
  989. }
  990. private void txtTIME_EditValueChanged(object sender, EventArgs e)
  991. {
  992. TextEdit te = sender as TextEdit;
  993. try
  994. {
  995. decimal d = Convert.ToDecimal(te.Text);
  996. if (d < 0)
  997. {
  998. throw new Exception("值不可小于 0");
  999. }
  1000. cboTiaojiBaseTime_SelectedIndexChanged(cboTiaojiBaseTime, null);
  1001. cboTiaojiPRT_SelectedIndexChanged(cboTiaojiPRT, null);
  1002. cboJianyanPRT_SelectedIndexChanged(cboJianyanPRT, null);
  1003. }
  1004. catch (Exception ex)
  1005. {
  1006. te.Text = "0";
  1007. ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
  1008. }
  1009. }
  1010. private void txtOPCODE_EditValueChanged(object sender, EventArgs e)
  1011. {
  1012. var o = txtOPCODE.Properties.GetRowByKeyValue(txtOPCODE.EditValue);
  1013. if (o is DataRowView)
  1014. {
  1015. DataRowView RowView = o as DataRowView;
  1016. txtOPDESC.Text = RowView.Row["工序"].ToString();
  1017. chkIsWW.Checked = RowView.Row["工序属性"].ToString() == "委外";
  1018. }
  1019. }
  1020. private void lookupOPLVL_EditValueChanged(object sender, EventArgs e)
  1021. {
  1022. var o = lookupOPLVL.Properties.GetRowByKeyValue(lookupOPLVL.EditValue);
  1023. if (o is DataRowView)
  1024. {
  1025. DataRowView RowView = o as DataRowView;
  1026. txtOPLVLDesc.Text = RowView.Row["说明"].ToString();
  1027. }
  1028. }
  1029. private void cboEQPSetting_SelectedIndexChanged(object sender, EventArgs e)
  1030. {
  1031. tabControl1.SelectedIndex = cboEQPSetting.SelectedIndex;
  1032. if (first)
  1033. {
  1034. return;
  1035. }
  1036. txtROUTEMEMO.Text = "";
  1037. txtOPCODE.Text = "";
  1038. txtOPDESC.Text = "";
  1039. lookupClass.Text = lookupAxis.Text = lookupAccuracy.Text = lookupHandles.Text = lookupToolMagazine.Text = "";
  1040. txtJiagongTime.Text = txtJiazhuangTime.Text = "0";
  1041. if (cboEQPSetting.SelectedIndex == 1)
  1042. {
  1043. cboTiaojiPRT.SelectedIndex = cboTiaojiBaseTime.SelectedIndex = cboJianyanPRT.SelectedIndex = -1;
  1044. txtJiagongTime.Text = txtJiazhuangTime.Text = txtJianyanTime.Text = txtTiaojiTime.Text = "0";
  1045. lookupMachinableProfiles.Text = "";
  1046. }
  1047. lookupOPLVL.Text = "";
  1048. chkIsWW.Checked = false;
  1049. cboIsRef.Checked = true;
  1050. }
  1051. private void txtEQPCODE_EditValueChanged_1(object sender, EventArgs e)
  1052. {
  1053. if (txtEQPCODE.EditValue == null)
  1054. {
  1055. return;
  1056. }
  1057. var o = txtEQPCODE.Properties.GetRowByKeyValue(txtEQPCODE.EditValue);
  1058. if (o is DataRowView)
  1059. {
  1060. DataRowView RowView = o as DataRowView;
  1061. txtEQPNAME.Text = RowView.Row["设备名称"].ToString();
  1062. }
  1063. }
  1064. private void txtROUTECODE_EditValueChanged(object sender, EventArgs e)
  1065. {
  1066. var o = txtROUTECODE.Properties.GetRowByKeyValue(txtROUTECODE.EditValue);
  1067. if (o is DataRowView)
  1068. {
  1069. DataRowView RowView = o as DataRowView;
  1070. txtRouteName.Text = RowView.Row["工艺名称"].ToString();
  1071. #region 工序代码
  1072. string sql = @"
  1073. SELECT DISTINCT [],[],,[] FROM (
  1074. select distinct
  1075. a.OPCODE as [],
  1076. b.OPDESC as [] ,
  1077. a.OPSEQ AS ,
  1078. A.OPAttr AS []--CASE WHEN b.EATTRIBUTE1='1' THEN '' ELSE '' END []
  1079. from dbo.ICSITEMROUTE2OPLot a
  1080. left join ICSOP b on a.OPCODE=b.OPCODE AND a.WorkPoint=b.WorkPoint
  1081. WHERE a.ITEMCODE='{0}' and a.ROUTECODE='{1}' AND a.WorkPoint='{2}'
  1082. UNION ALL
  1083. select distinct
  1084. a.OPCODE as [],
  1085. b.OPDESC as [] ,
  1086. a.OPSEQ AS ,
  1087. A.OPAttr AS []--CASE WHEN b.EATTRIBUTE1='1' THEN '' ELSE '' END []
  1088. from ICSITEMROUTE2OP a
  1089. left join ICSOP b on a.OPCODE=b.OPCODE AND a.WorkPoint=b.WorkPoint
  1090. WHERE a.ITEMCODE='{0}' and a.ROUTECODE='{1}' AND a.WorkPoint='{2}'
  1091. )T ORDER BY T. ASC
  1092. ";
  1093. sql = string.Format(sql, txtItemCode.Text, txtROUTECODE.Text, AppConfig.WorkPointCode);
  1094. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  1095. // if (data == null || data.Rows.Count == 0)
  1096. // {
  1097. // sql2 = @"select distinct
  1098. // a.OPCODE as [工序代码],
  1099. // c.OPDESC as [工序]
  1100. // from ICSITEMROUTE2OP a
  1101. // left join ICSINVENTORY b on a.ITEMCODE=b.INVCODE
  1102. // left join ICSOP c on a.OPCODE=c.OPCODE
  1103. //where b.INVCODE='" + txtItemCode.Text + "' and 1=1";
  1104. // data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql2).Tables[0];
  1105. // }
  1106. txtOPCODE.Properties.ValueMember = "工序代码";
  1107. txtOPCODE.Properties.DisplayMember = "工序代码";
  1108. txtOPCODE.Properties.DataSource = data;
  1109. txtOPCODE.Properties.NullText = "";//空时的值
  1110. txtOPCODE.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
  1111. txtOPCODE.Properties.ValidateOnEnterKey = true;//回车确认
  1112. txtOPCODE.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
  1113. txtOPCODE.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
  1114. //自适应宽度
  1115. //txtOPCODE.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
  1116. #endregion
  1117. }
  1118. }
  1119. private void chkIsWW_CheckedChanged(object sender, EventArgs e)
  1120. {
  1121. txtWWTIME.Visible = LBL_WWU.Visible = LBL_WWTIME.Visible = chkIsWW.Checked;
  1122. }
  1123. private void txtpp1_Properties_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  1124. {
  1125. if (e.Button.Index == 1) {
  1126. txtpp1.Text = "";
  1127. }
  1128. }
  1129. private void txtpp2_Properties_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  1130. {
  1131. if (e.Button.Index == 1)
  1132. {
  1133. txtpp2.Text = "";
  1134. }
  1135. }
  1136. private void txtpp3_Properties_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  1137. {
  1138. if (e.Button.Index == 1)
  1139. {
  1140. txtpp3.Text = "";
  1141. }
  1142. }
  1143. private void txtcxjd_EditValueChanged(object sender, EventArgs e)
  1144. {
  1145. }
  1146. //private void txtSTIME_EditValueChanged(object sender, EventArgs e)
  1147. //{
  1148. // decimal calcJY = 0;
  1149. // string x = txtCalc.Text.TrimEnd('%');
  1150. // try
  1151. // {
  1152. // calcJY = Decimal.Parse(x);
  1153. // }
  1154. // catch (Exception)
  1155. // {
  1156. // throw new Exception("工序:" + txtOPCODE.Text + "对应的工序属性维护了错误的值'" + txtCalc.Text + "'");
  1157. // }
  1158. // txtJianyanTime.Text = (Convert.ToDecimal(txtSTIME.Text) * calcJY * 0.01m).ToString();
  1159. //}
  1160. }
  1161. }