F_PM_1601.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_1601.cs
  5. * 2.功能描述:半检数据一览
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 宋扬 2014/12/04 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_1601 : DockPanelBase
  27. {
  28. #region 成员变量
  29. // 窗体的单例模式
  30. private static F_PM_1601 _instance;
  31. //实体类
  32. private SemiTestDetailEntity semiTestDetailEntity = new SemiTestDetailEntity();
  33. //权限工号id集
  34. private string _userPurviews = string.Empty;
  35. #endregion
  36. #region 构造函数
  37. public F_PM_1601()
  38. {
  39. InitializeComponent();
  40. // 窗体显示的Title
  41. this.Text = FormTitles.F_PM_1601;
  42. // 新增
  43. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  44. // 编辑
  45. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  46. //自动适应列宽
  47. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  48. //关闭
  49. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  50. //查询
  51. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  52. //清空条件
  53. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  54. //查询条件
  55. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  56. }
  57. #endregion
  58. #region 单例模式
  59. /// <summary>
  60. /// 单例模式,防止重复创建窗体
  61. /// </summary>
  62. public static F_PM_1601 Instance
  63. {
  64. get
  65. {
  66. if (_instance == null || _instance.IsDisposed)
  67. {
  68. _instance = new F_PM_1601();
  69. }
  70. return _instance;
  71. }
  72. }
  73. #endregion
  74. #region 事件处理
  75. /// <summary>
  76. /// 窗体加载事件
  77. /// </summary>
  78. /// <param name="sender"></param>
  79. /// <param name="e"></param>
  80. private void F_PM_1601_Load(object sender, EventArgs e)
  81. {
  82. try
  83. {
  84. // 加载权限
  85. FormPermissionManager.FormPermissionControl(this.Name, this,
  86. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  87. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  88. // 设置表格不自动创建列
  89. this.dgvSemiTestDetail.AutoGenerateColumns = false;
  90. this.dgvSemiTestDefect.AutoGenerateColumns = false;
  91. // 初始化时间控件为当前日期
  92. this.dtpSemiTestDateStart.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  93. this.dtpSemiTestDateEnd.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  94. //查看成型线权限值
  95. getPurview();
  96. // 获取缺陷位置
  97. DataSet dsDefectPosition = (DataSet)DoAsync(new AsyncMethod(() =>
  98. {
  99. return SystemModuleProxy.Service.GetDictionaryData(0, "TPC006");
  100. }));
  101. //绑定缺陷位置
  102. string strDefectPositionId = string.Empty;
  103. string strDefectPosition = string.Empty;
  104. for (int j = 0; j < dsDefectPosition.Tables[0].Rows.Count; j++)
  105. {
  106. strDefectPositionId = "Col" + dsDefectPosition.Tables[0].Rows[j]["DICTIONARYID"].ToString();
  107. strDefectPosition = dsDefectPosition.Tables[0].Rows[j]["DICTIONARYVALUE"].ToString();
  108. this.dgvSemiTestDefect.Columns.Add(strDefectPositionId, strDefectPosition);
  109. this.dgvSemiTestDefect.Columns[strDefectPositionId].DataPropertyName = strDefectPositionId;
  110. }
  111. // 获取半检类别
  112. DataSet dsType = (DataSet)DoAsync(new AsyncMethod(() =>
  113. {
  114. return SystemModuleProxy.Service.GetDictionaryData(0, "TPC007");
  115. }));
  116. if (dsType != null && dsType.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  117. {
  118. this.dropSemiTestType.DisplayMember = "DictionaryValue";
  119. this.dropSemiTestType.ValueMember = "DictionaryID";
  120. this.dropSemiTestType.DataSource = dsType.Tables[0];
  121. }
  122. }
  123. catch (Exception ex)
  124. {
  125. // 对异常进行共通处理
  126. ExceptionManager.HandleEventException(this.ToString(),
  127. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  128. }
  129. }
  130. /// <summary>
  131. /// 关闭按钮
  132. /// </summary>
  133. /// <param name="sender"></param>
  134. /// <param name="e"></param>
  135. private void tsbtnClose_Click(object sender, EventArgs e)
  136. {
  137. this.Close();
  138. }
  139. /// <summary>
  140. /// 窗体关闭事件
  141. /// </summary>
  142. /// <param name="sender"></param>
  143. /// <param name="e"></param>
  144. private void F_PM_1601_FormClosed(object sender, FormClosedEventArgs e)
  145. {
  146. _instance = null;
  147. }
  148. /// <summary>
  149. /// 自动适应列宽
  150. /// </summary>
  151. /// <param name="sender"></param>
  152. /// <param name="e"></param>
  153. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  154. {
  155. this.dgvSemiTestDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  156. this.dgvSemiTestDefect.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  157. }
  158. /// <summary>
  159. /// 查询按钮事件
  160. /// </summary>
  161. /// <param name="sender"></param>
  162. /// <param name="e"></param>
  163. private void btnSearch_Click(object sender, EventArgs e)
  164. {
  165. try
  166. {
  167. CreatesearchReportEntity();
  168. DataSet dsSearchSemiTestList = (DataSet)DoAsync(new AsyncMethod(() =>
  169. {
  170. return PMModuleProxy.Service.GetSearchSemiTestListModule(semiTestDetailEntity);
  171. }));
  172. //清空数据
  173. this.dgvSemiTestDetail.DataSource = null;
  174. this.dgvSemiTestDefect.DataSource = null;
  175. this.tsbtnEdit.Enabled = false;
  176. if (dsSearchSemiTestList != null && dsSearchSemiTestList.Tables.Count > 0)
  177. {
  178. if (dsSearchSemiTestList.Tables[Constant.INT_IS_ZERO].Rows.Count <= Constant.INT_IS_ZERO)
  179. {
  180. // 提示未查找到数据
  181. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  182. MessageBoxButtons.OK, MessageBoxIcon.Information);
  183. }
  184. else
  185. {
  186. this.dgvSemiTestDetail.DataSource = dsSearchSemiTestList.Tables[Constant.INT_IS_ZERO];
  187. this.tsbtnEdit.Enabled = true;
  188. }
  189. }
  190. }
  191. catch (Exception ex)
  192. {
  193. this.btnSearch.Enabled = true;
  194. // 对异常进行共通处理
  195. ExceptionManager.HandleEventException(this.ToString(),
  196. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  197. }
  198. }
  199. /// <summary>
  200. /// 清空条件按钮事件
  201. /// </summary>
  202. /// <param name="sender"></param>
  203. /// <param name="e"></param>
  204. private void btnClearCondition_Click(object sender, EventArgs e)
  205. {
  206. this.scbGoods.ClearValue();
  207. this.scbCheckUser.ClearValue();
  208. this.scbUser.ClearValue();
  209. this.dropSemiTestType.SelectedValue = null;
  210. this.txtRemarks.Text = string.Empty;
  211. this.dtpSemiTestDateStart.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  212. this.dtpSemiTestDateEnd.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
  213. }
  214. /// <summary>
  215. /// 新建单击事件
  216. /// </summary>
  217. /// <param name="sender"></param>
  218. /// <param name="e"></param>
  219. private void tsbtnAdd_Click(object sender, EventArgs e)
  220. {
  221. try
  222. {
  223. F_PM_1602 frmPM1602 = new F_PM_1602();
  224. DialogResult dialogResult = frmPM1602.ShowDialog();
  225. // 重新加载GridView
  226. if (dialogResult == DialogResult.OK)
  227. {
  228. btnSearch_Click(sender, e);
  229. }
  230. }
  231. catch (Exception ex)
  232. {
  233. // 对异常进行共通处理
  234. ExceptionManager.HandleEventException(this.ToString(),
  235. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  236. }
  237. }
  238. /// <summary>
  239. /// 编辑单击事件
  240. /// </summary>
  241. /// <param name="sender"></param>
  242. /// <param name="e"></param>
  243. private void tsbtnEdit_Click(object sender, EventArgs e)
  244. {
  245. try
  246. {
  247. if (this.dgvSemiTestDetail.CurrentRow != null)
  248. {
  249. int SemiTestID = Convert.ToInt32(this.dgvSemiTestDetail.Rows[this.dgvSemiTestDetail.CurrentCell.RowIndex].Cells["SemiTestID"].Value.ToString());
  250. F_PM_1602 frmPM1602 = new F_PM_1602(SemiTestID);
  251. DialogResult dialogResult = frmPM1602.ShowDialog();
  252. // 重新加载GridView
  253. if (dialogResult == DialogResult.OK)
  254. {
  255. btnSearch_Click(sender, e);
  256. }
  257. }
  258. }
  259. catch (Exception ex)
  260. {
  261. // 对异常进行共通处理
  262. ExceptionManager.HandleEventException(this.ToString(),
  263. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  264. }
  265. }
  266. /// <summary>
  267. /// 发生改变事件
  268. /// </summary>
  269. /// <param name="sender"></param>
  270. /// <param name="e"></param>
  271. private void dgvSemiTestDetail_SelectionChanged(object sender, EventArgs e)
  272. {
  273. try
  274. {
  275. //判断是否为空
  276. if (this.dgvSemiTestDetail.CurrentRow == null)
  277. {
  278. return;
  279. }
  280. if (this.txtRemarks.ReadOnly)
  281. {
  282. return;
  283. }
  284. //获取数据信息
  285. DataGridViewRow dgvr = dgvSemiTestDetail.CurrentRow;
  286. int semiTestDetailId = Convert.ToInt32(dgvr.Cells["Semitestdetailid"].Value.ToString());
  287. DataSet dsSemiTestDefect = (DataSet)DoAsync(new AsyncMethod(() =>
  288. {
  289. return PMModuleProxy.Service.SearchSemiTestDetailInfo(semiTestDetailId);
  290. }));
  291. //清空数据
  292. this.dgvSemiTestDefect.DataSource = null;
  293. if (dsSemiTestDefect != null && dsSemiTestDefect.Tables.Count > 0)
  294. {
  295. if (dsSemiTestDefect.Tables[Constant.INT_IS_ZERO].Rows.Count <= Constant.INT_IS_ZERO)
  296. {
  297. // 提示未查找到数据
  298. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  299. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  300. }
  301. else
  302. {
  303. this.dgvSemiTestDefect.DataSource = dsSemiTestDefect.Tables[Constant.INT_IS_ZERO];
  304. }
  305. }
  306. }
  307. catch (Exception ex)
  308. {
  309. this.btnSearch.Enabled = true;
  310. this.btnClearCondition.Enabled = true;
  311. // 对异常进行共通处理
  312. ExceptionManager.HandleEventException(this.ToString(),
  313. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  314. }
  315. }
  316. #endregion
  317. #region 私有方法
  318. /// <summary>
  319. /// 搜索条件
  320. /// </summary>
  321. /// <returns></returns>
  322. private void CreatesearchReportEntity()
  323. {
  324. semiTestDetailEntity = new SemiTestDetailEntity();
  325. semiTestDetailEntity.GoodsIDS = this.scbGoods.CheckedPKMember;
  326. semiTestDetailEntity.TestUserIDS = scbCheckUser.CheckedPKMember;
  327. semiTestDetailEntity.Remarks = this.txtRemarks.Text.Trim();
  328. semiTestDetailEntity.GroutingUserIDS = scbUser.CheckedPKMember;
  329. semiTestDetailEntity.UserPurviews = this._userPurviews;
  330. if (this.dropSemiTestType.SelectedValue != null)
  331. {
  332. semiTestDetailEntity.SemiTestType = Convert.ToInt32(this.dropSemiTestType.SelectedValue);
  333. }
  334. string SemiTestDateStart = this.dtpSemiTestDateStart.Value.ToString("yyyy-MM-dd") + " 0:0:0";
  335. semiTestDetailEntity.SemiTestDateStart = Convert.ToDateTime(SemiTestDateStart);
  336. string SemiTestDateEnd = this.dtpSemiTestDateEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59";
  337. semiTestDetailEntity.SemiTestDateEnd = Convert.ToDateTime(SemiTestDateEnd);
  338. }
  339. /// <summary>
  340. /// 获取当前权限
  341. /// </summary>
  342. protected void getPurview()
  343. {
  344. try
  345. {
  346. StringBuilder sbUserPurview = new StringBuilder();
  347. //获取工号操作权限集
  348. DataSet dsUserPurview = (DataSet)DoAsync(new AsyncMethod(() =>
  349. {
  350. return SystemModuleProxy.Service.GetUserPurview(4, LogInUserInfo.CurrentUser.UserID);
  351. }));
  352. //拼接字符串
  353. if (dsUserPurview != null)
  354. {
  355. foreach (DataRow dr in dsUserPurview.Tables[Constant.INT_IS_ZERO].Rows)
  356. {
  357. sbUserPurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  358. }
  359. if (sbUserPurview.Length != Constant.INT_IS_ZERO)
  360. {
  361. this._userPurviews = sbUserPurview.ToString().Substring(Constant.INT_IS_ZERO, sbUserPurview.Length - 1);
  362. }
  363. }
  364. }
  365. catch (Exception ex)
  366. {
  367. throw ex;
  368. }
  369. }
  370. #endregion
  371. }
  372. }