F_PM_2001.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_2001.cs
  5. * 2.功能描述:干补计件一览
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 袁新成 2015/3/27 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.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_2001 : DockPanelBase
  27. {
  28. #region 成员变量
  29. // 窗体的单例模式
  30. private static Dictionary<int, F_PM_2001> _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_2001()
  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_2001 Instance(int procedureID, string fromTitle)
  64. {
  65. F_PM_2001 fInstance = null;
  66. if (_dicInstance == null)
  67. {
  68. _dicInstance = new Dictionary<int, F_PM_2001>();
  69. fInstance = new F_PM_2001();
  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_2001();
  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_2001_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);
  105. // 设置ToolStripButton状态
  106. this.SetToolStripButtonEnable();
  107. }
  108. catch (Exception ex)
  109. {
  110. // 对异常进行共通处理
  111. ExceptionManager.HandleEventException(this.ToString(),
  112. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  113. }
  114. }
  115. /// <summary>
  116. /// 窗体关闭事件
  117. /// </summary>
  118. /// <param name="sender"></param>
  119. /// <param name="e"></param>
  120. private void F_PM_2001_FormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e)
  121. {
  122. _dicInstance = null;
  123. }
  124. /// <summary>
  125. /// 自动适应列宽
  126. /// </summary>
  127. /// <param name="sender"></param>
  128. /// <param name="e"></param>
  129. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  130. {
  131. this.dgvProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  132. }
  133. /// <summary>
  134. /// 清空条件按钮事件
  135. /// </summary>
  136. /// <param name="sender"></param>
  137. /// <param name="e"></param>
  138. private void btnClearCondition_Click(object sender, EventArgs e)
  139. {
  140. this.txtBarCode.Text = "";
  141. this.txtGoodsCode.Text = "";
  142. this.txtGoodsName.Text = "";
  143. this.txtUserCode.Text = "";
  144. this.scbOrganization.ClearValue();
  145. //this.txtRemarks.Text = "";
  146. //this.statusIsReworked.ClearItemCheck();
  147. this.scbGoodsType.ClearValue();
  148. this.dtpStartTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  149. this.dtpEndTime.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  150. }
  151. /// <summary>
  152. /// 查询按钮事件
  153. /// </summary>
  154. /// <param name="sender"></param>
  155. /// <param name="e"></param>
  156. private void btnSearch_Click(object sender, EventArgs e)
  157. {
  158. try
  159. {
  160. // 记录当前选中行
  161. int selectRowIndex = this._selecedRow;
  162. // 异步处理
  163. this.btnSearch.Enabled = false;
  164. this.btnClearCondition.Enabled = false;
  165. //SearchProductionDataEntity requestEntity = CreatesearchProductionDataRequestEntity();
  166. //DataTable dtProductionData = (DataTable)DoAsync(new AsyncMethod(() =>
  167. //{
  168. // return PMModuleProxy.Service.GetProductionData(requestEntity);
  169. //}));
  170. ClientRequestEntity cre = CreatesearchProductionDataRequestEntity();
  171. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(() =>
  172. {
  173. return PMModuleProxyNew.Service.HandleRequest(cre);
  174. });
  175. if (sre == null)
  176. {
  177. return;
  178. }
  179. DataSet dsProductionData = sre.Data;
  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[0];
  190. if (this.DataSource.Tables[0].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[0].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_2002 frmPM2002 = new F_PM_2002(_currentProcedureID, _fromTitle);
  243. DialogResult dialogResult = frmPM2002.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. this.btnSearch_Click(null, null);
  261. }
  262. }
  263. catch (Exception ex)
  264. {
  265. // 对异常进行共通处理
  266. ExceptionManager.HandleEventException(this.ToString(),
  267. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  268. }
  269. }
  270. #endregion
  271. #region 私有方法
  272. /// <summary>
  273. /// 设置工具按钮的可用状态
  274. /// </summary>
  275. private void SetToolStripButtonEnable()
  276. {
  277. if (this.dgvProduction.CurrentCell != null)
  278. {
  279. this.tsbtnEdit.Enabled = true;
  280. }
  281. else
  282. {
  283. this.tsbtnEdit.Enabled = false;
  284. }
  285. }
  286. /// <summary>
  287. /// 搜索条件
  288. /// </summary>
  289. /// <returns></returns>
  290. private ClientRequestEntity CreatesearchProductionDataRequestEntity()
  291. {
  292. //SearchProductionDataEntity result = new SearchProductionDataEntity();
  293. //result.BarCode = this.txtBarCode.Text.Trim();
  294. //result.GoodsCode = this.txtGoodsCode.Text.Trim();
  295. //result.GoodsName = this.txtGoodsName.Text.Trim();
  296. //result.UserCode = this.txtUserCode.Text.Trim();
  297. //result.OrganizationID = this.dkOrganization.OrganizationID;
  298. //result.Remarks = "";// this.txtRemarks.Text.Trim();
  299. ////object[] objRework = this.statusIsReworked.SelectedValues;
  300. //string Rework = "";
  301. ////for (int i = 0; i < objRework.Length; i++)
  302. ////{
  303. //// Rework += objRework[i] + ",";
  304. ////}
  305. //Rework = "";// Rework.TrimEnd(',');
  306. //result.IsRework = Rework;
  307. //result.BeginDate = this.dtpStartTime.Value;
  308. //result.EndDate = this.dtpEndTime.Value.AddDays(1);
  309. //result.ProcedureID = _currentProcedureID;
  310. //result.GoodsTypeCode = dkGoodsTypeSearchBox.GoodsTypeCode;
  311. //return result;
  312. ClientRequestEntity cre = new ClientRequestEntity();
  313. cre.NameSpace = "ProductionData";
  314. cre.Name = "GetProductionData_8";
  315. cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
  316. cre.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
  317. cre.Properties["GoodsName"] = this.txtGoodsName.Text.Trim();
  318. cre.Properties["UserCode"] = this.txtUserCode.Text.Trim();
  319. cre.Properties["OrganizationID"] = this.scbOrganization.SearchedPKMember;
  320. cre.Properties["BeginDate"] = this.dtpStartTime.Value;
  321. cre.Properties["EndDate"] = this.dtpEndTime.Value.AddDays(1);
  322. cre.Properties["ProcedureID"] = _currentProcedureID;
  323. cre.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue;
  324. return cre;
  325. }
  326. #endregion
  327. }
  328. }