F_PM_0601.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_0601.cs
  5. * 2.功能描述:入窑、出窑、卸车计件一览
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 张国印 2014/09/28 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_0601 : DockPanelBase
  28. {
  29. #region 成员变量
  30. // 窗体的单例模式
  31. private static Dictionary<int, F_PM_0601> _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_0601()
  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_0601 Instance(int procedureID, string fromTitle)
  56. {
  57. F_PM_0601 fInstance = null;
  58. if (_dicInstance == null)
  59. {
  60. _dicInstance = new Dictionary<int, F_PM_0601>();
  61. fInstance = new F_PM_0601();
  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_0601();
  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_0601_Load(object sender, EventArgs e)
  86. {
  87. try
  88. {
  89. // 加载权限
  90. FormPermissionManager.FormPermissionControl(this.Name, this,
  91. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  92. #region 设置下拉列表框的数据源
  93. this.cobKilnName.DataSource = GetMSTKilnInfo();
  94. this.cobKilnName.DisplayMember = "KilnName";
  95. this.cobKilnName.ValueMember = "KilnCode";
  96. this.cobKilnCarPosition.DataSource = GetMSTKilnCarPositionInfo();
  97. this.cobKilnCarPosition.DisplayMember = "DictionaryValue";
  98. this.cobKilnCarPosition.ValueMember = "DictionaryID";
  99. #endregion
  100. // 初始化时间控件为当前日期
  101. this.dtpStartTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  102. this.dtpEndTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddDays(1).AddMinutes(-1);// new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  103. // 设置ToolStripButton状态
  104. this.SetToolStripButtonEnable();
  105. // 获取工序明细数据
  106. ProcedureEntity procedureDataEntity = (ProcedureEntity)DoAsync(new AsyncMethod(() =>
  107. {
  108. return PMModuleProxy.Service.GetProcedureDataEntityByID(_currentProcedureID);
  109. }));
  110. if (procedureDataEntity != null && procedureDataEntity.ModelType == 2)
  111. {
  112. this.tsbtnCancelIntoCar.Visible = true;
  113. }
  114. }
  115. catch (Exception ex)
  116. {
  117. // 对异常进行共通处理
  118. ExceptionManager.HandleEventException(this.ToString(),
  119. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  120. }
  121. }
  122. /// <summary>
  123. /// 窗体关闭事件
  124. /// </summary>
  125. /// <param name="sender"></param>
  126. /// <param name="e"></param>
  127. private void F_PM_0601_FormClosed(object sender, FormClosedEventArgs e)
  128. {
  129. _dicInstance = null;
  130. }
  131. /// <summary>
  132. /// 自动适应列宽
  133. /// </summary>
  134. /// <param name="sender"></param>
  135. /// <param name="e"></param>
  136. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  137. {
  138. this.dgvProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  139. }
  140. /// <summary>
  141. /// 清空条件按钮事件
  142. /// </summary>
  143. /// <param name="sender"></param>
  144. /// <param name="e"></param>
  145. private void btnClearCondition_Click(object sender, EventArgs e)
  146. {
  147. this.txtBarCode.Text = "";
  148. this.txtGoodsCode.Text = "";
  149. this.txtGoodsName.Text = "";
  150. this.txtUserCode.Text = "";
  151. this.scbOrganization.ClearValue();
  152. //this.txtRemarks.Text = "";
  153. //this.statusIsReworked.ClearItemCheck();
  154. this.scbGoodsType.ClearValue();
  155. this.dtpStartTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  156. this.dtpEndTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddDays(1).AddMinutes(-1);// new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  157. this.cobKilnName.SelectedIndex = Constant.INT_IS_ZERO;
  158. this.txtKilnCarName.Text = string.Empty;
  159. this.cobKilnCarPosition.SelectedIndex = Constant.INT_IS_ZERO;
  160. }
  161. /// <summary>
  162. /// 查询按钮事件
  163. /// </summary>
  164. /// <param name="sender"></param>
  165. /// <param name="e"></param>
  166. private void btnSearch_Click(object sender, EventArgs e)
  167. {
  168. try
  169. {
  170. // 记录当前选中行
  171. int selectRowIndex = this._selecedRow;
  172. // 异步处理
  173. this.btnSearch.Enabled = false;
  174. this.btnClearCondition.Enabled = false;
  175. SearchProductionDataEntity requestEntity = CreatesearchProductionDataRequestEntity();
  176. DataTable dtProductionData = (DataTable)DoAsync(new AsyncMethod(() =>
  177. {
  178. return PMModuleProxy.Service.GetProductionData(requestEntity);
  179. }));
  180. DataSet dsProductionData = new DataSet();
  181. dsProductionData.Tables.Add(dtProductionData);
  182. this.btnSearch.Enabled = true;
  183. this.btnClearCondition.Enabled = true;
  184. if (dsProductionData != null)
  185. {
  186. base.DataSource = dsProductionData;
  187. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  188. {
  189. this.dgvProduction.DataSource = this.DataSource.Tables[Constant.INT_IS_ZERO];
  190. if (this.DataSource.Tables[Constant.INT_IS_ZERO].Rows.Count <= Constant.INT_IS_ZERO)
  191. {
  192. // 提示未查找到数据
  193. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  194. MessageBoxButtons.OK, MessageBoxIcon.Information);
  195. }
  196. else
  197. {
  198. if (selectRowIndex >= Constant.INT_IS_ZERO)
  199. {
  200. if (selectRowIndex >= dsProductionData.Tables[Constant.INT_IS_ZERO].Rows.Count)
  201. {
  202. this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Selected = true;
  203. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Cells["GoodsCode"];
  204. }
  205. else
  206. {
  207. this.dgvProduction.Rows[selectRowIndex].Selected = true;
  208. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[selectRowIndex].Cells["GoodsCode"];
  209. }
  210. }
  211. }
  212. }
  213. }
  214. }
  215. catch (Exception ex)
  216. {
  217. this.btnSearch.Enabled = true;
  218. this.btnClearCondition.Enabled = true;
  219. // 对异常进行共通处理
  220. ExceptionManager.HandleEventException(this.ToString(),
  221. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  222. }
  223. }
  224. /// <summary>
  225. /// 关闭按钮事件
  226. /// </summary>
  227. /// <param name="sender"></param>
  228. /// <param name="e"></param>
  229. private void tsbtnClose_Click(object sender, EventArgs e)
  230. {
  231. this.Close();
  232. }
  233. /// <summary>
  234. /// 新建按钮事件
  235. /// </summary>
  236. /// <param name="sender"></param>
  237. /// <param name="e"></param>
  238. private void tsbtnAdd_Click(object sender, EventArgs e)
  239. {
  240. try
  241. {
  242. F_PM_0602 frmPM0602 = new F_PM_0602(_currentProcedureID, _fromTitle);
  243. DialogResult dialogResult = frmPM0602.ShowDialog();
  244. // 重新加载GridView
  245. if (dialogResult == DialogResult.OK)
  246. {
  247. SearchProductionDataEntity requestEntity = CreatesearchProductionDataRequestEntity();
  248. DataTable dtProductionData = (DataTable)DoAsync(new AsyncMethod(() =>
  249. {
  250. return PMModuleProxy.Service.GetProductionData(requestEntity);
  251. }));
  252. if (dtProductionData != null && dtProductionData.Rows.Count > Constant.INT_IS_ZERO)
  253. {
  254. this.dgvProduction.DataSource = null;
  255. this.dgvProduction.DataSource = dtProductionData;
  256. // 设置ToolStripButton按钮状态
  257. this.SetToolStripButtonEnable();
  258. this.dgvProduction.ReadOnly = true;
  259. }
  260. }
  261. }
  262. catch (Exception ex)
  263. {
  264. // 对异常进行共通处理
  265. ExceptionManager.HandleEventException(this.ToString(),
  266. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  267. }
  268. }
  269. /// <summary>
  270. /// 撤销入窑按钮事件
  271. /// </summary>
  272. /// <param name="sender"></param>
  273. /// <param name="e"></param>
  274. private void tsbtnCancelIntoCar_Click(object sender, EventArgs e)
  275. {
  276. try
  277. {
  278. F_PM_0603 frm0603 = new F_PM_0603(this._currentProcedureID);
  279. frm0603.ShowDialog();
  280. }
  281. catch (Exception ex)
  282. {
  283. // 对异常进行共通处理
  284. ExceptionManager.HandleEventException(this.ToString(),
  285. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  286. }
  287. }
  288. /// <summary>
  289. /// 撤销入窑2,撤销到登窑前工序
  290. /// </summary>
  291. /// <param name="sender"></param>
  292. /// <param name="e"></param>
  293. private void tsbtnCancelIntoCar2_Click(object sender, EventArgs e)
  294. {
  295. try
  296. {
  297. F_PM_0603 frm0603 = new F_PM_0603(this._currentProcedureID);
  298. frm0603.ShowDialog();
  299. }
  300. catch (Exception ex)
  301. {
  302. // 对异常进行共通处理
  303. ExceptionManager.HandleEventException(this.ToString(),
  304. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  305. }
  306. }
  307. #endregion
  308. #region 私有方法
  309. /// <summary>
  310. /// 设置窗体按钮的文本信息
  311. /// </summary>
  312. private void SetFromTitleInfo()
  313. {
  314. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  315. //编辑
  316. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  317. //自动适应列宽
  318. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  319. //关闭
  320. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  321. //查询
  322. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  323. //清空条件
  324. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  325. //查询条件
  326. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  327. this.Text = this._fromTitle;
  328. }
  329. /// <summary>
  330. /// 获取窑炉字典信息
  331. /// </summary>
  332. /// <returns></returns>
  333. private DataTable GetMSTKilnInfo()
  334. {
  335. DataSet dsKilnInfo = (DataSet)DoAsync(new AsyncMethod(() =>
  336. {
  337. byte byFlage = Convert.ToByte(Constant.ValueFlag.Invalid);
  338. return SystemModuleProxy.Service.GetKilnData(byFlage);
  339. }));
  340. DataTable dtKilnInfo = dsKilnInfo.Tables[Constant.INT_IS_ZERO];
  341. DataRow newRowDic = dtKilnInfo.NewRow();
  342. newRowDic["KilnID"] = Constant.CBO_SELECT_ALL_VALUE;
  343. newRowDic["KilnCode"] = Constant.CBO_SELECT_ALL_VALUE;
  344. newRowDic["KilnName"] = Constant.CBO_SELECT_ALL_NAME;
  345. dtKilnInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  346. return dtKilnInfo;
  347. }
  348. /// <summary>
  349. /// 获取窑车位置字典表数据
  350. /// </summary>
  351. /// <returns></returns>
  352. public DataTable GetMSTKilnCarPositionInfo()
  353. {
  354. DataTable dtDicInfo = (DataTable)DoAsync(new AsyncMethod(() =>
  355. {
  356. return CommonModuleProxy.Service.GetDataDictionaryByType(Constant.TPC_TPC003);
  357. }));
  358. DataRow newRowDic = dtDicInfo.NewRow();
  359. newRowDic["DictionaryID"] = Constant.CBO_SELECT_ALL_VALUE;
  360. newRowDic["DictionaryValue"] = Constant.CBO_SELECT_ALL_NAME;
  361. dtDicInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  362. return dtDicInfo;
  363. }
  364. /// <summary>
  365. /// 设置工具按钮的可用状态
  366. /// </summary>
  367. private void SetToolStripButtonEnable()
  368. {
  369. if (this.dgvProduction.CurrentCell != null)
  370. {
  371. this.tsbtnEdit.Enabled = true;
  372. }
  373. else
  374. {
  375. this.tsbtnEdit.Enabled = false;
  376. }
  377. }
  378. /// <summary>
  379. /// 搜索条件
  380. /// </summary>
  381. /// <returns></returns>
  382. private SearchProductionDataEntity CreatesearchProductionDataRequestEntity()
  383. {
  384. SearchProductionDataEntity result = new SearchProductionDataEntity();
  385. result.BarCode = this.txtBarCode.Text.Trim();
  386. result.GoodsCode = this.txtGoodsCode.Text.Trim();
  387. result.GoodsName = this.txtGoodsName.Text.Trim();
  388. result.UserCode = this.txtUserCode.Text.Trim();
  389. result.OrganizationID = this.scbOrganization.SearchedPKMember;
  390. result.Remarks = "";// this.txtRemarks.Text.Trim();
  391. //object[] objRework = this.statusIsReworked.SelectedValues;
  392. string Rework = "";
  393. //for (int i = Constant.INT_IS_ZERO; i < objRework.Length; i++)
  394. //{
  395. // Rework += objRework[i] + ",";
  396. //}
  397. Rework = "";// Rework.TrimEnd(',');
  398. result.IsRework = Rework;
  399. result.BeginDate = this.dtpStartTime.Value;
  400. result.EndDate = this.dtpEndTime.Value;//.AddDays(1);
  401. result.ProcedureID = _currentProcedureID;
  402. if (this.cobKilnName.SelectedValue != null
  403. && !Constant.CBO_SELECT_ALL_VALUE.ToString().Equals(this.cobKilnName.SelectedValue.ToString())) //.ToString()
  404. {
  405. result.KilnCode = this.cobKilnName.SelectedValue.ToString();
  406. }
  407. result.KilnCarCode = this.txtKilnCarName.Text.Trim();
  408. if (this.cobKilnCarPosition.SelectedValue != null
  409. && !Constant.CBO_SELECT_ALL_VALUE.ToString().Equals(this.cobKilnCarPosition.SelectedValue.ToString()))
  410. {
  411. result.KilnCarPosition = Convert.ToInt32(this.cobKilnCarPosition.SelectedValue);
  412. }
  413. result.GoodsTypeCode = this.scbGoodsType.SearchedValue + "";
  414. return result;
  415. }
  416. #endregion
  417. }
  418. }