F_PM_3201.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  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. this.cobworkshop.SelectedIndex = Constant.INT_IS_NEGATIE_ONE;
  164. }
  165. /// <summary>
  166. /// 查询按钮事件
  167. /// </summary>
  168. /// <param name="sender"></param>
  169. /// <param name="e"></param>
  170. private void btnSearch_Click(object sender, EventArgs e)
  171. {
  172. try
  173. {
  174. // 记录当前选中行
  175. int selectRowIndex = this._selecedRow;
  176. // 异步处理
  177. this.btnSearch.Enabled = false;
  178. this.btnClearCondition.Enabled = false;
  179. SearchProductionDataEntity requestEntity = CreatesearchProductionDataRequestEntity();
  180. DataTable dtProductionData = (DataTable)DoAsync(new AsyncMethod(() =>
  181. {
  182. return PMModuleProxy.Service.GetProductionData(requestEntity);
  183. }));
  184. DataSet dsProductionData = new DataSet();
  185. dsProductionData.Tables.Add(dtProductionData);
  186. this.btnSearch.Enabled = true;
  187. this.btnClearCondition.Enabled = true;
  188. if (dsProductionData != null)
  189. {
  190. base.DataSource = dsProductionData;
  191. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  192. {
  193. tsbtnEdit.Enabled = true;
  194. this.dgvProduction.DataSource = this.DataSource.Tables[0];
  195. selectRowIndex = 0;
  196. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  197. {
  198. tsbtnEdit.Enabled = false;
  199. this.dgvDefect.DataSource = null;
  200. // 提示未查找到数据
  201. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  202. MessageBoxButtons.OK, MessageBoxIcon.Information);
  203. }
  204. else
  205. {
  206. if (selectRowIndex >= Constant.INT_IS_ZERO)
  207. {
  208. if (selectRowIndex >= dsProductionData.Tables[0].Rows.Count)
  209. {
  210. this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Selected = true;
  211. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Cells["GoodsCode"];
  212. }
  213. else
  214. {
  215. this.dgvProduction.Rows[selectRowIndex].Selected = true;
  216. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[selectRowIndex].Cells["GoodsCode"];
  217. }
  218. }
  219. }
  220. }
  221. }
  222. }
  223. catch (Exception ex)
  224. {
  225. this.btnSearch.Enabled = true;
  226. this.btnClearCondition.Enabled = true;
  227. // 对异常进行共通处理
  228. ExceptionManager.HandleEventException(this.ToString(),
  229. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  230. }
  231. }
  232. /// <summary>
  233. /// 关闭按钮事件
  234. /// </summary>
  235. /// <param name="sender"></param>
  236. /// <param name="e"></param>
  237. private void tsbtnClose_Click(object sender, EventArgs e)
  238. {
  239. this.Close();
  240. }
  241. /// <summary>
  242. /// 新建按钮事件
  243. /// </summary>
  244. /// <param name="sender"></param>
  245. /// <param name="e"></param>
  246. private void tsbtnAdd_Click(object sender, EventArgs e)
  247. {
  248. try
  249. {
  250. F_PM_3202 frmPM3202 = new F_PM_3202(_currentProcedureID, _fromTitle);
  251. DialogResult dialogResult = frmPM3202.ShowDialog();
  252. // 重新加载GridView
  253. if (dialogResult == DialogResult.OK)
  254. {
  255. SearchProductionDataEntity requestEntity = CreatesearchProductionDataRequestEntity();
  256. DataTable dtProductionData = (DataTable)DoAsync(new AsyncMethod(() =>
  257. {
  258. return PMModuleProxy.Service.GetProductionData(requestEntity);
  259. }));
  260. if (dtProductionData != null && dtProductionData.Rows.Count > Constant.INT_IS_ZERO)
  261. {
  262. this.dgvProduction.DataSource = null;
  263. this.dgvProduction.DataSource = dtProductionData;
  264. // 设置ToolStripButton按钮状态
  265. this.SetToolStripButtonEnable();
  266. this.dgvProduction.ReadOnly = true;
  267. }
  268. }
  269. }
  270. catch (Exception ex)
  271. {
  272. // 对异常进行共通处理
  273. ExceptionManager.HandleEventException(this.ToString(),
  274. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  275. }
  276. }
  277. /// <summary>
  278. /// 数据表格选定项改变事件
  279. /// </summary>
  280. /// <param name="sender"></param>
  281. /// <param name="e"></param>
  282. private void dgvProduction_SelectionChanged(object sender, EventArgs e)
  283. {
  284. try
  285. {
  286. if (this.dgvProduction.CurrentCell != null)
  287. {
  288. if (!this.txtBarCode.ReadOnly)
  289. {
  290. this._selecedRow = this.dgvProduction.CurrentCell.RowIndex;
  291. this.dgvDefect.DataSource = null;
  292. string flag = this.dgvProduction.Rows[_selecedRow].Cells["ProductionDataID"].Value.ToString();
  293. if (flag != null && flag != "")
  294. {
  295. int ProductionDataID = Convert.ToInt32(this.dgvProduction.Rows[_selecedRow].Cells["ProductionDataID"].Value.ToString());
  296. DataSet dsProductionDefect = (DataSet)DoAsync(new AsyncMethod(() =>
  297. {
  298. return PMModuleProxy.Service.GetProductionDefectByProductionDataID(ProductionDataID);
  299. }));
  300. if (dsProductionDefect != null && dsProductionDefect.Tables.Count > Constant.INT_IS_ZERO
  301. && dsProductionDefect.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  302. {
  303. this.dgvDefect.DataSource = dsProductionDefect.Tables[0];
  304. }
  305. }
  306. }
  307. }
  308. }
  309. catch (Exception ex)
  310. {
  311. // 对异常进行共通处理
  312. ExceptionManager.HandleEventException(this.ToString(),
  313. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  314. }
  315. }
  316. /// <summary>
  317. /// 编辑按钮事件
  318. /// </summary>
  319. /// <param name="sender"></param>
  320. /// <param name="e"></param>
  321. private void tsbtnEdit_Click(object sender, EventArgs e)
  322. {
  323. try
  324. {
  325. if (this.dgvProduction.CurrentRow != null)
  326. {
  327. string flag = this.dgvProduction.Rows[_selecedRow].Cells["ProductionDataID"].Value.ToString();
  328. if (this.dgvProduction.CurrentRow != null && (flag != null && flag != ""))
  329. {
  330. int ProductionDataID = Convert.ToInt32(this.dgvProduction.CurrentRow.Cells["ProductionDataID"].Value);
  331. string BarCode = this.dgvProduction.CurrentRow.Cells["BarCode"].Value.ToString();
  332. int CompleteProcedureID = (int)DoAsync(new AsyncMethod(() =>
  333. {
  334. return PMModuleProxy.Service.GetCompleteProcedureID(BarCode);
  335. }));
  336. bool isView = true;
  337. if (CompleteProcedureID != -Constant.INT_IS_ONE && CompleteProcedureID == this._currentProcedureID)
  338. {
  339. // 尽管等于当前工序,但是如果该条码又插入了一条生产数据,在编辑此数据时,也应该为只读,即重烧后添加的生产数据,编辑上一次生产数据ID
  340. int CompleteProductionDataID = (int)DoAsync(new AsyncMethod(() =>
  341. {
  342. return PMModuleProxy.Service.GetCompleteProductionDataID(BarCode);
  343. }));
  344. if (ProductionDataID == CompleteProductionDataID)
  345. {
  346. //是否己报损,如果已经报损也是查看记录
  347. //DataSet dsReturn = (DataSet)DoAsync(new AsyncMethod(() =>
  348. //{
  349. // return PMModuleProxy.Service.GetSubstandardInfo(BarCode);
  350. //}));
  351. //if (dsReturn != null && dsReturn.Tables[0].Rows.Count > 0) //有报损记录
  352. //{
  353. // if (this.dgvProduction.CurrentRow.Cells["GoodsGrade"].Value.ToString() != "次品")
  354. // {
  355. // isView = true;
  356. // }
  357. // else
  358. // {
  359. // isView = false;
  360. // }
  361. //}
  362. //else
  363. //{
  364. // isView = false;
  365. //}
  366. //if(!isView)
  367. //{
  368. int auditstatus = (int)DoAsync(new AsyncMethod(() =>
  369. {
  370. return PMModuleProxy.Service.CheckScrapProduct(BarCode);
  371. }));
  372. if (auditstatus != -100)
  373. {
  374. isView = true;
  375. }
  376. else
  377. {
  378. isView = false;
  379. }
  380. // }
  381. }
  382. }
  383. F_PM_3202 frmPM3202 = new F_PM_3202(_currentProcedureID, _fromTitle, ProductionDataID, isView);
  384. DialogResult dialogResult = frmPM3202.ShowDialog();
  385. // 重新加载GridView
  386. if (dialogResult == DialogResult.OK)
  387. {
  388. SearchProductionDataEntity requestEntity = CreatesearchProductionDataRequestEntity();
  389. DataTable dtProductionData = (DataTable)DoAsync(new AsyncMethod(() =>
  390. {
  391. return PMModuleProxy.Service.GetProductionData(requestEntity);
  392. }));
  393. if (dtProductionData != null && dtProductionData.Rows.Count > Constant.INT_IS_ZERO)
  394. {
  395. this.dgvProduction.DataSource = null;
  396. this.dgvProduction.DataSource = dtProductionData;
  397. // 设置ToolStripButton按钮状态
  398. this.SetToolStripButtonEnable();
  399. this.dgvProduction.ReadOnly = true;
  400. }
  401. }
  402. }
  403. else
  404. {
  405. MessageBox.Show("无法编辑小计合计数据 请重新选择", this.Text,
  406. MessageBoxButtons.OK, MessageBoxIcon.Information);
  407. }
  408. }
  409. }
  410. catch (Exception ex)
  411. {
  412. // 对异常进行共通处理
  413. ExceptionManager.HandleEventException(this.ToString(),
  414. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  415. }
  416. }
  417. #endregion
  418. #region 私有方法
  419. /// <summary>
  420. /// 设置工具按钮的可用状态
  421. /// </summary>
  422. private void SetToolStripButtonEnable()
  423. {
  424. if (this.dgvProduction.CurrentCell != null)
  425. {
  426. this.tsbtnEdit.Enabled = true;
  427. }
  428. else
  429. {
  430. this.tsbtnEdit.Enabled = false;
  431. }
  432. }
  433. /// <summary>
  434. /// 搜索条件
  435. /// </summary>
  436. /// <returns></returns>
  437. private SearchProductionDataEntity CreatesearchProductionDataRequestEntity()
  438. {
  439. SearchProductionDataEntity result = new SearchProductionDataEntity();
  440. result.BarCode = this.txtBarCode.Text.Trim();
  441. result.GoodsCode = this.txtGoodsCode.Text.Trim();
  442. result.GoodsName = this.txtGoodsName.Text.Trim();
  443. result.UserCode = this.txtUserCode.Text.Trim();
  444. result.OrganizationID = this.scbOrganization.SearchedPKMember;
  445. // 1-3节点到3-2节点都加一个成型车间的筛选条件 250317
  446. result.Remarks = cobworkshop.Text;//暂传车间(成检部分)
  447. // this.txtRemarks.Text.Trim();
  448. //object[] objRework = this.statusIsReworked.SelectedValues;
  449. //string Rework = "";
  450. //for (int i = 0; i < objRework.Length; i++)
  451. //{
  452. // Rework += objRework[i] + ",";
  453. //}
  454. //Rework = Rework.TrimEnd(',');
  455. //result.IsRework = Rework;
  456. result.BeginDate = this.dtpStartTime.Value;
  457. result.EndDate = this.dtpEndTime.Value;
  458. result.ProcedureID = _currentProcedureID;
  459. if (this.cobKilnName.SelectedValue != null
  460. && !Constant.CBO_SELECT_ALL_VALUE.ToString().Equals(this.cobKilnName.SelectedValue.ToString()))
  461. {
  462. result.KilnCode = this.cobKilnName.SelectedValue.ToString();
  463. }
  464. result.KilnCarCode = this.txtKilnCarName.Text.Trim();
  465. if (this.cobKilnCarPosition.SelectedValue != null
  466. && !Constant.CBO_SELECT_ALL_VALUE.ToString().Equals(this.cobKilnCarPosition.SelectedValue.ToString()))
  467. {
  468. result.KilnCarPosition = Convert.ToInt32(this.cobKilnCarPosition.SelectedValue);
  469. }
  470. result.GoodsTypeCode = scbGoodsType.SearchedValue + "";
  471. return result;
  472. }
  473. /// <summary>
  474. /// 获取窑炉字典信息
  475. /// </summary>
  476. /// <returns></returns>
  477. private DataTable GetMSTKilnInfo()
  478. {
  479. DataSet dsKilnInfo = (DataSet)DoAsync(new AsyncMethod(() =>
  480. {
  481. byte byFlage = Convert.ToByte(Constant.ValueFlag.Invalid);
  482. return SystemModuleProxy.Service.GetKilnData(byFlage);
  483. }));
  484. DataTable dtKilnInfo = dsKilnInfo.Tables[Constant.INT_IS_ZERO];
  485. DataRow newRowDic = dtKilnInfo.NewRow();
  486. newRowDic["KilnID"] = Constant.CBO_SELECT_ALL_VALUE;
  487. newRowDic["KilnCode"] = Constant.CBO_SELECT_ALL_VALUE;
  488. newRowDic["KilnName"] = Constant.CBO_SELECT_ALL_NAME;
  489. dtKilnInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  490. return dtKilnInfo;
  491. }
  492. /// <summary>
  493. /// 获取窑车位置字典表数据
  494. /// </summary>
  495. /// <returns></returns>
  496. public DataTable GetMSTKilnCarPositionInfo()
  497. {
  498. DataTable dtDicInfo = (DataTable)DoAsync(new AsyncMethod(() =>
  499. {
  500. return CommonModuleProxy.Service.GetDataDictionaryByType(Constant.TPC_TPC003);
  501. }));
  502. DataRow newRowDic = dtDicInfo.NewRow();
  503. newRowDic["DictionaryID"] = Constant.CBO_SELECT_ALL_VALUE;
  504. newRowDic["DictionaryValue"] = Constant.CBO_SELECT_ALL_NAME;
  505. dtDicInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  506. return dtDicInfo;
  507. }
  508. #endregion
  509. }
  510. }