F_PM_0504.cs 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_0504.cs
  5. * 2.功能描述:新建装窑车漏扫计件
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * chenxy 2019/12/10 1.00 设计窗体布局
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseControls;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Basics.Library;
  17. using Dongke.IBOSS.PRD.Client.CommonModule;
  18. using Dongke.IBOSS.PRD.Client.Controls.FormCommon;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. namespace Dongke.IBOSS.PRD.Client.PMModule
  22. {
  23. /// <summary>
  24. /// 新建装窑车计件
  25. /// </summary>
  26. public partial class F_PM_0504 : FormBase
  27. {
  28. #region 成员变量
  29. // 工序ID
  30. private int _procedureID;
  31. //窗体名称
  32. private string _fromTitle;
  33. // 工序实体类
  34. ProcedureEntity _procedureDataEntity;
  35. // 生产数据实体类
  36. List<ProductionDataEntity> _productionDataEntity = new List<ProductionDataEntity>();
  37. // 数据源Table
  38. private DataTable _dataSourceTable = null;
  39. // 添加行数据源
  40. private DataTable _collectType = null;
  41. // 当前操作实体
  42. ProductionDataEntity _productionEntity = new ProductionDataEntity();
  43. // 配置文件的全路径
  44. private string _iniFilePath = LocalPath.RootPath + Constant.INI_FILE_NAME;
  45. //窑车最大装载数
  46. private int MaxGoodsNum = 0;
  47. // 是否有商标
  48. private int? _isLogo = null;
  49. // 是否有商标编码
  50. private string _isLogoCode = "";
  51. // 是否有商标名称
  52. private string _isLogoName = "";
  53. private DataSet _KilntInfo = null;
  54. #endregion
  55. #region 构造函数
  56. /// <summary>
  57. /// 构造函数
  58. /// </summary>
  59. public F_PM_0504()
  60. {
  61. InitializeComponent();
  62. }
  63. /// <summary>
  64. /// 构造函数
  65. /// </summary>
  66. /// <param name="procedureID">工序编号</param>
  67. /// <param name="fromTitle">窗体名称</param>
  68. public F_PM_0504(int procedureID, string fromTitle)
  69. {
  70. InitializeComponent();
  71. this._procedureID = procedureID;
  72. this._fromTitle = fromTitle;
  73. this.SetFromTitleInfo();
  74. }
  75. #endregion
  76. #region 属性
  77. /// <summary>
  78. /// 绑定GridView数据源
  79. /// </summary>
  80. public DataTable DataSourceTable
  81. {
  82. set
  83. {
  84. _dataSourceTable = value;
  85. }
  86. get
  87. {
  88. if (_dataSourceTable == null)
  89. {
  90. _dataSourceTable = new DataTable("Table1");
  91. _dataSourceTable.Columns.Add("BarCode");
  92. _dataSourceTable.Columns.Add("GoodsID");
  93. _dataSourceTable.Columns.Add("GoodsCode");
  94. _dataSourceTable.Columns.Add("GoodsName");
  95. _dataSourceTable.Columns.Add("UserID");
  96. _dataSourceTable.Columns.Add("UserCode");
  97. _dataSourceTable.Columns.Add("UserName");
  98. _dataSourceTable.Columns.Add("KilnID");
  99. _dataSourceTable.Columns.Add("KilnCode");
  100. _dataSourceTable.Columns.Add("KilnName");
  101. _dataSourceTable.Columns.Add("KilnCarID");
  102. _dataSourceTable.Columns.Add("KilnCarCode");
  103. _dataSourceTable.Columns.Add("KilnCarName");
  104. _dataSourceTable.Columns.Add("KilnCarPosition", typeof(decimal));
  105. _dataSourceTable.Columns.Add("IsSave");//是否保存,为了的在此车上有此产品时显示出来(1不保存,只是查看)
  106. _dataSourceTable.Columns.Add("Status");//登车状态,只是查看
  107. _dataSourceTable.Columns.Add("IsPublicBody");
  108. _dataSourceTable.Columns.Add("MouldCode");
  109. _dataSourceTable.Columns.Add("GroutingUserCode");
  110. _dataSourceTable.Columns.Add("GroutingNum");
  111. _dataSourceTable.Columns.Add("GroutingDate", typeof(DateTime));
  112. _dataSourceTable.Columns.Add("LogoID");
  113. _dataSourceTable.Columns.Add("LogoCodeName");
  114. return _dataSourceTable;
  115. }
  116. else
  117. {
  118. return _dataSourceTable;
  119. }
  120. }
  121. }
  122. /// <summary>
  123. /// 添加行数据源
  124. /// </summary>
  125. public DataTable DataSourceCollectTypeTable
  126. {
  127. set
  128. {
  129. _collectType = value;
  130. }
  131. get
  132. {
  133. if (_collectType == null)
  134. {
  135. _collectType = new DataTable("Table2");
  136. _collectType.Columns.Add("BarCode");
  137. _collectType.Columns.Add("GoodsID");
  138. _collectType.Columns.Add("GoodsCode");
  139. _collectType.Columns.Add("GoodsName");
  140. _collectType.Columns.Add("UserID");
  141. _collectType.Columns.Add("UserCode");
  142. _collectType.Columns.Add("UserName");
  143. _collectType.Columns.Add("KilnID");
  144. _collectType.Columns.Add("KilnCode");
  145. _collectType.Columns.Add("KilnName");
  146. _collectType.Columns.Add("KilnCarID");
  147. _collectType.Columns.Add("KilnCarCode");
  148. _collectType.Columns.Add("KilnCarName");
  149. _collectType.Columns.Add("KilnCarPosition", typeof(decimal));
  150. return _collectType;
  151. }
  152. else
  153. {
  154. return _collectType;
  155. }
  156. }
  157. }
  158. #endregion
  159. #region 事件
  160. /// <summary>
  161. /// 窗体加载事件
  162. /// </summary>
  163. /// <param name="sender"></param>
  164. /// <param name="e"></param>
  165. private void F_PM_0504_Load(object sender, EventArgs e)
  166. {
  167. try
  168. {
  169. dtpFiredDate.Value = DateTime.Now.Date;
  170. //string getKiln = Utility.ReadIniFile(Constant.INI_SECTION_SETTINGS,
  171. // Constant.INI_KEY_KILN_CODE, this._iniFilePath);
  172. string getKiln = Utility.ReadIniFile(Constant.INI_SECTION_SETTINGS,
  173. Constant.INI_KEY_KILN_CODE, LocalPath.LocalINIFilePath);
  174. _KilntInfo = SystemModuleProxy.Service.GetAllKilntInfo();
  175. if (getKiln != string.Empty)
  176. {
  177. this.txtKiln.Text = getKiln;
  178. if (this.txtKiln.Text.Trim() != "")
  179. {
  180. //DataSet dsResultAccount = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  181. //{
  182. // return SystemModuleProxy.Service.GetAllKilntInfo();
  183. //}));
  184. DataSet dsResultAccount = _KilntInfo;
  185. if (dsResultAccount != null && dsResultAccount.Tables[0].Rows.Count > 0)
  186. {
  187. DataView dv = dsResultAccount.Tables[0].DefaultView;
  188. dv.RowFilter = "ValueFlag=1 and KilnCode='" + this.txtKiln.Text.Trim() + "'";
  189. DataTable dt = dv.ToTable();
  190. if (dt.Rows.Count == 0)
  191. {
  192. // 提示信息
  193. //MessageBox.Show("不存在此窑炉编号",
  194. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  195. this.txtKiln.SelectAll();
  196. this.txtKiln.Focus();
  197. //return;
  198. _productionEntity.KilnID = null;
  199. _productionEntity.KilnCode = null;
  200. }
  201. else
  202. {
  203. _productionEntity.KilnID = Convert.ToInt32(dt.Rows[0]["KilnID"]);
  204. _productionEntity.KilnCode = this.txtKiln.Text.Trim();
  205. }
  206. }
  207. }
  208. this.txtKilnCarCode.Focus();
  209. }
  210. else
  211. {
  212. this.txtKiln.Focus();
  213. }
  214. // 加载权限
  215. FormPermissionManager.FormPermissionControl(this.Name, this,
  216. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  217. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  218. DataTable tKilnCarInfo = GetMSTKilnCarPositionInfo();
  219. this.cmbKilnCarPosition.DataSource = tKilnCarInfo;
  220. this.cmbKilnCarPosition.DisplayMember = "DictionaryValue";
  221. this.cmbKilnCarPosition.ValueMember = "DictionaryID";
  222. this._productionEntity.UserID = Constant.INT_IS_NEGATIE_ONE;
  223. this._productionEntity.KilnCarID = Constant.INT_IS_NEGATIE_ONE;
  224. this.dgvProduction.DataSource = DataSourceTable;
  225. this.KilnCarPosition.DisplayMember = "DictionaryValue";
  226. this.KilnCarPosition.ValueMember = "DictionaryID";
  227. this.KilnCarPosition.DataSource = tKilnCarInfo.Copy();
  228. this.dgvProduction.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
  229. // 获取工序明细数据
  230. //ProcedureEntity procedureDataEntity = (ProcedureEntity)DoAsync(new BaseAsyncMethod(() =>
  231. //{
  232. // return PMModuleProxy.Service.GetProcedureDataEntityByID(this._procedureID);
  233. //}));
  234. ProcedureEntity procedureDataEntity = PMModuleProxy.Service.GetProcedureDataEntityByID(this._procedureID);
  235. this._procedureDataEntity = procedureDataEntity;
  236. // 设置控件禁用或启用
  237. SetControlEnable();
  238. //this.txtUserCode.Focus();
  239. }
  240. catch (Exception ex)
  241. {
  242. // 对异常进行共通处理
  243. ExceptionManager.HandleEventException(this.ToString(),
  244. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  245. }
  246. }
  247. /// <summary>
  248. /// 窗体关闭事件
  249. /// </summary>
  250. /// <param name="sender"></param>
  251. /// <param name="e"></param>
  252. private void btnCancel_Click(object sender, EventArgs e)
  253. {
  254. this.Close();
  255. }
  256. /// <summary>
  257. /// 窗体关闭事件
  258. /// </summary>
  259. /// <param name="sender"></param>
  260. /// <param name="e"></param>
  261. private void tsbtnClose_Click(object sender, EventArgs e)
  262. {
  263. this.Close();
  264. }
  265. /// <summary>
  266. /// 自动适应列宽
  267. /// </summary>
  268. /// <param name="sender"></param>
  269. /// <param name="e"></param>
  270. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  271. {
  272. this.dgvProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  273. }
  274. /// <summary>
  275. /// 条形码按键事件
  276. /// </summary>
  277. /// <param name="sender"></param>
  278. /// <param name="e"></param>
  279. private void txtBarcode_KeyPress(object sender, KeyPressEventArgs e)
  280. {
  281. try
  282. {
  283. if (this.txtBarcode.ReadOnly)
  284. {
  285. return;
  286. }
  287. if (!this.txtFiredBatchNo.ReadOnly)
  288. {
  289. e.Handled = true;
  290. txtBarcode.Clear();
  291. // 提示信息
  292. MessageBox.Show("请输入窑车烧成批次号",
  293. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  294. this.txtFiredBatchNo.Focus();
  295. return;
  296. }
  297. if ((int)e.KeyChar == Constant.SYSTEM_KEYBOARD_ENTER_VALUE) // 按了回车键
  298. {
  299. //if (this.txtUserCode.Text.Trim() == string.Empty)
  300. //{
  301. // this.txtUserCode.Focus();
  302. // this.txtBarcode.Text = string.Empty;
  303. // return;
  304. //}
  305. //if (this.txtKilnCarCode.Text.Trim() == string.Empty)
  306. //{
  307. // this.txtKilnCarCode.Focus();
  308. // this.txtBarcode.Text = string.Empty;
  309. // return;
  310. //}
  311. //if (this.txtBarcode.Text.Trim() == string.Empty)
  312. //{
  313. // this.txtBarcode.SelectAll();
  314. // this.txtBarcode.Focus();
  315. // return;
  316. //}
  317. DataRow[] drRows = this.DataSourceTable.Select("BarCode='" + this.txtBarcode.Text.Trim() + "'");
  318. if (drRows.Length == Constant.INT_IS_ZERO)
  319. {
  320. // 校验条码 获取校验条码信
  321. DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  322. {
  323. return PMModuleProxy.Service.CheckBarcode(this._procedureID, this.txtBarcode.Text.Trim());
  324. }));
  325. if (dsCheckBarcode != null && dsCheckBarcode.Tables[Constant.INT_IS_ZERO].Rows.Count > Constant.INT_IS_ZERO)
  326. {
  327. if (dsCheckBarcode.Tables[Constant.INT_IS_ZERO].Rows[Constant.INT_IS_ZERO]
  328. [Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString() != string.Empty)
  329. {
  330. // 表示有错误
  331. //MessageBox.Show(string.Format(dsCheckBarcode.Tables[Constant.INT_IS_ZERO].Rows[Constant.INT_IS_ZERO]
  332. // [Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(),
  333. // this.txtBarcode.Text.Trim(), "产品条码"),
  334. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  335. //this.txtBarcode.SelectAll();
  336. //this.txtBarcode.Focus();
  337. //return;
  338. if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()].ToString() == "0")
  339. {
  340. // 表示有错误
  341. MessageBox.Show(string.Format(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString(), this.txtBarcode.Text.Trim(), "产品条码"),
  342. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  343. }
  344. else
  345. {
  346. S_CMN_020 frmscmn020 = new S_CMN_020(Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_missFlag.ToString()])
  347. , dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_errMsg.ToString()].ToString());
  348. frmscmn020.ShowDialog();
  349. }
  350. this.txtBarcode.Focus();
  351. this.txtBarcode.SelectAll();
  352. return;
  353. }
  354. else
  355. {
  356. this.DataSourceTable.AcceptChanges();
  357. if (this.DataSourceTable.Rows.Count > Constant.INT_IS_ZERO)
  358. {
  359. if (this.MaxGoodsNum > 0 && this.DataSourceTable.Rows.Count >= this.MaxGoodsNum)
  360. {
  361. // 提示信息
  362. MessageBox.Show("超出登车产品最大装载数量" + this.MaxGoodsNum.ToString(),
  363. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  364. return;
  365. }
  366. }
  367. if (dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()].ToString() != "")
  368. {
  369. this._isLogo = Convert.ToInt32(dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoID.ToString()]);
  370. this._isLogoCode = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoCode.ToString()].ToString();
  371. this._isLogoName = dsCheckBarcode.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_logoName.ToString()].ToString();
  372. }
  373. // 生产数据实体
  374. ProductionDataEntity procedureDataEntity = new ProductionDataEntity();
  375. procedureDataEntity.Barcode = this.txtBarcode.Text.Trim(); // 产品条码
  376. procedureDataEntity.GoodsID = Convert.ToInt32(dsCheckBarcode.Tables[Constant.INT_IS_ZERO].Rows[Constant.INT_IS_ZERO]
  377. [Constant.BarCodeResultTableColumns.out_goodsID.ToString()]);
  378. procedureDataEntity.GoodsCode = dsCheckBarcode.Tables[Constant.INT_IS_ZERO].Rows[Constant.INT_IS_ZERO]
  379. [Constant.BarCodeResultTableColumns.out_goodsCode.ToString()].ToString();
  380. procedureDataEntity.GoodsName = dsCheckBarcode.Tables[Constant.INT_IS_ZERO].Rows[Constant.INT_IS_ZERO]
  381. [Constant.BarCodeResultTableColumns.out_goodsName.ToString()].ToString();
  382. procedureDataEntity.UserID = this._productionEntity.UserID;
  383. procedureDataEntity.UserCode = this._productionEntity.UserCode;
  384. procedureDataEntity.UserName = this._productionEntity.UserName;
  385. procedureDataEntity.KilnID = this._productionEntity.KilnID;
  386. procedureDataEntity.KilnCode = this._productionEntity.KilnCode;
  387. procedureDataEntity.KilnName = this._productionEntity.KilnName;
  388. procedureDataEntity.KilnCarID = this._productionEntity.KilnCarID;
  389. procedureDataEntity.KilnCarCode = this._productionEntity.KilnCarCode;
  390. procedureDataEntity.KilnCarName = this._productionEntity.KilnCarName;
  391. procedureDataEntity.KilnCarPosition = Convert.ToInt32(this.cmbKilnCarPosition.SelectedValue);
  392. procedureDataEntity.ValueFlag = Constant.ValueFlag.Effective.GetHashCode();
  393. procedureDataEntity.LogoID = this._isLogo;
  394. //if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Point) // 单点采集 直接保存
  395. //{
  396. // this.CollectTypeTwo(procedureDataEntity);
  397. //}
  398. //else
  399. //{
  400. this.CollectTypeOne(procedureDataEntity, dsCheckBarcode); // 集中采集
  401. //}
  402. this.txtBarcode.Text = string.Empty;
  403. this.txtBarcode.Focus();
  404. }
  405. }
  406. }
  407. else
  408. {
  409. this.txtBarcode.Text = "";
  410. }
  411. }
  412. }
  413. catch (Exception ex)
  414. {
  415. // 对异常进行共通处理
  416. ExceptionManager.HandleEventException(this.ToString(),
  417. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  418. }
  419. }
  420. /// <summary>
  421. /// 控件数据校验时发生
  422. /// </summary>
  423. /// <param name="sender"></param>
  424. /// <param name="e"></param>
  425. private void txtUserCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
  426. {
  427. try
  428. {
  429. if (txtUserCode.Text.Trim() == string.Empty) // 如果未添加数据,则此项获取焦点
  430. {
  431. this.txtUserCode.IsMustInput = true;
  432. this.txtUserCode.SelectAll();
  433. e.Cancel = true;
  434. return;
  435. }
  436. else if (!this.txtUserCode.ReadOnly)
  437. {
  438. SUserEntity userEntity = new SUserEntity();
  439. userEntity.UserCode = this.txtUserCode.Text.Trim();
  440. // 是否存在此用户编码的生产工号
  441. CheckProcedureUserResult MsgCheckProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
  442. {
  443. return PMModuleProxy.Service.CheckProcedureUser(this._procedureID, this.txtUserCode.Text.Trim());
  444. }));
  445. if (MsgCheckProcedureUser != null)
  446. {
  447. if (!string.IsNullOrEmpty(MsgCheckProcedureUser.ErrMsg))
  448. {
  449. MessageBox.Show(MsgCheckProcedureUser.ErrMsg,
  450. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  451. this.txtUserCode.SelectAll();
  452. e.Cancel = true;
  453. return;
  454. }
  455. // 有此生产工号
  456. if (this._productionEntity.UserID != -Constant.INT_IS_ONE)
  457. {
  458. if (MsgCheckProcedureUser.UserID != this._productionEntity.UserID)
  459. {
  460. this.SaveDataInfo();
  461. }
  462. }
  463. this._productionEntity.UserID = MsgCheckProcedureUser.UserID;
  464. this._productionEntity.UserCode = MsgCheckProcedureUser.UserCode;
  465. this._productionEntity.UserName = MsgCheckProcedureUser.UserName;
  466. this.txtUserCode.ReadOnly = true;
  467. }
  468. }
  469. }
  470. catch (Exception ex)
  471. {
  472. // 对异常进行共通处理
  473. ExceptionManager.HandleEventException(this.ToString(),
  474. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  475. }
  476. }
  477. private void txtKiln_Validating(object sender, System.ComponentModel.CancelEventArgs e)
  478. {
  479. try
  480. {
  481. if (string.IsNullOrWhiteSpace(this.txtKiln.Text) ||
  482. this.txtKiln.ReadOnly)
  483. {
  484. return;
  485. }
  486. //DataSet dsResultAccount = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  487. //{
  488. // return SystemModuleProxy.Service.GetAllKilntInfo();
  489. //}));
  490. //DataSet dsResultAccount = SystemModuleProxy.Service.GetAllKilntInfo();
  491. DataSet dsResultAccount = _KilntInfo;
  492. if (dsResultAccount != null && dsResultAccount.Tables[0].Rows.Count > 0)
  493. {
  494. DataView dv = dsResultAccount.Tables[0].DefaultView;
  495. dv.RowFilter = "ValueFlag=1 and KilnCode='" + this.txtKiln.Text.Trim() + "'";
  496. DataTable dt = dv.ToTable();
  497. if (dt.Rows.Count == 0)
  498. {
  499. _productionEntity.KilnID = null;
  500. _productionEntity.KilnCode = null;
  501. e.Cancel = true;
  502. this.txtKiln.SelectAll();
  503. // 提示信息
  504. MessageBox.Show("不存在此窑炉编号",
  505. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  506. return;
  507. }
  508. else
  509. {
  510. _productionEntity.KilnID = Convert.ToInt32(dt.Rows[0]["KilnID"]);
  511. _productionEntity.KilnCode = this.txtKiln.Text.Trim();
  512. }
  513. // 保存业务系统配置
  514. Utility.WriteIniFile(Constant.INI_SECTION_SETTINGS, Constant.INI_KEY_KILN_CODE,
  515. this.txtKiln.Text.Trim(), this._iniFilePath);
  516. // 验证烧成批次
  517. if (string.IsNullOrWhiteSpace(this._productionEntity.KilnCode) ||
  518. this._productionEntity.KilnID == null ||
  519. this._productionEntity.KilnID == -1)
  520. {
  521. return;
  522. }
  523. if (string.IsNullOrWhiteSpace(this._productionEntity.KilnCarCode) ||
  524. this._productionEntity.KilnCarID == null ||
  525. this._productionEntity.KilnCarID == -1)
  526. {
  527. return;
  528. }
  529. if (string.IsNullOrWhiteSpace(this.txtFiredBatchNo.Text))
  530. {
  531. return;
  532. }
  533. this.CheckFiredBatchNo();
  534. }
  535. }
  536. catch (Exception ex)
  537. {
  538. // 对异常进行共通处理
  539. ExceptionManager.HandleEventException(this.ToString(),
  540. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  541. }
  542. }
  543. private void txtKiln_KeyPress(object sender, KeyPressEventArgs e)
  544. {
  545. try
  546. {
  547. if ((int)e.KeyChar == Constant.SYSTEM_KEYBOARD_ENTER_VALUE) // 按了回车键
  548. {
  549. this.txtKilnCarCode.Focus();
  550. }
  551. }
  552. catch (Exception ex)
  553. {
  554. // 对异常进行共通处理
  555. ExceptionManager.HandleEventException(this.ToString(),
  556. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  557. }
  558. }
  559. private void txtKilnCarCode_KeyPress(object sender, KeyPressEventArgs e)
  560. {
  561. try
  562. {
  563. if ((int)e.KeyChar == Constant.SYSTEM_KEYBOARD_ENTER_VALUE) // 按了回车键
  564. {
  565. this.dtpFiredDate.Focus();
  566. }
  567. }
  568. catch (Exception ex)
  569. {
  570. // 对异常进行共通处理
  571. ExceptionManager.HandleEventException(this.ToString(),
  572. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  573. }
  574. }
  575. /// <summary>
  576. /// 控件数据校验时发生
  577. /// </summary>
  578. /// <param name="sender"></param>
  579. /// <param name="e"></param>
  580. private void txtKilnCarCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
  581. {
  582. try
  583. {
  584. if (string.IsNullOrWhiteSpace(this.txtKilnCarCode.Text) ||
  585. this.txtKilnCarCode.ReadOnly)
  586. {
  587. return;
  588. }
  589. ClientRequestEntity cre = new ClientRequestEntity();
  590. cre.NameSpace = "F_PM_0504";
  591. cre.Name = "CheckKilnCar";
  592. cre.Properties["kilncarcode"] = this.txtKiln.Text.Trim() + this.txtKilnCarCode.Text.Trim();
  593. cre.Properties["procedureID"] = this._procedureID;
  594. ServiceResultEntity sre = PMModuleProxyNew.Service.HandleRequest(cre);
  595. this._productionEntity.KilnCarID = null;
  596. this._productionEntity.KilnCarCode = null;
  597. if (sre == null)
  598. {
  599. this.txtKilnCarCode.SelectAll();
  600. e.Cancel = true;
  601. MessageBox.Show("此窑车不存在",
  602. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  603. return;
  604. }
  605. if (sre.Status == Constant.ServiceResultStatus.Other)
  606. {
  607. this.txtKilnCarCode.SelectAll();
  608. e.Cancel = true;
  609. MessageBox.Show(sre.Message,
  610. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  611. return;
  612. }
  613. this._productionEntity.KilnCarID = Convert.ToInt32(sre.Result);
  614. this._productionEntity.KilnCarCode = this.txtKiln.Text.Trim() + this.txtKilnCarCode.Text.Trim();
  615. //this.txtKilnCarCode.ReadOnly = true;
  616. //this.txtKiln.ReadOnly = true;
  617. // 验证烧成批次
  618. if (string.IsNullOrWhiteSpace(this._productionEntity.KilnCode) ||
  619. this._productionEntity.KilnID == null ||
  620. this._productionEntity.KilnID == -1)
  621. {
  622. return;
  623. }
  624. if (string.IsNullOrWhiteSpace(this._productionEntity.KilnCarCode) ||
  625. this._productionEntity.KilnCarID == null ||
  626. this._productionEntity.KilnCarID == -1)
  627. {
  628. return;
  629. }
  630. if (string.IsNullOrWhiteSpace(this.txtFiredBatchNo.Text))
  631. {
  632. return;
  633. }
  634. this.CheckFiredBatchNo();
  635. }
  636. catch (Exception ex)
  637. {
  638. // 对异常进行共通处理
  639. ExceptionManager.HandleEventException(this.ToString(),
  640. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  641. }
  642. }
  643. private void dtpFiredDate_Validating(object sender, System.ComponentModel.CancelEventArgs e)
  644. {
  645. // 验证烧成批次
  646. if (string.IsNullOrWhiteSpace(this._productionEntity.KilnCode) ||
  647. this._productionEntity.KilnID == null ||
  648. this._productionEntity.KilnID == -1)
  649. {
  650. return;
  651. }
  652. if (string.IsNullOrWhiteSpace(this._productionEntity.KilnCarCode) ||
  653. this._productionEntity.KilnCarID == null ||
  654. this._productionEntity.KilnCarID == -1)
  655. {
  656. return;
  657. }
  658. if (string.IsNullOrWhiteSpace(this.txtFiredBatchNo.Text))
  659. {
  660. return;
  661. }
  662. this.CheckFiredBatchNo();
  663. }
  664. /// <summary>
  665. /// 删除按钮事件
  666. /// </summary>
  667. /// <param name="sender"></param>
  668. /// <param name="e"></param>
  669. private void tsbtnDelete_Click(object sender, EventArgs e)
  670. {
  671. if (this.dgvProduction.CurrentCell != null)
  672. {
  673. if (this.dgvProduction.Rows[this.dgvProduction.CurrentCell.RowIndex].Cells["Status"].Value.ToString() != "己登车")
  674. {
  675. this.DataSourceTable.Rows[this.dgvProduction.CurrentCell.RowIndex].Delete();
  676. }
  677. }
  678. }
  679. /// <summary>
  680. /// 保存按钮事件
  681. /// </summary>
  682. /// <param name="sender"></param>
  683. /// <param name="e"></param>
  684. private void btnSave_Click(object sender, EventArgs e)
  685. {
  686. try
  687. {
  688. this.SaveDataInfo();
  689. }
  690. catch (Exception ex)
  691. {
  692. // 对异常进行共通处理
  693. ExceptionManager.HandleEventException(this.ToString(),
  694. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  695. }
  696. }
  697. /// <summary>
  698. /// 窗体关闭时事件
  699. /// </summary>
  700. /// <param name="sender"></param>
  701. /// <param name="e"></param>
  702. private void F_PM_0504_FormClosing(object sender, FormClosingEventArgs e)
  703. {
  704. if (this.btnSave.Visible)
  705. {
  706. try
  707. {
  708. this.DataSourceTable.AcceptChanges();
  709. this.DataSourceCollectTypeTable.Clear();
  710. if (this.DataSourceTable.Rows.Count > Constant.INT_IS_ZERO)
  711. {
  712. if (DataSourceTable.Select("IsSave<>1").Length > 0)
  713. {
  714. DialogResult result = MessageBox.Show(Messages.MSG_CMN_Q001, this.Text,
  715. MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
  716. if (result == DialogResult.Yes)
  717. {
  718. // 保存数据
  719. btnSave_Click(sender, e);
  720. }
  721. else if (result == DialogResult.Cancel)
  722. {
  723. e.Cancel = true;
  724. }
  725. }
  726. }
  727. }
  728. catch (Exception ex)
  729. {
  730. // 对异常进行共通处理
  731. ExceptionManager.HandleEventException(this.ToString(),
  732. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  733. }
  734. }
  735. }
  736. /// <summary>
  737. /// 鼠标单击事件
  738. /// </summary>
  739. /// <param name="sender"></param>
  740. /// <param name="e"></param>
  741. private void txtUserCode_MouseClick(object sender, MouseEventArgs e)
  742. {
  743. if (this.txtUserCode.Text.Trim() != string.Empty)
  744. {
  745. this.txtUserCode.SelectAll();
  746. }
  747. }
  748. /// <summary>
  749. /// 生产工号回车事件
  750. /// </summary>
  751. /// <param name="sender"></param>
  752. /// <param name="e"></param>
  753. private void txtUserCode_KeyPress(object sender, KeyPressEventArgs e)
  754. {
  755. //if ((int)e.KeyChar == 13) // 按了回车键
  756. //{
  757. // this.txtKilnCarCode.Focus();
  758. //}
  759. }
  760. #endregion
  761. #region 私有方法
  762. /// <summary>
  763. /// 设置窗体按钮的文本信息
  764. /// </summary>
  765. private void SetFromTitleInfo()
  766. {
  767. this.Text = "漏扫补件【" + this._fromTitle + "】";
  768. this.tsbtnDelete.Text = ButtonText.TSBTN_DELETE;
  769. //自动适应列宽
  770. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  771. //关闭
  772. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  773. this.btnSave.Text = ButtonText.BTN_SAVE;
  774. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  775. }
  776. /// <summary>
  777. /// 设置控件禁用或启用
  778. /// </summary>
  779. private void SetControlEnable()
  780. {
  781. if (this._procedureDataEntity != null)
  782. {
  783. //if (this._procedureDataEntity.CollectType == (int)Constant.ProcedureCollectType.Togather)
  784. //{
  785. // this.txtUserCode.Enabled = true;
  786. // this.tsbtnDelete.Visible = true;
  787. // this.tsbtnDelete.Enabled = true;
  788. // this.btnSave.Visible = true;
  789. //}
  790. //else
  791. {
  792. this.tsbtnDelete.Visible = true;
  793. this.tsbtnDelete.Enabled = true;
  794. this.txtUserCode.Enabled = true;
  795. this.txtUserCode.ReadOnly = true;
  796. this._productionEntity.UserID = Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserID;
  797. this._productionEntity.UserCode = Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode;
  798. this._productionEntity.UserName = Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserName;
  799. this.txtUserCode.Text = this._productionEntity.UserCode;
  800. this.btnSave.Visible = true;
  801. // 此工号是否能生产工序
  802. CheckProcedureUserResult checkProcedureUser = (CheckProcedureUserResult)DoAsync(new BaseAsyncMethod(() =>
  803. {
  804. return PMModuleProxy.Service.CheckProcedureUser(this._procedureID,
  805. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode);
  806. }));
  807. if (checkProcedureUser != null)
  808. {
  809. if (!string.IsNullOrEmpty(checkProcedureUser.ErrMsg))
  810. {
  811. // 此工号不允许生产工序
  812. MessageBox.Show(checkProcedureUser.ErrMsg,
  813. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  814. this.Close();
  815. return;
  816. }
  817. }
  818. }
  819. }
  820. }
  821. /// <summary>
  822. /// 获取窑车位置字典表数据
  823. /// </summary>
  824. /// <returns></returns>
  825. public DataTable GetMSTKilnCarPositionInfo()
  826. {
  827. DataTable dtDicInfo = (DataTable)DoAsync(new BaseAsyncMethod(() =>
  828. {
  829. return CommonModuleProxy.Service.GetDataDictionaryByType(Constant.TPC_TPC003);
  830. }));
  831. return dtDicInfo;
  832. }
  833. /// <summary>
  834. /// 单点采集模式
  835. /// </summary>
  836. /// <param name="procedureDataEntity"></param>
  837. private void CollectTypeTwo(ProductionDataEntity procedureDataEntity)
  838. {
  839. try
  840. {
  841. #region 单点采集
  842. // 添加行就可以 并保存
  843. // 保存到数据库
  844. DataSourceCollectTypeTable.Rows.Clear();
  845. DataRow drCollectType = DataSourceCollectTypeTable.NewRow();
  846. drCollectType["BarCode"] = procedureDataEntity.Barcode;
  847. drCollectType["GoodsID"] = procedureDataEntity.GoodsID;
  848. drCollectType["GoodsCode"] = procedureDataEntity.GoodsCode;
  849. drCollectType["GoodsName"] = procedureDataEntity.GoodsName;
  850. drCollectType["UserID"] = procedureDataEntity.UserID;
  851. drCollectType["UserCode"] = procedureDataEntity.UserCode;
  852. drCollectType["UserName"] = procedureDataEntity.UserName;
  853. drCollectType["KilnID"] = procedureDataEntity.KilnID;
  854. drCollectType["KilnCode"] = procedureDataEntity.KilnCode;
  855. drCollectType["KilnName"] = procedureDataEntity.KilnName;
  856. drCollectType["KilnCarID"] = procedureDataEntity.KilnCarID;
  857. drCollectType["KilnCarCode"] = procedureDataEntity.KilnCarCode;
  858. drCollectType["KilnCarName"] = procedureDataEntity.KilnCarName;
  859. drCollectType["KilnCarPosition"] = procedureDataEntity.KilnCarPosition;
  860. DataSourceCollectTypeTable.Rows.Add(drCollectType);
  861. DataTable returnString = (DataTable)DoAsync(new BaseAsyncMethod(() =>
  862. {
  863. return PMModuleProxy.Service.AddWorkPiece(this._procedureID, DataSourceCollectTypeTable);
  864. }
  865. ));
  866. DataRow dr = this.DataSourceTable.NewRow();
  867. dr["BarCode"] = procedureDataEntity.Barcode;
  868. dr["GoodsID"] = procedureDataEntity.GoodsID;
  869. dr["GoodsCode"] = procedureDataEntity.GoodsCode;
  870. dr["GoodsName"] = procedureDataEntity.GoodsName;
  871. dr["UserID"] = procedureDataEntity.UserID;
  872. dr["UserCode"] = procedureDataEntity.UserCode;
  873. dr["UserName"] = procedureDataEntity.UserName;
  874. dr["KilnID"] = procedureDataEntity.KilnID;
  875. dr["KilnCode"] = procedureDataEntity.KilnCode;
  876. dr["KilnName"] = procedureDataEntity.KilnName;
  877. dr["KilnCarID"] = procedureDataEntity.KilnCarID;
  878. dr["KilnCarCode"] = procedureDataEntity.KilnCarCode;
  879. dr["KilnCarName"] = procedureDataEntity.KilnCarName;
  880. dr["KilnCarPosition"] = procedureDataEntity.KilnCarPosition;
  881. this.DataSourceTable.Rows.Add(dr);
  882. this.dgvProduction.CurrentCell = null;
  883. this.dgvProduction.Rows[dgvProduction.RowCount - 1].Selected = true;
  884. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[dgvProduction.RowCount - 1].Cells[0];
  885. #endregion
  886. }
  887. catch (Exception ex)
  888. {
  889. throw ex;
  890. }
  891. }
  892. /// <summary>
  893. ///集中采集模式
  894. /// </summary>
  895. /// <param name="procedureDataEntity"></param>
  896. private void CollectTypeOne(ProductionDataEntity procedureDataEntity,DataSet dsGroutingProduct)
  897. {
  898. try
  899. {
  900. #region 集中采集
  901. DataRow[] drRows = this.DataSourceTable.Select("BarCode='" + procedureDataEntity.Barcode + "'");
  902. if (drRows.Length > Constant.INT_IS_ZERO)
  903. {
  904. this.txtBarcode.Text = "";
  905. return;
  906. }
  907. // 由产品条码获取注浆信息
  908. //DataSet dsGroutingProduct = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  909. //{
  910. // return PMModuleProxy.Service.GetGroutingProducttByBarCode(procedureDataEntity.Barcode);
  911. //}));
  912. DataRow dr = this.DataSourceTable.NewRow();
  913. dr["BarCode"] = procedureDataEntity.Barcode;
  914. dr["GoodsID"] = procedureDataEntity.GoodsID;
  915. dr["GoodsCode"] = procedureDataEntity.GoodsCode;
  916. dr["GoodsName"] = procedureDataEntity.GoodsName;
  917. dr["UserID"] = procedureDataEntity.UserID;
  918. dr["UserCode"] = procedureDataEntity.UserCode;
  919. dr["UserName"] = procedureDataEntity.UserName;
  920. dr["KilnID"] = procedureDataEntity.KilnID;
  921. dr["KilnCode"] = procedureDataEntity.KilnCode;
  922. dr["KilnName"] = procedureDataEntity.KilnName;
  923. dr["KilnCarID"] = procedureDataEntity.KilnCarID;
  924. dr["KilnCarCode"] = procedureDataEntity.KilnCarCode;
  925. dr["KilnCarName"] = procedureDataEntity.KilnCarName;
  926. dr["KilnCarPosition"] = procedureDataEntity.KilnCarPosition;
  927. dr["MouldCode"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_mouldCode.ToString()];
  928. dr["GroutingUserCode"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingUserCode.ToString()];
  929. dr["GroutingNum"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingNum.ToString()];
  930. dr["GroutingDate"] = Convert.ToDateTime(dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_groutingdate.ToString()]);
  931. dr["IsPublicBody"] = dsGroutingProduct.Tables[0].Rows[0][Constant.BarCodeResultTableColumns.out_ispublicbody.ToString()].ToString() != "1" ? 0 : 1;
  932. dr["LogoID"] = procedureDataEntity.LogoID;
  933. dr["LogoCodeName"] = this._isLogoName + "[" + this._isLogoCode + "]";
  934. this.DataSourceTable.Rows.Add(dr);
  935. this.dgvProduction.CurrentCell = null;
  936. this.dgvProduction.Rows[dgvProduction.RowCount - 1].Selected = true;
  937. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[dgvProduction.RowCount - 1].Cells[0];
  938. #endregion
  939. }
  940. catch (Exception ex)
  941. {
  942. throw ex;
  943. }
  944. }
  945. /// <summary>
  946. /// 保存数据到数据库
  947. /// </summary>
  948. private void SaveDataInfo()
  949. {
  950. this.DataSourceTable.AcceptChanges();
  951. this.DataSourceCollectTypeTable = null;
  952. if (this.DataSourceTable.Rows.Count > Constant.INT_IS_ZERO)
  953. {
  954. //if (this.MaxGoodsNum > 0 && this.DataSourceTable.Rows.Count > this.MaxGoodsNum)
  955. //{
  956. // // 提示信息
  957. // MessageBox.Show("超出登车产品最大装载数量" + this.MaxGoodsNum.ToString(),
  958. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  959. // return;
  960. //}
  961. foreach (DataRow drproductionData in this.DataSourceTable.Rows)
  962. {
  963. if (drproductionData["IsSave"].ToString() != "1")
  964. {
  965. DataRow drCollectType = DataSourceCollectTypeTable.NewRow();
  966. drCollectType["BarCode"] = drproductionData["BarCode"];
  967. //drCollectType["GoodsID"] = drproductionData["GoodsID"];
  968. //drCollectType["GoodsCode"] = drproductionData["GoodsCode"];
  969. //drCollectType["GoodsName"] = drproductionData["GoodsName"];
  970. //drCollectType["UserID"] = drproductionData["UserID"];
  971. //drCollectType["UserCode"] = drproductionData["UserCode"];
  972. //drCollectType["UserName"] = drproductionData["UserName"];
  973. //drCollectType["KilnID"] = drproductionData["KilnID"];
  974. //drCollectType["KilnCode"] = drproductionData["KilnCode"];
  975. //drCollectType["KilnName"] = drproductionData["KilnName"];
  976. //drCollectType["KilnCarID"] = drproductionData["KilnCarID"];
  977. //drCollectType["KilnCarCode"] = drproductionData["KilnCarCode"];
  978. //drCollectType["KilnCarName"] = drproductionData["KilnCarName"];
  979. drCollectType["KilnCarPosition"] = drproductionData["KilnCarPosition"];
  980. DataSourceCollectTypeTable.Rows.Add(drCollectType);
  981. }
  982. }
  983. if (DataSourceCollectTypeTable.Rows.Count == 0)
  984. {
  985. // 提示信息
  986. MessageBox.Show("以上产品已经登车",
  987. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  988. return;
  989. }
  990. string KilnCarBatchNo = string.Format("{0}#{1}#{2}#{3}",
  991. this._productionEntity.KilnCode,
  992. this._productionEntity.KilnCarCode,
  993. this.dtpFiredDate.Value.Value.ToString("yyyyMMdd"),
  994. this.txtFiredBatchNo.DataValue.Value.ToString("000"));
  995. ClientRequestEntity cre = new ClientRequestEntity();
  996. cre.NameSpace = "F_PM_0504";
  997. cre.Name = "SetKilnCarMissing";
  998. cre.Properties["KilnID"] = this._productionEntity.KilnID.Value;
  999. cre.Properties["KilnCarID"] = this._productionEntity.KilnCarID.Value;
  1000. cre.Properties["FiredDate"] = this.dtpFiredDate.Value.Value;
  1001. cre.Properties["KilnCarBatchNo"] = KilnCarBatchNo;
  1002. cre.Properties["ProcedureID"] = this._procedureID;
  1003. cre.Properties["ModelType"] = this._procedureDataEntity.ModelType;
  1004. cre.Data = new DataSet();
  1005. cre.Data.Tables.Add(DataSourceCollectTypeTable);
  1006. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
  1007. {
  1008. return PMModuleProxyNew.Service.HandleRequest(cre);
  1009. }));
  1010. if (sre == null)
  1011. {
  1012. // 提示信息
  1013. MessageBox.Show("操作失败",
  1014. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1015. return;
  1016. }
  1017. if (sre.Status != Constant.ServiceResultStatus.Success)
  1018. {
  1019. MessageBox.Show(sre.Message,
  1020. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1021. return;
  1022. }
  1023. // 提示信息
  1024. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
  1025. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  1026. this.txtBarcode.Clear();
  1027. this._productionDataEntity.Clear();
  1028. this.DataSourceTable.Rows.Clear();
  1029. this.txtKilnCarCode.Clear();
  1030. this.txtFiredBatchNo.Clear();
  1031. this._productionEntity = new ProductionDataEntity();
  1032. this.txtKilnCarCode.ReadOnly = false;
  1033. this.txtKiln.ReadOnly = false;
  1034. this.dtpFiredDate.Enabled = true;
  1035. this.txtFiredBatchNo.ReadOnly = false;
  1036. }
  1037. }
  1038. #endregion
  1039. private void btnOk_Click(object sender, EventArgs e)
  1040. {
  1041. this.btnOk.Focus();
  1042. if (this.txtFiredBatchNo.ReadOnly)
  1043. {
  1044. return;
  1045. }
  1046. try
  1047. {
  1048. btnOk.Tag = 1;
  1049. if (string.IsNullOrWhiteSpace(this._productionEntity.KilnCode) ||
  1050. this._productionEntity.KilnID == null ||
  1051. this._productionEntity.KilnID == -1)
  1052. {
  1053. MessageBox.Show("没有输入窑炉", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1054. this.txtKiln.Focus();
  1055. return;
  1056. }
  1057. if (string.IsNullOrWhiteSpace(this._productionEntity.KilnCarCode) ||
  1058. this._productionEntity.KilnCarID == null ||
  1059. this._productionEntity.KilnCarID == -1)
  1060. {
  1061. MessageBox.Show("没有输入窑车", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1062. this.txtKilnCarCode.Focus();
  1063. return;
  1064. }
  1065. if (string.IsNullOrWhiteSpace(this.txtFiredBatchNo.Text))
  1066. {
  1067. MessageBox.Show("没有输入烧成批次", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1068. this.txtFiredBatchNo.Focus();
  1069. return;
  1070. }
  1071. this.CheckFiredBatchNo();
  1072. }
  1073. catch (Exception ex)
  1074. {
  1075. // 对异常进行共通处理
  1076. ExceptionManager.HandleEventException(this.ToString(),
  1077. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1078. }
  1079. finally
  1080. {
  1081. btnOk.Tag = null;
  1082. btnOk.Enabled = true;
  1083. }
  1084. }
  1085. private void CheckFiredBatchNo()
  1086. {
  1087. string KilnCarBatchNo = string.Format("{0}#{1}#{2}#{3}",
  1088. this._productionEntity.KilnCode,
  1089. this._productionEntity.KilnCarCode,
  1090. this.dtpFiredDate.Value.Value.ToString("yyyyMMdd"),
  1091. this.txtFiredBatchNo.DataValue.Value.ToString("000"));
  1092. ClientRequestEntity cre = new ClientRequestEntity();
  1093. cre.NameSpace = "F_PM_0504";
  1094. cre.Name = "CheckKilnCarBatchNo";
  1095. cre.Properties["KilnID"] = this._productionEntity.KilnID.Value;
  1096. cre.Properties["KilnCarID"] = this._productionEntity.KilnCarID.Value;
  1097. cre.Properties["FiredDate"] = this.dtpFiredDate.Value.Value;
  1098. cre.Properties["KilnCarBatchNo"] = KilnCarBatchNo;
  1099. cre.Properties["ProcedureID"] = this._procedureID;
  1100. cre.Properties["ModelType"] = this._procedureDataEntity.ModelType;
  1101. //ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
  1102. //{
  1103. // return PMModuleProxyNew.Service.HandleRequest(cre);
  1104. //}));
  1105. ServiceResultEntity sre = PMModuleProxyNew.Service.HandleRequest(cre);
  1106. if (sre == null)
  1107. {
  1108. MessageBox.Show("此窑车烧成批次不存在",
  1109. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1110. return;
  1111. }
  1112. if (sre.Status == Constant.ServiceResultStatus.Other)
  1113. {
  1114. MessageBox.Show(sre.Message,
  1115. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1116. return;
  1117. }
  1118. this.txtKilnCarCode.ReadOnly = true;
  1119. this.txtKiln.ReadOnly = true;
  1120. this.txtFiredBatchNo.ReadOnly = true;
  1121. this.dtpFiredDate.Enabled = false;
  1122. }
  1123. private void txtFiredBatchNo_KeyPress(object sender, KeyPressEventArgs e)
  1124. {
  1125. try
  1126. {
  1127. if ((int)e.KeyChar == Constant.SYSTEM_KEYBOARD_ENTER_VALUE) // 按了回车键
  1128. {
  1129. this.btnOk.Focus();
  1130. }
  1131. }
  1132. catch (Exception ex)
  1133. {
  1134. // 对异常进行共通处理
  1135. ExceptionManager.HandleEventException(this.ToString(),
  1136. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1137. }
  1138. }
  1139. private void txtFiredBatchNo_Validating(object sender, System.ComponentModel.CancelEventArgs e)
  1140. {
  1141. try
  1142. {
  1143. if (this.txtFiredBatchNo.ReadOnly || string.IsNullOrWhiteSpace(this.txtFiredBatchNo.Text))
  1144. {
  1145. return;
  1146. }
  1147. // 验证烧成批次
  1148. if (string.IsNullOrWhiteSpace(this._productionEntity.KilnCode) ||
  1149. this._productionEntity.KilnID == null ||
  1150. this._productionEntity.KilnID == -1)
  1151. {
  1152. return;
  1153. }
  1154. if (string.IsNullOrWhiteSpace(this._productionEntity.KilnCarCode) ||
  1155. this._productionEntity.KilnCarID == null ||
  1156. this._productionEntity.KilnCarID == -1)
  1157. {
  1158. return;
  1159. }
  1160. if (string.IsNullOrWhiteSpace(this.txtFiredBatchNo.Text))
  1161. {
  1162. return;
  1163. }
  1164. this.CheckFiredBatchNo();
  1165. }
  1166. catch (Exception ex)
  1167. {
  1168. // 对异常进行共通处理
  1169. ExceptionManager.HandleEventException(this.ToString(),
  1170. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1171. }
  1172. }
  1173. }
  1174. }