F_PM_0501.cs 14 KB

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