F_PM_3201.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  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. string flag = this.dgvProduction.Rows[_selecedRow].Cells["ProductionDataID"].Value.ToString();
  292. if (flag != null && flag != "")
  293. {
  294. int ProductionDataID = Convert.ToInt32(this.dgvProduction.Rows[_selecedRow].Cells["ProductionDataID"].Value.ToString());
  295. DataSet dsProductionDefect = (DataSet)DoAsync(new AsyncMethod(() =>
  296. {
  297. return PMModuleProxy.Service.GetProductionDefectByProductionDataID(ProductionDataID);
  298. }));
  299. if (dsProductionDefect != null && dsProductionDefect.Tables.Count > Constant.INT_IS_ZERO
  300. && dsProductionDefect.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  301. {
  302. this.dgvDefect.DataSource = dsProductionDefect.Tables[0];
  303. }
  304. }
  305. }
  306. }
  307. }
  308. catch (Exception ex)
  309. {
  310. // 对异常进行共通处理
  311. ExceptionManager.HandleEventException(this.ToString(),
  312. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  313. }
  314. }
  315. /// <summary>
  316. /// 编辑按钮事件
  317. /// </summary>
  318. /// <param name="sender"></param>
  319. /// <param name="e"></param>
  320. private void tsbtnEdit_Click(object sender, EventArgs e)
  321. {
  322. try
  323. {
  324. if (this.dgvProduction.CurrentRow != null)
  325. {
  326. string flag = this.dgvProduction.Rows[_selecedRow].Cells["ProductionDataID"].Value.ToString();
  327. if (this.dgvProduction.CurrentRow != null && (flag != null && flag != ""))
  328. {
  329. int ProductionDataID = Convert.ToInt32(this.dgvProduction.CurrentRow.Cells["ProductionDataID"].Value);
  330. string BarCode = this.dgvProduction.CurrentRow.Cells["BarCode"].Value.ToString();
  331. int CompleteProcedureID = (int)DoAsync(new AsyncMethod(() =>
  332. {
  333. return PMModuleProxy.Service.GetCompleteProcedureID(BarCode);
  334. }));
  335. bool isView = true;
  336. if (CompleteProcedureID != -Constant.INT_IS_ONE && CompleteProcedureID == this._currentProcedureID)
  337. {
  338. // 尽管等于当前工序,但是如果该条码又插入了一条生产数据,在编辑此数据时,也应该为只读,即重烧后添加的生产数据,编辑上一次生产数据ID
  339. int CompleteProductionDataID = (int)DoAsync(new AsyncMethod(() =>
  340. {
  341. return PMModuleProxy.Service.GetCompleteProductionDataID(BarCode);
  342. }));
  343. if (ProductionDataID == CompleteProductionDataID)
  344. {
  345. //是否己报损,如果已经报损也是查看记录
  346. //DataSet dsReturn = (DataSet)DoAsync(new AsyncMethod(() =>
  347. //{
  348. // return PMModuleProxy.Service.GetSubstandardInfo(BarCode);
  349. //}));
  350. //if (dsReturn != null && dsReturn.Tables[0].Rows.Count > 0) //有报损记录
  351. //{
  352. // if (this.dgvProduction.CurrentRow.Cells["GoodsGrade"].Value.ToString() != "次品")
  353. // {
  354. // isView = true;
  355. // }
  356. // else
  357. // {
  358. // isView = false;
  359. // }
  360. //}
  361. //else
  362. //{
  363. // isView = false;
  364. //}
  365. //if(!isView)
  366. //{
  367. int auditstatus = (int)DoAsync(new AsyncMethod(() =>
  368. {
  369. return PMModuleProxy.Service.CheckScrapProduct(BarCode);
  370. }));
  371. if (auditstatus != -100)
  372. {
  373. isView = true;
  374. }
  375. else
  376. {
  377. isView = false;
  378. }
  379. // }
  380. }
  381. }
  382. F_PM_3202 frmPM3202 = new F_PM_3202(_currentProcedureID, _fromTitle, ProductionDataID, isView);
  383. DialogResult dialogResult = frmPM3202.ShowDialog();
  384. // 重新加载GridView
  385. if (dialogResult == DialogResult.OK)
  386. {
  387. SearchProductionDataEntity requestEntity = CreatesearchProductionDataRequestEntity();
  388. DataTable dtProductionData = (DataTable)DoAsync(new AsyncMethod(() =>
  389. {
  390. return PMModuleProxy.Service.GetProductionData(requestEntity);
  391. }));
  392. if (dtProductionData != null && dtProductionData.Rows.Count > Constant.INT_IS_ZERO)
  393. {
  394. this.dgvProduction.DataSource = null;
  395. this.dgvProduction.DataSource = dtProductionData;
  396. // 设置ToolStripButton按钮状态
  397. this.SetToolStripButtonEnable();
  398. this.dgvProduction.ReadOnly = true;
  399. }
  400. }
  401. }
  402. else
  403. {
  404. MessageBox.Show("无法编辑小计合计数据 请重新选择", this.Text,
  405. MessageBoxButtons.OK, MessageBoxIcon.Information);
  406. }
  407. }
  408. }
  409. catch (Exception ex)
  410. {
  411. // 对异常进行共通处理
  412. ExceptionManager.HandleEventException(this.ToString(),
  413. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  414. }
  415. }
  416. #endregion
  417. #region 私有方法
  418. /// <summary>
  419. /// 设置工具按钮的可用状态
  420. /// </summary>
  421. private void SetToolStripButtonEnable()
  422. {
  423. if (this.dgvProduction.CurrentCell != null)
  424. {
  425. this.tsbtnEdit.Enabled = true;
  426. }
  427. else
  428. {
  429. this.tsbtnEdit.Enabled = false;
  430. }
  431. }
  432. /// <summary>
  433. /// 搜索条件
  434. /// </summary>
  435. /// <returns></returns>
  436. private SearchProductionDataEntity CreatesearchProductionDataRequestEntity()
  437. {
  438. SearchProductionDataEntity result = new SearchProductionDataEntity();
  439. result.BarCode = this.txtBarCode.Text.Trim();
  440. result.GoodsCode = this.txtGoodsCode.Text.Trim();
  441. result.GoodsName = this.txtGoodsName.Text.Trim();
  442. result.UserCode = this.txtUserCode.Text.Trim();
  443. result.OrganizationID = this.scbOrganization.SearchedPKMember;
  444. result.Remarks = "";
  445. // this.txtRemarks.Text.Trim();
  446. //object[] objRework = this.statusIsReworked.SelectedValues;
  447. //string Rework = "";
  448. //for (int i = 0; i < objRework.Length; i++)
  449. //{
  450. // Rework += objRework[i] + ",";
  451. //}
  452. //Rework = Rework.TrimEnd(',');
  453. //result.IsRework = Rework;
  454. result.BeginDate = this.dtpStartTime.Value;
  455. result.EndDate = this.dtpEndTime.Value;
  456. result.ProcedureID = _currentProcedureID;
  457. if (this.cobKilnName.SelectedValue != null
  458. && !Constant.CBO_SELECT_ALL_VALUE.ToString().Equals(this.cobKilnName.SelectedValue.ToString()))
  459. {
  460. result.KilnCode = this.cobKilnName.SelectedValue.ToString();
  461. }
  462. result.KilnCarCode = this.txtKilnCarName.Text.Trim();
  463. if (this.cobKilnCarPosition.SelectedValue != null
  464. && !Constant.CBO_SELECT_ALL_VALUE.ToString().Equals(this.cobKilnCarPosition.SelectedValue.ToString()))
  465. {
  466. result.KilnCarPosition = Convert.ToInt32(this.cobKilnCarPosition.SelectedValue);
  467. }
  468. result.GoodsTypeCode = scbGoodsType.SearchedValue + "";
  469. return result;
  470. }
  471. /// <summary>
  472. /// 获取窑炉字典信息
  473. /// </summary>
  474. /// <returns></returns>
  475. private DataTable GetMSTKilnInfo()
  476. {
  477. DataSet dsKilnInfo = (DataSet)DoAsync(new AsyncMethod(() =>
  478. {
  479. byte byFlage = Convert.ToByte(Constant.ValueFlag.Invalid);
  480. return SystemModuleProxy.Service.GetKilnData(byFlage);
  481. }));
  482. DataTable dtKilnInfo = dsKilnInfo.Tables[Constant.INT_IS_ZERO];
  483. DataRow newRowDic = dtKilnInfo.NewRow();
  484. newRowDic["KilnID"] = Constant.CBO_SELECT_ALL_VALUE;
  485. newRowDic["KilnCode"] = Constant.CBO_SELECT_ALL_VALUE;
  486. newRowDic["KilnName"] = Constant.CBO_SELECT_ALL_NAME;
  487. dtKilnInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  488. return dtKilnInfo;
  489. }
  490. /// <summary>
  491. /// 获取窑车位置字典表数据
  492. /// </summary>
  493. /// <returns></returns>
  494. public DataTable GetMSTKilnCarPositionInfo()
  495. {
  496. DataTable dtDicInfo = (DataTable)DoAsync(new AsyncMethod(() =>
  497. {
  498. return CommonModuleProxy.Service.GetDataDictionaryByType(Constant.TPC_TPC003);
  499. }));
  500. DataRow newRowDic = dtDicInfo.NewRow();
  501. newRowDic["DictionaryID"] = Constant.CBO_SELECT_ALL_VALUE;
  502. newRowDic["DictionaryValue"] = Constant.CBO_SELECT_ALL_NAME;
  503. dtDicInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  504. return dtDicInfo;
  505. }
  506. #endregion
  507. }
  508. }