F_PM_0501.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  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. this.tsbtnSKIn.Enabled = false;
  118. }
  119. catch (Exception ex)
  120. {
  121. // 对异常进行共通处理
  122. ExceptionManager.HandleEventException(this.ToString(),
  123. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  124. }
  125. }
  126. /// <summary>
  127. /// 窗体关闭事件
  128. /// </summary>
  129. /// <param name="sender"></param>
  130. /// <param name="e"></param>
  131. private void F_PM_0501_FormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e)
  132. {
  133. _dicInstance = null;
  134. }
  135. /// <summary>
  136. /// 自动适应列宽
  137. /// </summary>
  138. /// <param name="sender"></param>
  139. /// <param name="e"></param>
  140. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  141. {
  142. this.dgvProduction.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);
  160. this.dtpEndTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddDays(1).AddMinutes(-1);
  161. this.cobKilnName.SelectedIndex = Constant.INT_IS_ZERO;
  162. this.txtKilnCarName.Text = string.Empty;
  163. this.cobKilnCarPosition.SelectedIndex = Constant.INT_IS_ZERO;
  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. this.dgvProduction.DataSource = this.DataSource.Tables[Constant.INT_IS_ZERO];
  194. if (this.DataSource.Tables[Constant.INT_IS_ZERO].Rows.Count <= Constant.INT_IS_ZERO)
  195. {
  196. // 提示未查找到数据
  197. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  198. MessageBoxButtons.OK, MessageBoxIcon.Information);
  199. }
  200. else
  201. {
  202. if (selectRowIndex >= Constant.INT_IS_ZERO)
  203. {
  204. if (selectRowIndex >= dsProductionData.Tables[0].Rows.Count)
  205. {
  206. this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Selected = true;
  207. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Cells["GoodsCode"];
  208. }
  209. else
  210. {
  211. this.dgvProduction.Rows[selectRowIndex].Selected = true;
  212. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[selectRowIndex].Cells["GoodsCode"];
  213. }
  214. }
  215. }
  216. }
  217. }
  218. }
  219. catch (Exception ex)
  220. {
  221. this.btnSearch.Enabled = true;
  222. this.btnClearCondition.Enabled = true;
  223. // 对异常进行共通处理
  224. ExceptionManager.HandleEventException(this.ToString(),
  225. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  226. }
  227. }
  228. /// <summary>
  229. /// 关闭按钮事件
  230. /// </summary>
  231. /// <param name="sender"></param>
  232. /// <param name="e"></param>
  233. private void tsbtnClose_Click(object sender, EventArgs e)
  234. {
  235. this.Close();
  236. }
  237. /// <summary>
  238. /// 新建按钮事件
  239. /// </summary>
  240. /// <param name="sender"></param>
  241. /// <param name="e"></param>
  242. private void tsbtnAdd_Click(object sender, EventArgs e)
  243. {
  244. try
  245. {
  246. F_PM_0502 frmPM0502 = new F_PM_0502(_currentProcedureID, _fromTitle);
  247. DialogResult dialogResult = frmPM0502.ShowDialog();
  248. // 重新加载GridView
  249. if (dialogResult == DialogResult.OK)
  250. {
  251. SearchProductionDataEntity requestEntity = CreatesearchProductionDataRequestEntity();
  252. DataTable dtProductionData = (DataTable)DoAsync(new AsyncMethod(() =>
  253. {
  254. return PMModuleProxy.Service.GetProductionData(requestEntity);
  255. }));
  256. if (dtProductionData != null && dtProductionData.Rows.Count > Constant.INT_IS_ZERO)
  257. {
  258. this.dgvProduction.DataSource = null;
  259. this.dgvProduction.DataSource = dtProductionData;
  260. // 设置ToolStripButton按钮状态
  261. this.SetToolStripButtonEnable();
  262. this.dgvProduction.ReadOnly = true;
  263. }
  264. }
  265. }
  266. catch (Exception ex)
  267. {
  268. // 对异常进行共通处理
  269. ExceptionManager.HandleEventException(this.ToString(),
  270. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  271. }
  272. }
  273. /// <summary>
  274. ///
  275. /// </summary>
  276. /// <param name="sender"></param>
  277. /// <param name="e"></param>
  278. private void tsbtnUnDoLoading_Click(object sender, EventArgs e)
  279. {
  280. try
  281. {
  282. string barcode = "";
  283. if (this.dgvProduction.CurrentCell != null)
  284. {
  285. barcode = this.dgvProduction.CurrentRow.Cells["BarCode"].Value.ToString();
  286. }
  287. string flag = this.dgvProduction.CurrentRow.Cells["BarCode"].Value.ToString(); ;
  288. if (flag.Contains("小计") && flag!="合计")
  289. {
  290. F_PM_0503 frmPM0503 = new F_PM_0503(_currentProcedureID, barcode);
  291. DialogResult dialogResult = frmPM0503.ShowDialog();
  292. }
  293. else {
  294. MessageBox.Show("无法操作当前选中行数据 请重新选择", this.Text,
  295. MessageBoxButtons.OK, MessageBoxIcon.Information);
  296. }
  297. }
  298. catch (Exception ex)
  299. {
  300. // 对异常进行共通处理
  301. ExceptionManager.HandleEventException(this.ToString(),
  302. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  303. }
  304. }
  305. /// <summary>
  306. /// 梭式窑入窑按钮点击事件
  307. /// </summary>
  308. /// <param name="sender"></param>
  309. /// <param name="e"></param>
  310. private void tsbtnSKIn_Click(object sender, EventArgs e)
  311. {
  312. try
  313. {
  314. F_PM_0505 frm = new F_PM_0505();
  315. frm.ShowDialog();
  316. }
  317. catch (Exception ex)
  318. {
  319. // 对异常进行共通处理
  320. ExceptionManager.HandleEventException(this.ToString(),
  321. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  322. }
  323. }
  324. #endregion
  325. #region 私有方法
  326. /// <summary>
  327. /// 设置窗体按钮的文本信息
  328. /// </summary>
  329. private void SetFromTitleInfo()
  330. {
  331. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  332. // 撤销装车
  333. this.tsbtnUnDoLoading.Text = ButtonText.TSBTN_UNDOLOADING;
  334. //自动适应列宽
  335. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  336. //关闭
  337. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  338. //查询
  339. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  340. //清空条件
  341. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  342. //查询条件
  343. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  344. // 梭式窑入窑
  345. this.tsbtnSKIn.Text = Constant.TSBTN_SKIN;
  346. this.Text = _fromTitle;
  347. }
  348. /// <summary>
  349. /// 获取窑炉字典信息
  350. /// </summary>
  351. /// <returns></returns>
  352. private DataTable GetMSTKilnInfo()
  353. {
  354. DataSet dsKilnInfo = (DataSet)DoAsync(new AsyncMethod(() =>
  355. {
  356. byte byFlage = Convert.ToByte(Constant.ValueFlag.Invalid);
  357. return SystemModuleProxy.Service.GetKilnData(byFlage);
  358. }));
  359. DataTable dtKilnInfo = dsKilnInfo.Tables[Constant.INT_IS_ZERO];
  360. DataRow newRowDic = dtKilnInfo.NewRow();
  361. newRowDic["KilnID"] = Constant.CBO_SELECT_ALL_VALUE;
  362. newRowDic["KilnCode"] = Constant.CBO_SELECT_ALL_VALUE;
  363. newRowDic["KilnName"] = Constant.CBO_SELECT_ALL_NAME;
  364. dtKilnInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  365. return dtKilnInfo;
  366. }
  367. /// <summary>
  368. /// 获取窑车位置字典表数据
  369. /// </summary>
  370. /// <returns></returns>
  371. public DataTable GetMSTKilnCarPositionInfo()
  372. {
  373. DataTable dtDicInfo = (DataTable)DoAsync(new AsyncMethod(() =>
  374. {
  375. return CommonModuleProxy.Service.GetDataDictionaryByType(Constant.TPC_TPC003);
  376. }));
  377. DataRow newRowDic = dtDicInfo.NewRow();
  378. newRowDic["DictionaryID"] = Constant.CBO_SELECT_ALL_VALUE;
  379. newRowDic["DictionaryValue"] = Constant.CBO_SELECT_ALL_NAME;
  380. dtDicInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  381. return dtDicInfo;
  382. }
  383. /// <summary>
  384. /// 设置工具按钮的可用状态
  385. /// </summary>
  386. private void SetToolStripButtonEnable()
  387. {
  388. if (this.dgvProduction.CurrentCell != null)
  389. {
  390. //this.tsbtnCancelLoad.Enabled = true;
  391. }
  392. else
  393. {
  394. //this.tsbtnCancelLoad.Enabled = false;
  395. }
  396. }
  397. /// <summary>
  398. /// 搜索条件
  399. /// </summary>
  400. /// <returns></returns>
  401. private SearchProductionDataEntity CreatesearchProductionDataRequestEntity()
  402. {
  403. SearchProductionDataEntity result = new SearchProductionDataEntity();
  404. result.BarCode = this.txtBarCode.Text.Trim();
  405. result.GoodsCode = this.txtGoodsCode.Text.Trim();
  406. result.GoodsName = this.txtGoodsName.Text.Trim();
  407. result.UserCode = this.txtUserCode.Text.Trim();
  408. result.OrganizationID = this.scbOrganization.SearchedPKMember;
  409. result.Remarks = "";// this.txtRemarks.Text.Trim();
  410. //object[] objRework = this.statusIsReworked.SelectedValues;
  411. //string Rework = "";
  412. //for (int i = 0; i < objRework.Length; i++)
  413. //{
  414. // Rework += objRework[i] + ",";
  415. //}
  416. //Rework = Rework.TrimEnd(',');
  417. //result.IsRework = Rework;
  418. result.BeginDate = this.dtpStartTime.Value;
  419. result.EndDate = this.dtpEndTime.Value;//.AddDays(1);
  420. result.ProcedureID = _currentProcedureID;
  421. if (this.cobKilnName.SelectedValue != null
  422. && !Constant.CBO_SELECT_ALL_VALUE.ToString().Equals(this.cobKilnName.SelectedValue.ToString()))
  423. {
  424. result.KilnCode = this.cobKilnName.SelectedValue.ToString();
  425. }
  426. result.KilnCarCode = this.txtKilnCarName.Text.Trim();
  427. if (this.cobKilnCarPosition.SelectedValue != null
  428. && !Constant.CBO_SELECT_ALL_VALUE.ToString().Equals(this.cobKilnCarPosition.SelectedValue.ToString()))
  429. {
  430. result.KilnCarPosition = Convert.ToInt32(this.cobKilnCarPosition.SelectedValue);
  431. }
  432. result.GoodsTypeCode = this.scbGoodsType.SearchedValue + "";
  433. return result;
  434. }
  435. #endregion
  436. #region 漏扫补件
  437. private void tsbReLoad_Click(object sender, EventArgs e)
  438. {
  439. try
  440. {
  441. F_PM_0504 frmPM0502 = new F_PM_0504(_currentProcedureID, _fromTitle);
  442. DialogResult dialogResult = frmPM0502.ShowDialog();
  443. }
  444. catch (Exception ex)
  445. {
  446. // 对异常进行共通处理
  447. ExceptionManager.HandleEventException(this.ToString(),
  448. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  449. }
  450. }
  451. #endregion
  452. }
  453. }