F_PM_0504.cs 52 KB

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