F_PM_3201.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. /*******************************************************************************
  2. * Copyright(c) 2019 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_3201.cs
  5. * 2.功能描述:半检一览
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * xuwei 2019-12-12 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.BaseResources;
  15. using Dongke.IBOSS.PRD.Basics.DockPanel;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.DataModels.PMModule;
  19. using Dongke.IBOSS.PRD.WCF.Proxys;
  20. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  21. namespace Dongke.IBOSS.PRD.Client.PMModule
  22. {
  23. /// <summary>
  24. /// 成品检验一览
  25. /// </summary>
  26. public partial class F_PM_3201 : DockPanelBase
  27. {
  28. #region 成员变量
  29. // 窗体的单例模式
  30. private static Dictionary<int, F_PM_3201> _dicInstance;
  31. // 当前工序ID
  32. private int _currentProcedureID = 0;
  33. // 最后选择行
  34. private int _selecedRow;
  35. // 窗体显示的Title
  36. private string _fromTitle;
  37. #endregion
  38. #region 构造函数
  39. public F_PM_3201()
  40. {
  41. InitializeComponent();
  42. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  43. //编辑
  44. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  45. //自动适应列宽
  46. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  47. //关闭
  48. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  49. //查询
  50. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  51. //清空条件
  52. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  53. //查询条件
  54. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  55. this.Text = _fromTitle;
  56. }
  57. #endregion
  58. #region 单例模式
  59. /// <summary>
  60. /// 一个工序ID有一个单例,防止重复创建窗体
  61. /// </summary>
  62. /// <param name="procedureID">工序ID</param>
  63. /// <returns></returns>
  64. public static F_PM_3201 Instance(int procedureID, string fromTitle)
  65. {
  66. F_PM_3201 fInstance = null;
  67. if (_dicInstance == null)
  68. {
  69. _dicInstance = new Dictionary<int, F_PM_3201>();
  70. fInstance = new F_PM_3201();
  71. _dicInstance.Add(procedureID, fInstance);
  72. }
  73. else if (_dicInstance.ContainsKey(procedureID))
  74. {
  75. fInstance = _dicInstance[procedureID];
  76. }
  77. else
  78. {
  79. fInstance = new F_PM_3201();
  80. _dicInstance.Add(procedureID, fInstance);
  81. }
  82. fInstance._currentProcedureID = procedureID;
  83. fInstance._fromTitle = fromTitle;
  84. fInstance.Text = fromTitle;
  85. return fInstance;
  86. }
  87. #endregion
  88. #region 事件
  89. /// <summary>
  90. /// 窗体加载事件
  91. /// </summary>
  92. /// <param name="sender"></param>
  93. /// <param name="e"></param>
  94. private void F_PM_3201_Load(object sender, System.EventArgs e)
  95. {
  96. try
  97. {
  98. // 加载权限
  99. FormPermissionManager.FormPermissionControl(this.Name, this,
  100. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  101. this.tsbtnAdd.Visible = true;
  102. // 设置表格不自动创建列
  103. this.dgvProduction.AutoGenerateColumns = false;
  104. // 初始化时间控件为当前日期
  105. this.dtpStartTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  106. this.dtpEndTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddDays(1).AddMinutes(-1);
  107. // 设置ToolStripButton状态
  108. this.SetToolStripButtonEnable();
  109. #region 设置下拉列表框的数据源
  110. this.cobKilnName.DataSource = GetMSTKilnInfo();
  111. this.cobKilnName.DisplayMember = "KilnName";
  112. this.cobKilnName.ValueMember = "KilnCode";
  113. this.cobKilnCarPosition.DataSource = GetMSTKilnCarPositionInfo();
  114. this.cobKilnCarPosition.DisplayMember = "DictionaryValue";
  115. this.cobKilnCarPosition.ValueMember = "DictionaryID";
  116. #endregion
  117. }
  118. catch (Exception ex)
  119. {
  120. // 对异常进行共通处理
  121. ExceptionManager.HandleEventException(this.ToString(),
  122. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  123. }
  124. }
  125. /// <summary>
  126. /// 窗体关闭事件
  127. /// </summary>
  128. /// <param name="sender"></param>
  129. /// <param name="e"></param>
  130. private void F_PM_3201_FormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e)
  131. {
  132. _dicInstance = null;
  133. }
  134. /// <summary>
  135. /// 自动适应列宽
  136. /// </summary>
  137. /// <param name="sender"></param>
  138. /// <param name="e"></param>
  139. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  140. {
  141. this.dgvProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  142. this.dgvDefect.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  143. }
  144. /// <summary>
  145. /// 清空条件按钮事件
  146. /// </summary>
  147. /// <param name="sender"></param>
  148. /// <param name="e"></param>
  149. private void btnClearCondition_Click(object sender, EventArgs e)
  150. {
  151. this.txtBarCode.Text = string.Empty;
  152. this.txtGoodsCode.Text = string.Empty;
  153. this.txtGoodsName.Text = string.Empty;
  154. this.txtUserCode.Text = string.Empty;
  155. this.scbOrganization.ClearValue();
  156. //this.txtRemarks.Text = string.Empty;
  157. this.scbGoodsType.ClearValue();
  158. this.dtpStartTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  159. this.dtpEndTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddDays(1).AddMinutes(-1);
  160. this.cobKilnName.SelectedIndex = Constant.INT_IS_ZERO;
  161. this.txtKilnCarName.Text = string.Empty;
  162. this.cobKilnCarPosition.SelectedIndex = Constant.INT_IS_ZERO;
  163. }
  164. /// <summary>
  165. /// 查询按钮事件
  166. /// </summary>
  167. /// <param name="sender"></param>
  168. /// <param name="e"></param>
  169. private void btnSearch_Click(object sender, EventArgs e)
  170. {
  171. try
  172. {
  173. // 记录当前选中行
  174. int selectRowIndex = this._selecedRow;
  175. // 异步处理
  176. this.btnSearch.Enabled = false;
  177. this.btnClearCondition.Enabled = false;
  178. SearchProductionDataEntity requestEntity = CreatesearchProductionDataRequestEntity();
  179. DataTable dtProductionData = (DataTable)DoAsync(new AsyncMethod(() =>
  180. {
  181. return PMModuleProxy.Service.GetProductionData(requestEntity);
  182. }));
  183. DataSet dsProductionData = new DataSet();
  184. dsProductionData.Tables.Add(dtProductionData);
  185. this.btnSearch.Enabled = true;
  186. this.btnClearCondition.Enabled = true;
  187. if (dsProductionData != null)
  188. {
  189. base.DataSource = dsProductionData;
  190. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  191. {
  192. tsbtnEdit.Enabled = true;
  193. this.dgvProduction.DataSource = this.DataSource.Tables[0];
  194. selectRowIndex = 0;
  195. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  196. {
  197. tsbtnEdit.Enabled = false;
  198. this.dgvDefect.DataSource = null;
  199. // 提示未查找到数据
  200. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  201. MessageBoxButtons.OK, MessageBoxIcon.Information);
  202. }
  203. else
  204. {
  205. if (selectRowIndex >= Constant.INT_IS_ZERO)
  206. {
  207. if (selectRowIndex >= dsProductionData.Tables[0].Rows.Count)
  208. {
  209. this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Selected = true;
  210. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Cells["GoodsCode"];
  211. }
  212. else
  213. {
  214. this.dgvProduction.Rows[selectRowIndex].Selected = true;
  215. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[selectRowIndex].Cells["GoodsCode"];
  216. }
  217. }
  218. }
  219. }
  220. }
  221. }
  222. catch (Exception ex)
  223. {
  224. this.btnSearch.Enabled = true;
  225. this.btnClearCondition.Enabled = true;
  226. // 对异常进行共通处理
  227. ExceptionManager.HandleEventException(this.ToString(),
  228. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  229. }
  230. }
  231. /// <summary>
  232. /// 关闭按钮事件
  233. /// </summary>
  234. /// <param name="sender"></param>
  235. /// <param name="e"></param>
  236. private void tsbtnClose_Click(object sender, EventArgs e)
  237. {
  238. this.Close();
  239. }
  240. /// <summary>
  241. /// 新建按钮事件
  242. /// </summary>
  243. /// <param name="sender"></param>
  244. /// <param name="e"></param>
  245. private void tsbtnAdd_Click(object sender, EventArgs e)
  246. {
  247. try
  248. {
  249. F_PM_3202 frmPM3202 = new F_PM_3202(_currentProcedureID, _fromTitle);
  250. DialogResult dialogResult = frmPM3202.ShowDialog();
  251. // 重新加载GridView
  252. if (dialogResult == DialogResult.OK)
  253. {
  254. SearchProductionDataEntity requestEntity = CreatesearchProductionDataRequestEntity();
  255. DataTable dtProductionData = (DataTable)DoAsync(new AsyncMethod(() =>
  256. {
  257. return PMModuleProxy.Service.GetProductionData(requestEntity);
  258. }));
  259. if (dtProductionData != null && dtProductionData.Rows.Count > Constant.INT_IS_ZERO)
  260. {
  261. this.dgvProduction.DataSource = null;
  262. this.dgvProduction.DataSource = dtProductionData;
  263. // 设置ToolStripButton按钮状态
  264. this.SetToolStripButtonEnable();
  265. this.dgvProduction.ReadOnly = true;
  266. }
  267. }
  268. }
  269. catch (Exception ex)
  270. {
  271. // 对异常进行共通处理
  272. ExceptionManager.HandleEventException(this.ToString(),
  273. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  274. }
  275. }
  276. /// <summary>
  277. /// 数据表格选定项改变事件
  278. /// </summary>
  279. /// <param name="sender"></param>
  280. /// <param name="e"></param>
  281. private void dgvProduction_SelectionChanged(object sender, EventArgs e)
  282. {
  283. try
  284. {
  285. if (this.dgvProduction.CurrentCell != null)
  286. {
  287. if (!this.txtBarCode.ReadOnly)
  288. {
  289. this._selecedRow = this.dgvProduction.CurrentCell.RowIndex;
  290. this.dgvDefect.DataSource = null;
  291. int ProductionDataID = Convert.ToInt32(this.dgvProduction.Rows[_selecedRow].Cells["ProductionDataID"].Value.ToString());
  292. DataSet dsProductionDefect = (DataSet)DoAsync(new AsyncMethod(() =>
  293. {
  294. return PMModuleProxy.Service.GetProductionDefectByProductionDataID(ProductionDataID);
  295. }));
  296. if (dsProductionDefect != null && dsProductionDefect.Tables.Count > Constant.INT_IS_ZERO
  297. && dsProductionDefect.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  298. {
  299. this.dgvDefect.DataSource = dsProductionDefect.Tables[0];
  300. }
  301. }
  302. }
  303. }
  304. catch (Exception ex)
  305. {
  306. // 对异常进行共通处理
  307. ExceptionManager.HandleEventException(this.ToString(),
  308. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  309. }
  310. }
  311. /// <summary>
  312. /// 编辑按钮事件
  313. /// </summary>
  314. /// <param name="sender"></param>
  315. /// <param name="e"></param>
  316. private void tsbtnEdit_Click(object sender, EventArgs e)
  317. {
  318. try
  319. {
  320. if (this.dgvProduction.CurrentRow != null)
  321. {
  322. int ProductionDataID = Convert.ToInt32(this.dgvProduction.CurrentRow.Cells["ProductionDataID"].Value);
  323. string BarCode = this.dgvProduction.CurrentRow.Cells["BarCode"].Value.ToString();
  324. int CompleteProcedureID = (int)DoAsync(new AsyncMethod(() =>
  325. {
  326. return PMModuleProxy.Service.GetCompleteProcedureID(BarCode);
  327. }));
  328. bool isView = true;
  329. if (CompleteProcedureID != -Constant.INT_IS_ONE && CompleteProcedureID == this._currentProcedureID)
  330. {
  331. // 尽管等于当前工序,但是如果该条码又插入了一条生产数据,在编辑此数据时,也应该为只读,即重烧后添加的生产数据,编辑上一次生产数据ID
  332. int CompleteProductionDataID = (int)DoAsync(new AsyncMethod(() =>
  333. {
  334. return PMModuleProxy.Service.GetCompleteProductionDataID(BarCode);
  335. }));
  336. if (ProductionDataID == CompleteProductionDataID)
  337. {
  338. //是否己报损,如果已经报损也是查看记录
  339. //DataSet dsReturn = (DataSet)DoAsync(new AsyncMethod(() =>
  340. //{
  341. // return PMModuleProxy.Service.GetSubstandardInfo(BarCode);
  342. //}));
  343. //if (dsReturn != null && dsReturn.Tables[0].Rows.Count > 0) //有报损记录
  344. //{
  345. // if (this.dgvProduction.CurrentRow.Cells["GoodsGrade"].Value.ToString() != "次品")
  346. // {
  347. // isView = true;
  348. // }
  349. // else
  350. // {
  351. // isView = false;
  352. // }
  353. //}
  354. //else
  355. //{
  356. // isView = false;
  357. //}
  358. //if(!isView)
  359. //{
  360. int auditstatus = (int)DoAsync(new AsyncMethod(() =>
  361. {
  362. return PMModuleProxy.Service.CheckScrapProduct(BarCode);
  363. }));
  364. if (auditstatus != -100)
  365. {
  366. isView = true;
  367. }
  368. else
  369. {
  370. isView = false;
  371. }
  372. // }
  373. }
  374. }
  375. F_PM_3202 frmPM3202 = new F_PM_3202(_currentProcedureID, _fromTitle, ProductionDataID, isView);
  376. DialogResult dialogResult = frmPM3202.ShowDialog();
  377. // 重新加载GridView
  378. if (dialogResult == DialogResult.OK)
  379. {
  380. SearchProductionDataEntity requestEntity = CreatesearchProductionDataRequestEntity();
  381. DataTable dtProductionData = (DataTable)DoAsync(new AsyncMethod(() =>
  382. {
  383. return PMModuleProxy.Service.GetProductionData(requestEntity);
  384. }));
  385. if (dtProductionData != null && dtProductionData.Rows.Count > Constant.INT_IS_ZERO)
  386. {
  387. this.dgvProduction.DataSource = null;
  388. this.dgvProduction.DataSource = dtProductionData;
  389. // 设置ToolStripButton按钮状态
  390. this.SetToolStripButtonEnable();
  391. this.dgvProduction.ReadOnly = true;
  392. }
  393. }
  394. }
  395. }
  396. catch (Exception ex)
  397. {
  398. // 对异常进行共通处理
  399. ExceptionManager.HandleEventException(this.ToString(),
  400. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  401. }
  402. }
  403. #endregion
  404. #region 私有方法
  405. /// <summary>
  406. /// 设置工具按钮的可用状态
  407. /// </summary>
  408. private void SetToolStripButtonEnable()
  409. {
  410. if (this.dgvProduction.CurrentCell != null)
  411. {
  412. this.tsbtnEdit.Enabled = true;
  413. }
  414. else
  415. {
  416. this.tsbtnEdit.Enabled = false;
  417. }
  418. }
  419. /// <summary>
  420. /// 搜索条件
  421. /// </summary>
  422. /// <returns></returns>
  423. private SearchProductionDataEntity CreatesearchProductionDataRequestEntity()
  424. {
  425. SearchProductionDataEntity result = new SearchProductionDataEntity();
  426. result.BarCode = this.txtBarCode.Text.Trim();
  427. result.GoodsCode = this.txtGoodsCode.Text.Trim();
  428. result.GoodsName = this.txtGoodsName.Text.Trim();
  429. result.UserCode = this.txtUserCode.Text.Trim();
  430. result.OrganizationID = this.scbOrganization.SearchedPKMember;
  431. result.Remarks = "";
  432. // this.txtRemarks.Text.Trim();
  433. //object[] objRework = this.statusIsReworked.SelectedValues;
  434. //string Rework = "";
  435. //for (int i = 0; i < objRework.Length; i++)
  436. //{
  437. // Rework += objRework[i] + ",";
  438. //}
  439. //Rework = Rework.TrimEnd(',');
  440. //result.IsRework = Rework;
  441. result.BeginDate = this.dtpStartTime.Value;
  442. result.EndDate = this.dtpEndTime.Value;
  443. result.ProcedureID = _currentProcedureID;
  444. if (this.cobKilnName.SelectedValue != null
  445. && !Constant.CBO_SELECT_ALL_VALUE.ToString().Equals(this.cobKilnName.SelectedValue.ToString()))
  446. {
  447. result.KilnCode = this.cobKilnName.SelectedValue.ToString();
  448. }
  449. result.KilnCarCode = this.txtKilnCarName.Text.Trim();
  450. if (this.cobKilnCarPosition.SelectedValue != null
  451. && !Constant.CBO_SELECT_ALL_VALUE.ToString().Equals(this.cobKilnCarPosition.SelectedValue.ToString()))
  452. {
  453. result.KilnCarPosition = Convert.ToInt32(this.cobKilnCarPosition.SelectedValue);
  454. }
  455. result.GoodsTypeCode = scbGoodsType.SearchedValue + "";
  456. return result;
  457. }
  458. /// <summary>
  459. /// 获取窑炉字典信息
  460. /// </summary>
  461. /// <returns></returns>
  462. private DataTable GetMSTKilnInfo()
  463. {
  464. DataSet dsKilnInfo = (DataSet)DoAsync(new AsyncMethod(() =>
  465. {
  466. byte byFlage = Convert.ToByte(Constant.ValueFlag.Invalid);
  467. return SystemModuleProxy.Service.GetKilnData(byFlage);
  468. }));
  469. DataTable dtKilnInfo = dsKilnInfo.Tables[Constant.INT_IS_ZERO];
  470. DataRow newRowDic = dtKilnInfo.NewRow();
  471. newRowDic["KilnID"] = Constant.CBO_SELECT_ALL_VALUE;
  472. newRowDic["KilnCode"] = Constant.CBO_SELECT_ALL_VALUE;
  473. newRowDic["KilnName"] = Constant.CBO_SELECT_ALL_NAME;
  474. dtKilnInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  475. return dtKilnInfo;
  476. }
  477. /// <summary>
  478. /// 获取窑车位置字典表数据
  479. /// </summary>
  480. /// <returns></returns>
  481. public DataTable GetMSTKilnCarPositionInfo()
  482. {
  483. DataTable dtDicInfo = (DataTable)DoAsync(new AsyncMethod(() =>
  484. {
  485. return CommonModuleProxy.Service.GetDataDictionaryByType(Constant.TPC_TPC003);
  486. }));
  487. DataRow newRowDic = dtDicInfo.NewRow();
  488. newRowDic["DictionaryID"] = Constant.CBO_SELECT_ALL_VALUE;
  489. newRowDic["DictionaryValue"] = Constant.CBO_SELECT_ALL_NAME;
  490. dtDicInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  491. return dtDicInfo;
  492. }
  493. #endregion
  494. }
  495. }