F_PM_3401.cs 16 KB

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