F_PM_1603.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_1603.cs
  5. * 2.功能描述:半检数据审批
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2014/12/09 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Text;
  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_1603 : DockPanelBase
  27. {
  28. #region 成员变量
  29. // 窗体的单例模式
  30. private static F_PM_1603 _instance;
  31. //权限id集
  32. private string purviews = string.Empty;
  33. //实体类
  34. private SemiTestEntity _semiTestEntity;
  35. #endregion
  36. #region 构造函数
  37. public F_PM_1603()
  38. {
  39. InitializeComponent();
  40. // 窗体显示的Title
  41. this.Text = FormTitles.F_RM_1603;
  42. this.tsbtnApprover.Text = ButtonText.TSBTN_AUDIT;
  43. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  44. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  45. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  46. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  47. }
  48. #endregion
  49. #region 单例模式
  50. /// <summary>
  51. /// 单例模式,防止重复创建窗体
  52. /// </summary>
  53. public static F_PM_1603 Instance
  54. {
  55. get
  56. {
  57. if (_instance == null || _instance.IsDisposed)
  58. {
  59. _instance = new F_PM_1603();
  60. }
  61. return _instance;
  62. }
  63. }
  64. #endregion
  65. #region 事件处理
  66. /// <summary>
  67. /// 窗体加载事件
  68. /// </summary>
  69. /// <param name="sender"></param>
  70. /// <param name="e"></param>
  71. private void F_PM_1603_Load(object sender, EventArgs e)
  72. {
  73. try
  74. {
  75. // 加载权限
  76. FormPermissionManager.FormPermissionControl(this.Name, this,
  77. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  78. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  79. // 初始化时间控件为当前日期
  80. this.dtpSemiTestDateStart.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  81. this.dtpSemiTestDateEnd.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  82. //操作检验工号权限值
  83. //getPurview();
  84. DataSet dsDefectPosition = (DataSet)DoAsync(new AsyncMethod(() =>
  85. {
  86. return SystemModuleProxy.Service.GetDictionaryData(0, "TPC006");
  87. }));
  88. if (dsDefectPosition != null && dsDefectPosition.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  89. {
  90. for (int i = 0; i < dsDefectPosition.Tables[0].Rows.Count; i++)
  91. {
  92. DataGridViewTextBoxColumn dataGridTextBoxColumn = new DataGridViewTextBoxColumn();
  93. dataGridTextBoxColumn.HeaderText = dsDefectPosition.Tables[0].Rows[i]["DictionaryValue"].ToString();
  94. dataGridTextBoxColumn.DataPropertyName = "Col" + dsDefectPosition.Tables[0].Rows[i]["DictionaryID"].ToString();
  95. this.dgvSemiTestDetail.Columns.Add(dataGridTextBoxColumn);
  96. }
  97. }
  98. // 获取半检类别
  99. DataSet dsType = (DataSet)DoAsync(new AsyncMethod(() =>
  100. {
  101. return SystemModuleProxy.Service.GetDictionaryData(0, "TPC007");
  102. }));
  103. if (dsType != null && dsType.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  104. {
  105. this.dropSemiTestType.DisplayMember = "DictionaryValue";
  106. this.dropSemiTestType.ValueMember = "DictionaryID";
  107. this.dropSemiTestType.DataSource = dsType.Tables[0];
  108. }
  109. }
  110. catch (Exception ex)
  111. {
  112. // 对异常进行共通处理
  113. ExceptionManager.HandleEventException(this.ToString(),
  114. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  115. }
  116. }
  117. /// <summary>
  118. /// 关闭按钮
  119. /// </summary>
  120. /// <param name="sender"></param>
  121. /// <param name="e"></param>
  122. private void tsbtnClose_Click(object sender, EventArgs e)
  123. {
  124. this.Close();
  125. }
  126. /// <summary>
  127. /// 窗体关闭事件
  128. /// </summary>
  129. /// <param name="sender"></param>
  130. /// <param name="e"></param>
  131. private void F_PM_1603_FormClosed(object sender, FormClosedEventArgs e)
  132. {
  133. _instance = 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.dgvSemiTest.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  143. this.dgvSemiTestDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  144. }
  145. /// <summary>
  146. /// 查询按钮事件
  147. /// </summary>
  148. /// <param name="sender"></param>
  149. /// <param name="e"></param>
  150. private void btnSearch_Click(object sender, EventArgs e)
  151. {
  152. try
  153. {
  154. //获取条件
  155. CreatesearchSemiTestEntity();
  156. DataSet dsSearchSemiTest = (DataSet)DoAsync(new AsyncMethod(() =>
  157. {
  158. return PMModuleProxy.Service.SearchSemiTestList(_semiTestEntity);
  159. }));
  160. if (dsSearchSemiTest != null)
  161. {
  162. if (dsSearchSemiTest.Tables[Constant.INT_IS_ZERO].Rows.Count <= Constant.INT_IS_ZERO)
  163. {
  164. // 提示未查找到数据
  165. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  166. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  167. //清空数据
  168. this.dgvSemiTest.DataSource = null;
  169. this.dgvSemiTestDetail.DataSource = null;
  170. }
  171. else
  172. {
  173. this.dgvSemiTest.DataSource = dsSearchSemiTest.Tables[0];
  174. }
  175. }
  176. }
  177. catch (Exception ex)
  178. {
  179. this.btnSearch.Enabled = true;
  180. // 对异常进行共通处理
  181. ExceptionManager.HandleEventException(this.ToString(),
  182. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  183. }
  184. }
  185. /// <summary>
  186. /// 清空条件按钮事件
  187. /// </summary>
  188. /// <param name="sender"></param>
  189. /// <param name="e"></param>
  190. private void btnClearCondition_Click(object sender, EventArgs e)
  191. {
  192. this.dtpSemiTestDateStart.Value = DateTime.Now;
  193. this.dtpSemiTestDateEnd.Value = DateTime.Now;
  194. this.scbUser.ClearValue();
  195. this.dropSemiTestType.SelectedValue = null;
  196. this.txtRemarks.Text = "";
  197. }
  198. /// <summary>
  199. /// 半检数据选定项改变事件
  200. /// </summary>
  201. /// <param name="sender"></param>
  202. /// <param name="e"></param>
  203. private void dgvSemiTest_SelectionChanged(object sender, EventArgs e)
  204. {
  205. try
  206. {
  207. if (this.dgvSemiTest.CurrentCell != null)
  208. {
  209. if (this.txtRemarks.ReadOnly)
  210. {
  211. return;
  212. }
  213. this.dgvSemiTestDetail.DataSource = null;
  214. int SemiTestID = Convert.ToInt32(this.dgvSemiTest.Rows[this.dgvSemiTest.CurrentCell.RowIndex].Cells["SemiTestID"].Value.ToString());
  215. DataSet dsSemiTestDefect = (DataSet)DoAsync(new AsyncMethod(() =>
  216. {
  217. return PMModuleProxy.Service.SearchSemiTestInfo(SemiTestID);
  218. }));
  219. if (dsSemiTestDefect != null && dsSemiTestDefect.Tables.Count > Constant.INT_IS_ZERO
  220. && dsSemiTestDefect.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  221. {
  222. this.dgvSemiTestDetail.DataSource = dsSemiTestDefect.Tables[0];
  223. }
  224. }
  225. }
  226. catch (Exception ex)
  227. {
  228. // 对异常进行共通处理
  229. ExceptionManager.HandleEventException(this.ToString(),
  230. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  231. }
  232. }
  233. /// <summary>
  234. /// 审批按钮事件
  235. /// </summary>
  236. /// <param name="sender"></param>
  237. /// <param name="e"></param>
  238. private void tsbtnApprover_Click(object sender, EventArgs e)
  239. {
  240. try
  241. {
  242. if (this.dgvSemiTest.CurrentCell != null)
  243. {
  244. int SemiTestID = Convert.ToInt32(this.dgvSemiTest.Rows[this.dgvSemiTest.CurrentCell.RowIndex].Cells["SemiTestID"].Value.ToString());
  245. DateTime OPTimeStamp = Convert.ToDateTime(this.dgvSemiTest.Rows[this.dgvSemiTest.CurrentCell.RowIndex].Cells["OPTimeStamp"].Value);
  246. int ValidateRow = (int)DoAsync(new AsyncMethod(() =>
  247. {
  248. return PMModuleProxy.Service.ValidateOPTimeStamp(SemiTestID, OPTimeStamp);
  249. }));
  250. if (ValidateRow == Constant.INT_IS_NEGATIE_ONE)
  251. {
  252. // 提示信息
  253. MessageBox.Show(string.Format(Messages.MSG_CMN_W012, "半检数据", "审核"),
  254. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  255. return;
  256. }
  257. DialogResult dialogResult = MessageBox.Show(Messages.MSG_PM_Q002, this.Text,
  258. MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
  259. if (dialogResult == DialogResult.Yes)
  260. {
  261. int row = (int)DoAsync(new AsyncMethod(() =>
  262. {
  263. return PMModuleProxy.Service.UpdateSemiTestByID(SemiTestID, 1);
  264. }));
  265. // 提示信息
  266. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "半检数据", "审核"),
  267. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  268. // 搜索按钮事件
  269. this.btnSearch_Click(sender, e);
  270. }
  271. else if (dialogResult == DialogResult.No)
  272. {
  273. int row = (int)DoAsync(new AsyncMethod(() =>
  274. {
  275. return PMModuleProxy.Service.UpdateSemiTestByID(SemiTestID, 2);
  276. }));
  277. // 提示信息
  278. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "半检数据", "审核"),
  279. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  280. this.btnSearch_Click(sender, e);
  281. }
  282. }
  283. }
  284. catch (Exception ex)
  285. {
  286. // 对异常进行共通处理
  287. ExceptionManager.HandleEventException(this.ToString(),
  288. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  289. }
  290. }
  291. #endregion
  292. #region 私有方法
  293. /// <summary>
  294. /// 搜索条件
  295. /// </summary>
  296. /// <returns></returns>
  297. private void CreatesearchReportEntity()
  298. {
  299. string accountDateStart = this.dtpSemiTestDateStart.Value.ToString("yyyy-MM-dd") + " 0:0:0";
  300. string accountDateEnd = this.dtpSemiTestDateEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59";
  301. }
  302. /// <summary>
  303. /// 获取当前用户的成型线权限
  304. /// </summary>
  305. protected void getPurview()
  306. {
  307. try
  308. {
  309. //StringBuilder sbUserPurview = new StringBuilder();
  310. ////获取用户权限集
  311. //DataSet dsUserPurview = (DataSet)DoAsync(new AsyncMethod(() =>
  312. //{
  313. // return SystemModuleProxy.Service.GetUserPurview(4, LogInUserInfo.CurrentUser.UserID);
  314. //}));
  315. ////拼接字符串
  316. //if (dsUserPurview != null)
  317. //{
  318. // foreach (DataRow dr in dsUserPurview.Tables[Constant.INT_IS_ZERO].Rows)
  319. // {
  320. // sbUserPurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  321. // }
  322. // if (sbUserPurview.Length != Constant.INT_IS_ZERO)
  323. // {
  324. // purviews = sbUserPurview.ToString().Substring(Constant.INT_IS_ZERO, sbUserPurview.Length - 1);
  325. // this.dkUserInfoSearchBox.UserIDS = purviews;
  326. // }
  327. //}
  328. }
  329. catch (Exception ex)
  330. {
  331. throw ex;
  332. }
  333. }
  334. /// <summary>
  335. /// 搜索条件
  336. /// </summary>
  337. /// <returns></returns>
  338. private void CreatesearchSemiTestEntity()
  339. {
  340. this._semiTestEntity = new SemiTestEntity();
  341. this._semiTestEntity.TestUserIDS = purviews;
  342. this._semiTestEntity.beginDate = Convert.ToDateTime(this.dtpSemiTestDateStart.Value);
  343. this._semiTestEntity.endDate = Convert.ToDateTime(this.dtpSemiTestDateEnd.Value).AddDays(1);
  344. this._semiTestEntity.Remarks = this.txtRemarks.Text.Trim();
  345. if (scbUser.SearchedPKMember != 0)
  346. {
  347. this._semiTestEntity.TestUserID = scbUser.SearchedPKMember;
  348. }
  349. if (this.dropSemiTestType.SelectedValue != null)
  350. {
  351. this._semiTestEntity.SemiTestType = Convert.ToInt32(this.dropSemiTestType.SelectedValue);
  352. }
  353. }
  354. #endregion
  355. }
  356. }