F_PM_0301.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_0301.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.PMModule;
  19. using Dongke.IBOSS.PRD.WCF.Proxys;
  20. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  21. namespace Dongke.IBOSS.PRD.Client.PMModule
  22. {
  23. /// <summary>
  24. /// 标准、坯库计件一览
  25. /// </summary>
  26. public partial class F_PM_0301 : DockPanelBase
  27. {
  28. #region 成员变量
  29. // 窗体的单例模式
  30. private static Dictionary<int, F_PM_0301> _dicInstance;
  31. // 当前工序ID
  32. private int _currentProcedureID = 0;
  33. // 最后选择行
  34. private int _selecedRow;
  35. // 窗体显示的Title
  36. private string _fromTitle;
  37. #endregion
  38. #region 构造函数
  39. public F_PM_0301()
  40. {
  41. InitializeComponent();
  42. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  43. //编辑
  44. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  45. //自动适应列宽
  46. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  47. //关闭
  48. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  49. //查询
  50. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  51. //清空条件
  52. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  53. //查询条件
  54. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  55. }
  56. #endregion
  57. #region 单例模式
  58. /// <summary>
  59. /// 一个工序ID有一个单例,防止重复创建窗体
  60. /// </summary>
  61. /// <param name="procedureID">工序ID</param>
  62. /// <returns></returns>
  63. public static F_PM_0301 Instance(int procedureID, string fromTitle)
  64. {
  65. F_PM_0301 fInstance = null;
  66. if (_dicInstance == null)
  67. {
  68. _dicInstance = new Dictionary<int, F_PM_0301>();
  69. fInstance = new F_PM_0301();
  70. _dicInstance.Add(procedureID, fInstance);
  71. }
  72. else if (_dicInstance.ContainsKey(procedureID))
  73. {
  74. fInstance = _dicInstance[procedureID];
  75. }
  76. else
  77. {
  78. fInstance = new F_PM_0301();
  79. _dicInstance.Add(procedureID, fInstance);
  80. }
  81. fInstance._currentProcedureID = procedureID;
  82. fInstance._fromTitle = fromTitle;
  83. fInstance.Text = fromTitle;
  84. return fInstance;
  85. }
  86. #endregion
  87. #region 事件
  88. /// <summary>
  89. /// 窗体加载事件
  90. /// </summary>
  91. /// <param name="sender"></param>
  92. /// <param name="e"></param>
  93. private void F_PM_0301_Load(object sender, System.EventArgs e)
  94. {
  95. try
  96. {
  97. // 加载权限
  98. FormPermissionManager.FormPermissionControl(this.Name, this,
  99. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  100. // 设置表格不自动创建列
  101. this.dgvProduction.AutoGenerateColumns = false;
  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. // 1-3节点到3-2节点都加一个成型车间的筛选条件 250317
  108. // 2-1打磨--4 2-2擦洗--5 2-4半检--6 3-1精坯入--7 3-2精坯出--8 2-3打磨擦洗--36
  109. if (_currentProcedureID == 4 || _currentProcedureID == 5
  110. || _currentProcedureID == 6 || _currentProcedureID == 7
  111. || _currentProcedureID == 8 || _currentProcedureID == 36)
  112. {
  113. this.cobworkshop.Visible = true;
  114. this.lblworkshop.Visible = true;
  115. }
  116. else
  117. {
  118. this.cobworkshop.Visible = false;
  119. this.lblworkshop.Visible = false;
  120. }
  121. }
  122. catch (Exception ex)
  123. {
  124. // 对异常进行共通处理
  125. ExceptionManager.HandleEventException(this.ToString(),
  126. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  127. }
  128. }
  129. /// <summary>
  130. /// 窗体关闭事件
  131. /// </summary>
  132. /// <param name="sender"></param>
  133. /// <param name="e"></param>
  134. private void F_PM_0301_FormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e)
  135. {
  136. _dicInstance = null;
  137. }
  138. /// <summary>
  139. /// 自动适应列宽
  140. /// </summary>
  141. /// <param name="sender"></param>
  142. /// <param name="e"></param>
  143. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  144. {
  145. this.dgvProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  146. }
  147. /// <summary>
  148. /// 清空条件按钮事件
  149. /// </summary>
  150. /// <param name="sender"></param>
  151. /// <param name="e"></param>
  152. private void btnClearCondition_Click(object sender, EventArgs e)
  153. {
  154. this.txtBarCode.Text = "";
  155. this.txtGoodsCode.Text = "";
  156. this.txtGoodsName.Text = "";
  157. this.txtUserCode.Text = "";
  158. this.scbOrganization.ClearValue();
  159. //this.txtRemarks.Text = "";
  160. //this.statusIsReworked.ClearItemCheck();
  161. this.scbGoodsType.ClearValue();
  162. this.dtpStartTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  163. this.dtpEndTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddDays(1).AddMinutes(-1);
  164. // 1-3节点到3-2节点都加一个成型车间的筛选条件 250317
  165. // 2-1打磨--4 2-2擦洗--5 2-4半检--6 3-1精坯入--7 3-2精坯出--8 2-3打磨擦洗--36
  166. if (_currentProcedureID == 4 || _currentProcedureID == 5
  167. || _currentProcedureID == 6 || _currentProcedureID == 7
  168. || _currentProcedureID == 8 || _currentProcedureID == 36)
  169. {
  170. this.cobworkshop.SelectedIndex = Constant.INT_IS_NEGATIE_ONE;
  171. }
  172. }
  173. /// <summary>
  174. /// 查询按钮事件
  175. /// </summary>
  176. /// <param name="sender"></param>
  177. /// <param name="e"></param>
  178. private void btnSearch_Click(object sender, EventArgs e)
  179. {
  180. try
  181. {
  182. // 记录当前选中行
  183. int selectRowIndex = this._selecedRow;
  184. // 异步处理
  185. this.btnSearch.Enabled = false;
  186. this.btnClearCondition.Enabled = false;
  187. SearchProductionDataEntity requestEntity = CreatesearchProductionDataRequestEntity();
  188. DataTable dtProductionData = (DataTable)DoAsync(new AsyncMethod(() =>
  189. {
  190. return PMModuleProxy.Service.GetProductionData(requestEntity);
  191. }));
  192. DataSet dsProductionData = new DataSet();
  193. dsProductionData.Tables.Add(dtProductionData);
  194. this.btnSearch.Enabled = true;
  195. this.btnClearCondition.Enabled = true;
  196. if (dsProductionData != null)
  197. {
  198. base.DataSource = dsProductionData;
  199. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  200. {
  201. this.dgvProduction.DataSource = this.DataSource.Tables[0];
  202. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  203. {
  204. // 提示未查找到数据
  205. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  206. MessageBoxButtons.OK, MessageBoxIcon.Information);
  207. }
  208. else
  209. {
  210. if (selectRowIndex >= Constant.INT_IS_ZERO)
  211. {
  212. if (selectRowIndex >= dsProductionData.Tables[0].Rows.Count)
  213. {
  214. this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Selected = true;
  215. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[this.dgvProduction.Rows.Count - 1].Cells["GoodsCode"];
  216. }
  217. else
  218. {
  219. this.dgvProduction.Rows[selectRowIndex].Selected = true;
  220. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[selectRowIndex].Cells["GoodsCode"];
  221. }
  222. }
  223. }
  224. }
  225. }
  226. }
  227. catch (Exception ex)
  228. {
  229. this.btnSearch.Enabled = true;
  230. this.btnClearCondition.Enabled = true;
  231. // 对异常进行共通处理
  232. ExceptionManager.HandleEventException(this.ToString(),
  233. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  234. }
  235. }
  236. /// <summary>
  237. /// 关闭按钮事件
  238. /// </summary>
  239. /// <param name="sender"></param>
  240. /// <param name="e"></param>
  241. private void tsbtnClose_Click(object sender, EventArgs e)
  242. {
  243. this.Close();
  244. }
  245. /// <summary>
  246. /// 新建按钮事件
  247. /// </summary>
  248. /// <param name="sender"></param>
  249. /// <param name="e"></param>
  250. private void tsbtnAdd_Click(object sender, EventArgs e)
  251. {
  252. try
  253. {
  254. F_PM_0302 frmPM0402 = new F_PM_0302(_currentProcedureID, _fromTitle);
  255. DialogResult dialogResult = frmPM0402.ShowDialog();
  256. // 重新加载GridView
  257. if (dialogResult == DialogResult.OK)
  258. {
  259. SearchProductionDataEntity requestEntity = CreatesearchProductionDataRequestEntity();
  260. DataTable dtProductionData = (DataTable)DoAsync(new AsyncMethod(() =>
  261. {
  262. return PMModuleProxy.Service.GetProductionData(requestEntity);
  263. }));
  264. if (dtProductionData != null && dtProductionData.Rows.Count > Constant.INT_IS_ZERO)
  265. {
  266. this.dgvProduction.DataSource = null;
  267. this.dgvProduction.DataSource = dtProductionData;
  268. // 设置ToolStripButton按钮状态
  269. this.SetToolStripButtonEnable();
  270. this.dgvProduction.ReadOnly = true;
  271. }
  272. }
  273. }
  274. catch (Exception ex)
  275. {
  276. // 对异常进行共通处理
  277. ExceptionManager.HandleEventException(this.ToString(),
  278. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  279. }
  280. }
  281. #endregion
  282. #region 私有方法
  283. /// <summary>
  284. /// 设置工具按钮的可用状态
  285. /// </summary>
  286. private void SetToolStripButtonEnable()
  287. {
  288. if (this.dgvProduction.CurrentCell != null)
  289. {
  290. this.tsbtnEdit.Enabled = true;
  291. }
  292. else
  293. {
  294. this.tsbtnEdit.Enabled = false;
  295. }
  296. }
  297. /// <summary>
  298. /// 搜索条件
  299. /// </summary>
  300. /// <returns></returns>
  301. private SearchProductionDataEntity CreatesearchProductionDataRequestEntity()
  302. {
  303. SearchProductionDataEntity result = new SearchProductionDataEntity();
  304. result.BarCode = this.txtBarCode.Text.Trim();
  305. result.GoodsCode = this.txtGoodsCode.Text.Trim();
  306. result.GoodsName = this.txtGoodsName.Text.Trim();
  307. result.UserCode = this.txtUserCode.Text.Trim();
  308. result.OrganizationID = scbOrganization.SearchedPKMember;
  309. // 1-3节点到3-2节点都加一个成型车间的筛选条件 250317
  310. // 2-1打磨--4 2-2擦洗--5 2-4半检--6 3-1精坯入--7 3-2精坯出--8 2-3打磨擦洗--36
  311. if (_currentProcedureID == 4 || _currentProcedureID == 5
  312. || _currentProcedureID == 6 || _currentProcedureID == 7
  313. || _currentProcedureID == 8 || _currentProcedureID == 36)
  314. {
  315. result.Remarks = cobworkshop.Text;//暂传车间()
  316. }
  317. else
  318. {
  319. result.Remarks = "";
  320. }
  321. // this.txtRemarks.Text.Trim();
  322. //object[] objRework = this.statusIsReworked.SelectedValues;
  323. string Rework = "";
  324. //for (int i = 0; i < objRework.Length; i++)
  325. //{
  326. // Rework += objRework[i] + ",";
  327. //}
  328. Rework = Rework.TrimEnd(',');
  329. result.IsRework = Rework;
  330. result.BeginDate = this.dtpStartTime.Value;
  331. result.EndDate = this.dtpEndTime.Value;//.AddDays(1)
  332. result.ProcedureID = _currentProcedureID;
  333. result.GoodsTypeCode = this.scbGoodsType.SearchedValue + "";
  334. return result;
  335. }
  336. #endregion
  337. }
  338. }