F_PM_0501.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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. /// <summary>
  302. /// 梭式窑入窑按钮点击事件
  303. /// </summary>
  304. /// <param name="sender"></param>
  305. /// <param name="e"></param>
  306. private void tsbtnSKIn_Click(object sender, EventArgs e)
  307. {
  308. try
  309. {
  310. F_PM_0505 frm = new F_PM_0505();
  311. frm.ShowDialog();
  312. }
  313. catch (Exception ex)
  314. {
  315. // 对异常进行共通处理
  316. ExceptionManager.HandleEventException(this.ToString(),
  317. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  318. }
  319. }
  320. #endregion
  321. #region 私有方法
  322. /// <summary>
  323. /// 设置窗体按钮的文本信息
  324. /// </summary>
  325. private void SetFromTitleInfo()
  326. {
  327. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  328. // 撤销装车
  329. this.tsbtnUnDoLoading.Text = ButtonText.TSBTN_UNDOLOADING;
  330. //自动适应列宽
  331. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  332. //关闭
  333. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  334. //查询
  335. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  336. //清空条件
  337. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  338. //查询条件
  339. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  340. // 梭式窑入窑
  341. this.tsbtnSKIn.Text = Constant.TSBTN_SKIN;
  342. this.Text = _fromTitle;
  343. }
  344. /// <summary>
  345. /// 获取窑炉字典信息
  346. /// </summary>
  347. /// <returns></returns>
  348. private DataTable GetMSTKilnInfo()
  349. {
  350. DataSet dsKilnInfo = (DataSet)DoAsync(new AsyncMethod(() =>
  351. {
  352. byte byFlage = Convert.ToByte(Constant.ValueFlag.Invalid);
  353. return SystemModuleProxy.Service.GetKilnData(byFlage);
  354. }));
  355. DataTable dtKilnInfo = dsKilnInfo.Tables[Constant.INT_IS_ZERO];
  356. DataRow newRowDic = dtKilnInfo.NewRow();
  357. newRowDic["KilnID"] = Constant.CBO_SELECT_ALL_VALUE;
  358. newRowDic["KilnCode"] = Constant.CBO_SELECT_ALL_VALUE;
  359. newRowDic["KilnName"] = Constant.CBO_SELECT_ALL_NAME;
  360. dtKilnInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  361. return dtKilnInfo;
  362. }
  363. /// <summary>
  364. /// 获取窑车位置字典表数据
  365. /// </summary>
  366. /// <returns></returns>
  367. public DataTable GetMSTKilnCarPositionInfo()
  368. {
  369. DataTable dtDicInfo = (DataTable)DoAsync(new AsyncMethod(() =>
  370. {
  371. return CommonModuleProxy.Service.GetDataDictionaryByType(Constant.TPC_TPC003);
  372. }));
  373. DataRow newRowDic = dtDicInfo.NewRow();
  374. newRowDic["DictionaryID"] = Constant.CBO_SELECT_ALL_VALUE;
  375. newRowDic["DictionaryValue"] = Constant.CBO_SELECT_ALL_NAME;
  376. dtDicInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  377. return dtDicInfo;
  378. }
  379. /// <summary>
  380. /// 设置工具按钮的可用状态
  381. /// </summary>
  382. private void SetToolStripButtonEnable()
  383. {
  384. if (this.dgvProduction.CurrentCell != null)
  385. {
  386. //this.tsbtnCancelLoad.Enabled = true;
  387. }
  388. else
  389. {
  390. //this.tsbtnCancelLoad.Enabled = false;
  391. }
  392. }
  393. /// <summary>
  394. /// 搜索条件
  395. /// </summary>
  396. /// <returns></returns>
  397. private SearchProductionDataEntity CreatesearchProductionDataRequestEntity()
  398. {
  399. SearchProductionDataEntity result = new SearchProductionDataEntity();
  400. result.BarCode = this.txtBarCode.Text.Trim();
  401. result.GoodsCode = this.txtGoodsCode.Text.Trim();
  402. result.GoodsName = this.txtGoodsName.Text.Trim();
  403. result.UserCode = this.txtUserCode.Text.Trim();
  404. result.OrganizationID = this.scbOrganization.SearchedPKMember;
  405. result.Remarks = "";// this.txtRemarks.Text.Trim();
  406. //object[] objRework = this.statusIsReworked.SelectedValues;
  407. //string Rework = "";
  408. //for (int i = 0; i < objRework.Length; i++)
  409. //{
  410. // Rework += objRework[i] + ",";
  411. //}
  412. //Rework = Rework.TrimEnd(',');
  413. //result.IsRework = Rework;
  414. result.BeginDate = this.dtpStartTime.Value;
  415. result.EndDate = this.dtpEndTime.Value;//.AddDays(1);
  416. result.ProcedureID = _currentProcedureID;
  417. if (this.cobKilnName.SelectedValue != null
  418. && !Constant.CBO_SELECT_ALL_VALUE.ToString().Equals(this.cobKilnName.SelectedValue.ToString()))
  419. {
  420. result.KilnCode = this.cobKilnName.SelectedValue.ToString();
  421. }
  422. result.KilnCarCode = this.txtKilnCarName.Text.Trim();
  423. if (this.cobKilnCarPosition.SelectedValue != null
  424. && !Constant.CBO_SELECT_ALL_VALUE.ToString().Equals(this.cobKilnCarPosition.SelectedValue.ToString()))
  425. {
  426. result.KilnCarPosition = Convert.ToInt32(this.cobKilnCarPosition.SelectedValue);
  427. }
  428. result.GoodsTypeCode = this.scbGoodsType.SearchedValue + "";
  429. return result;
  430. }
  431. #endregion
  432. #region 漏扫补件
  433. private void tsbReLoad_Click(object sender, EventArgs e)
  434. {
  435. try
  436. {
  437. F_PM_0504 frmPM0502 = new F_PM_0504(_currentProcedureID, _fromTitle);
  438. DialogResult dialogResult = frmPM0502.ShowDialog();
  439. }
  440. catch (Exception ex)
  441. {
  442. // 对异常进行共通处理
  443. ExceptionManager.HandleEventException(this.ToString(),
  444. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  445. }
  446. }
  447. #endregion
  448. }
  449. }