F_PM_0502.cs 52 KB

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