F_PM_0501.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_0501.cs
  5. * 2.功能描述:装窑车计件一览
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2014/09/23 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;
  19. using Dongke.IBOSS.PRD.WCF.DataModels.PMModule;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  22. namespace Dongke.IBOSS.PRD.Client.PMModule
  23. {
  24. /// <summary>
  25. /// 装窑车计件一览
  26. /// </summary>
  27. public partial class F_PM_0501 : DockPanelBase
  28. {
  29. #region 成员变量
  30. // 窗体的单例模式
  31. private static Dictionary<int, F_PM_0501> _dicInstance;
  32. // 当前工序ID
  33. private int _currentProcedureID = Constant.INT_IS_ZERO;
  34. // 最后选择行
  35. private int _selecedRow;
  36. // 窗体显示的Title
  37. private string _fromTitle;
  38. #endregion
  39. #region 构造函数
  40. /// <summary>
  41. /// 构造函数
  42. /// </summary>
  43. public F_PM_0501()
  44. {
  45. InitializeComponent();
  46. this.SetFromTitleInfo();
  47. }
  48. #endregion
  49. #region 单例模式
  50. /// <summary>
  51. /// 一个工序ID有一个单例,防止重复创建窗体
  52. /// </summary>
  53. /// <param name="procedureID">工序ID</param>
  54. /// <returns></returns>
  55. public static F_PM_0501 Instance(int procedureID, string fromTitle)
  56. {
  57. F_PM_0501 fInstance = null;
  58. if (_dicInstance == null)
  59. {
  60. _dicInstance = new Dictionary<int, F_PM_0501>();
  61. fInstance = new F_PM_0501();
  62. _dicInstance.Add(procedureID, fInstance);
  63. }
  64. else if (_dicInstance.ContainsKey(procedureID))
  65. {
  66. fInstance = _dicInstance[procedureID];
  67. }
  68. else
  69. {
  70. fInstance = new F_PM_0501();
  71. _dicInstance.Add(procedureID, fInstance);
  72. }
  73. fInstance._currentProcedureID = procedureID;
  74. fInstance._fromTitle = fromTitle;
  75. fInstance.Text = fromTitle;
  76. return fInstance;
  77. }
  78. #endregion
  79. #region 事件
  80. /// <summary>
  81. /// 窗体加载事件
  82. /// </summary>
  83. /// <param name="sender"></param>
  84. /// <param name="e"></param>
  85. private void F_PM_0501_Load(object sender, System.EventArgs e)
  86. {
  87. try
  88. {
  89. // 加载权限
  90. FormPermissionManager.FormPermissionControl(this.Name, this,
  91. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  92. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  93. // 设置表格不自动创建列
  94. this.dgvProduction.AutoGenerateColumns = false;
  95. #region 设置下拉列表框的数据源
  96. this.cobKilnName.DataSource = GetMSTKilnInfo();
  97. this.cobKilnName.DisplayMember = "KilnName";
  98. this.cobKilnName.ValueMember = "KilnCode";
  99. this.cobKilnCarPosition.DataSource = GetMSTKilnCarPositionInfo();
  100. this.cobKilnCarPosition.DisplayMember = "DictionaryValue";
  101. this.cobKilnCarPosition.ValueMember = "DictionaryID";
  102. #endregion
  103. // 初始化时间控件为当前日期
  104. this.dtpStartTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  105. this.dtpEndTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddDays(1).AddMinutes(-1);
  106. // 设置ToolStripButton状态
  107. this.SetToolStripButtonEnable();
  108. // 获取工序明细数据
  109. ProcedureEntity procedureDataEntity = (ProcedureEntity)DoAsync(new AsyncMethod(() =>
  110. {
  111. return PMModuleProxy.Service.GetProcedureDataEntityByID(_currentProcedureID);
  112. }));
  113. if (procedureDataEntity != null && procedureDataEntity.ModelType == 6)
  114. {
  115. this.tsbtnUnDoLoading.Visible = false;
  116. }
  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_0501_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. }
  143. /// <summary>
  144. /// 清空条件按钮事件
  145. /// </summary>
  146. /// <param name="sender"></param>
  147. /// <param name="e"></param>
  148. private void btnClearCondition_Click(object sender, EventArgs e)
  149. {
  150. this.txtBarCode.Text = string.Empty;
  151. this.txtGoodsCode.Text = string.Empty;
  152. this.txtGoodsName.Text = string.Empty;
  153. this.txtUserCode.Text = string.Empty;
  154. this.scbOrganization.ClearValue();
  155. //this.txtRemarks.Text = string.Empty;
  156. this.scbGoodsType.ClearValue();
  157. this.dtpStartTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  158. //this.dtpEndTime.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. this.dgvProduction.DataSource = this.DataSource.Tables[Constant.INT_IS_ZERO];
  193. if (this.DataSource.Tables[Constant.INT_IS_ZERO].Rows.Count <= Constant.INT_IS_ZERO)
  194. {
  195. // 提示未查找到数据
  196. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  197. MessageBoxButtons.OK, MessageBoxIcon.Information);
  198. }
  199. else
  200. {
  201. if (selectRowIndex >= Constant.INT_IS_ZERO)
  202. {
  203. if (selectRowIndex >= dsProductionData.Tables[0].Rows.Count)
  204. {
  205. this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Selected = true;
  206. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Cells["GoodsCode"];
  207. }
  208. else
  209. {
  210. this.dgvProduction.Rows[selectRowIndex].Selected = true;
  211. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[selectRowIndex].Cells["GoodsCode"];
  212. }
  213. }
  214. }
  215. }
  216. }
  217. }
  218. catch (Exception ex)
  219. {
  220. this.btnSearch.Enabled = true;
  221. this.btnClearCondition.Enabled = true;
  222. // 对异常进行共通处理
  223. ExceptionManager.HandleEventException(this.ToString(),
  224. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  225. }
  226. }
  227. /// <summary>
  228. /// 关闭按钮事件
  229. /// </summary>
  230. /// <param name="sender"></param>
  231. /// <param name="e"></param>
  232. private void tsbtnClose_Click(object sender, EventArgs e)
  233. {
  234. this.Close();
  235. }
  236. /// <summary>
  237. /// 新建按钮事件
  238. /// </summary>
  239. /// <param name="sender"></param>
  240. /// <param name="e"></param>
  241. private void tsbtnAdd_Click(object sender, EventArgs e)
  242. {
  243. try
  244. {
  245. F_PM_0502 frmPM0502 = new F_PM_0502(_currentProcedureID, _fromTitle);
  246. DialogResult dialogResult = frmPM0502.ShowDialog();
  247. // 重新加载GridView
  248. if (dialogResult == DialogResult.OK)
  249. {
  250. SearchProductionDataEntity requestEntity = CreatesearchProductionDataRequestEntity();
  251. DataTable dtProductionData = (DataTable)DoAsync(new AsyncMethod(() =>
  252. {
  253. return PMModuleProxy.Service.GetProductionData(requestEntity);
  254. }));
  255. if (dtProductionData != null && dtProductionData.Rows.Count > Constant.INT_IS_ZERO)
  256. {
  257. this.dgvProduction.DataSource = null;
  258. this.dgvProduction.DataSource = dtProductionData;
  259. // 设置ToolStripButton按钮状态
  260. this.SetToolStripButtonEnable();
  261. this.dgvProduction.ReadOnly = true;
  262. }
  263. }
  264. }
  265. catch (Exception ex)
  266. {
  267. // 对异常进行共通处理
  268. ExceptionManager.HandleEventException(this.ToString(),
  269. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  270. }
  271. }
  272. /// <summary>
  273. ///
  274. /// </summary>
  275. /// <param name="sender"></param>
  276. /// <param name="e"></param>
  277. private void tsbtnUnDoLoading_Click(object sender, EventArgs e)
  278. {
  279. try
  280. {
  281. string barcode = "";
  282. if (this.dgvProduction.CurrentCell != null)
  283. {
  284. barcode = this.dgvProduction.CurrentRow.Cells["BarCode"].Value.ToString();
  285. }
  286. F_PM_0503 frmPM0503 = new F_PM_0503(_currentProcedureID, barcode);
  287. DialogResult dialogResult = frmPM0503.ShowDialog();
  288. // 重新加载GridView
  289. if (dialogResult == DialogResult.OK)
  290. {
  291. //this.btnSearch_Click(null, null);
  292. }
  293. }
  294. catch (Exception ex)
  295. {
  296. // 对异常进行共通处理
  297. ExceptionManager.HandleEventException(this.ToString(),
  298. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  299. }
  300. }
  301. #endregion
  302. #region 私有方法
  303. /// <summary>
  304. /// 设置窗体按钮的文本信息
  305. /// </summary>
  306. private void SetFromTitleInfo()
  307. {
  308. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  309. // 撤销装车
  310. this.tsbtnUnDoLoading.Text = ButtonText.TSBTN_UNDOLOADING;
  311. //自动适应列宽
  312. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  313. //关闭
  314. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  315. //查询
  316. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  317. //清空条件
  318. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  319. //查询条件
  320. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  321. this.Text = _fromTitle;
  322. }
  323. /// <summary>
  324. /// 获取窑炉字典信息
  325. /// </summary>
  326. /// <returns></returns>
  327. private DataTable GetMSTKilnInfo()
  328. {
  329. DataSet dsKilnInfo = (DataSet)DoAsync(new AsyncMethod(() =>
  330. {
  331. byte byFlage = Convert.ToByte(Constant.ValueFlag.Invalid);
  332. return SystemModuleProxy.Service.GetKilnData(byFlage);
  333. }));
  334. DataTable dtKilnInfo = dsKilnInfo.Tables[Constant.INT_IS_ZERO];
  335. DataRow newRowDic = dtKilnInfo.NewRow();
  336. newRowDic["KilnID"] = Constant.CBO_SELECT_ALL_VALUE;
  337. newRowDic["KilnCode"] = Constant.CBO_SELECT_ALL_VALUE;
  338. newRowDic["KilnName"] = Constant.CBO_SELECT_ALL_NAME;
  339. dtKilnInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  340. return dtKilnInfo;
  341. }
  342. /// <summary>
  343. /// 获取窑车位置字典表数据
  344. /// </summary>
  345. /// <returns></returns>
  346. public DataTable GetMSTKilnCarPositionInfo()
  347. {
  348. DataTable dtDicInfo = (DataTable)DoAsync(new AsyncMethod(() =>
  349. {
  350. return CommonModuleProxy.Service.GetDataDictionaryByType(Constant.TPC_TPC003);
  351. }));
  352. DataRow newRowDic = dtDicInfo.NewRow();
  353. newRowDic["DictionaryID"] = Constant.CBO_SELECT_ALL_VALUE;
  354. newRowDic["DictionaryValue"] = Constant.CBO_SELECT_ALL_NAME;
  355. dtDicInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  356. return dtDicInfo;
  357. }
  358. /// <summary>
  359. /// 设置工具按钮的可用状态
  360. /// </summary>
  361. private void SetToolStripButtonEnable()
  362. {
  363. if (this.dgvProduction.CurrentCell != null)
  364. {
  365. //this.tsbtnCancelLoad.Enabled = true;
  366. }
  367. else
  368. {
  369. //this.tsbtnCancelLoad.Enabled = false;
  370. }
  371. }
  372. /// <summary>
  373. /// 搜索条件
  374. /// </summary>
  375. /// <returns></returns>
  376. private SearchProductionDataEntity CreatesearchProductionDataRequestEntity()
  377. {
  378. SearchProductionDataEntity result = new SearchProductionDataEntity();
  379. result.BarCode = this.txtBarCode.Text.Trim();
  380. result.GoodsCode = this.txtGoodsCode.Text.Trim();
  381. result.GoodsName = this.txtGoodsName.Text.Trim();
  382. result.UserCode = this.txtUserCode.Text.Trim();
  383. result.OrganizationID = this.scbOrganization.SearchedPKMember;
  384. result.Remarks = "";// this.txtRemarks.Text.Trim();
  385. //object[] objRework = this.statusIsReworked.SelectedValues;
  386. //string Rework = "";
  387. //for (int i = 0; i < objRework.Length; i++)
  388. //{
  389. // Rework += objRework[i] + ",";
  390. //}
  391. //Rework = Rework.TrimEnd(',');
  392. //result.IsRework = Rework;
  393. result.BeginDate = this.dtpStartTime.Value;
  394. result.EndDate = this.dtpEndTime.Value;//.AddDays(1);
  395. result.ProcedureID = _currentProcedureID;
  396. if (this.cobKilnName.SelectedValue != null
  397. && !Constant.CBO_SELECT_ALL_VALUE.ToString().Equals(this.cobKilnName.SelectedValue.ToString()))
  398. {
  399. result.KilnCode = this.cobKilnName.SelectedValue.ToString();
  400. }
  401. result.KilnCarCode = this.txtKilnCarName.Text.Trim();
  402. if (this.cobKilnCarPosition.SelectedValue != null
  403. && !Constant.CBO_SELECT_ALL_VALUE.ToString().Equals(this.cobKilnCarPosition.SelectedValue.ToString()))
  404. {
  405. result.KilnCarPosition = Convert.ToInt32(this.cobKilnCarPosition.SelectedValue);
  406. }
  407. result.GoodsTypeCode = this.scbGoodsType.SearchedValue + "";
  408. return result;
  409. }
  410. #endregion
  411. #region 漏扫补件
  412. private void tsbReLoad_Click(object sender, EventArgs e)
  413. {
  414. try
  415. {
  416. F_PM_0504 frmPM0502 = new F_PM_0504(_currentProcedureID, _fromTitle);
  417. DialogResult dialogResult = frmPM0502.ShowDialog();
  418. }
  419. catch (Exception ex)
  420. {
  421. // 对异常进行共通处理
  422. ExceptionManager.HandleEventException(this.ToString(),
  423. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  424. }
  425. }
  426. #endregion
  427. }
  428. }