F_PM_0104_1.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. /*******************************************************************************
  2. * Copyright(c) 2015 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_0104.cs
  5. * 2.功能描述:可注浆的成型线选择画面
  6. * 选择或填写未注浆原因都会生成注浆日报
  7. * 1.选择:注浆标识为注浆,未注浆原因不可用
  8. * 2.填未注浆原因:注浆标识为未注浆并带有原因
  9. * 编辑履历:
  10. * 作者 日期 版本 修改内容
  11. * 欧阳涛 2015/03/27 1.00 新建
  12. *******************************************************************************/
  13. using System;
  14. using System.Data;
  15. using System.Reflection;
  16. using System.Windows.Forms;
  17. using Dongke.IBOSS.PRD.Basics.BaseControls;
  18. using Dongke.IBOSS.PRD.Basics.BaseResources;
  19. using Dongke.IBOSS.PRD.Client.CommonModule;
  20. using Dongke.IBOSS.PRD.Client.Controls;
  21. using Dongke.IBOSS.PRD.WCF.DataModels;
  22. using Dongke.IBOSS.PRD.WCF.Proxys;
  23. namespace Dongke.IBOSS.PRD.Client.PMModule
  24. {
  25. /// <summary>
  26. /// 可注浆的成型线选择画面
  27. /// </summary>
  28. public partial class F_PM_0104_1 : DKFormBase
  29. {
  30. #region 成员变量
  31. private DataRow[] _groutinginfo; // 返回调用画面选择成型线信息,包括:成型线ID,未注浆原因
  32. private DataTable _notGroutingRreason; // 未注浆原因,防止再次连接数据库
  33. private int _groutinglineid = -1;
  34. private DataTable _groutinguser = null;
  35. private DateTime _groutingDate = DateTime.Now.Date;
  36. #endregion
  37. #region 构造函数
  38. /// <summary>
  39. /// 构造函数
  40. /// </summary>
  41. public F_PM_0104_1()
  42. {
  43. InitializeComponent();
  44. // 为各个控件文本赋值
  45. this.InitializeControls();
  46. }
  47. #endregion
  48. #region 属性
  49. /// <summary>
  50. /// 返回选择的数据行
  51. /// </summary>
  52. public DataRow[] GroutingInfo
  53. {
  54. get
  55. {
  56. return this._groutinginfo;
  57. }
  58. set
  59. {
  60. this._groutinginfo = value;
  61. }
  62. }
  63. /// <summary>
  64. /// 未注浆原因
  65. /// </summary>
  66. public DataTable NotGroutingRreason
  67. {
  68. get
  69. {
  70. return this._notGroutingRreason;
  71. }
  72. set
  73. {
  74. this._notGroutingRreason = value;
  75. }
  76. }
  77. /// <summary>
  78. /// 注浆日期
  79. /// </summary>
  80. public DateTime GroutingDate
  81. {
  82. get
  83. {
  84. return this._groutingDate;
  85. //return this.dtpGroutingDate.Value.Date;
  86. }
  87. set
  88. {
  89. this.dtpGroutingDate.Value = value.Date;
  90. this._groutingDate = value.Date;
  91. }
  92. }
  93. #endregion
  94. #region 控件事件
  95. /// <summary>
  96. /// 页面Load事件
  97. /// </summary>
  98. /// <param name="sender"></param>
  99. /// <param name="e"></param>
  100. private void F_PM_0104_Load(object sender, EventArgs e)
  101. {
  102. // 未注浆原因绑定数据
  103. this.NoGroutingRreason.DataSource = this._notGroutingRreason;
  104. this.NoGroutingRreason.ValueMember = "DictionaryID";
  105. this.NoGroutingRreason.DisplayMember = "DictionaryValue";
  106. this.dgvGroutingLine.AutoGenerateColumns = false;
  107. this.dgvGroutingUser.AutoGenerateColumns = false;
  108. }
  109. /// <summary>
  110. /// 查询按钮按下事件
  111. /// </summary>
  112. /// <param name="sender"></param>
  113. /// <param name="e"></param>
  114. private void btnSearch_Click(object sender, System.EventArgs e)
  115. {
  116. try
  117. {
  118. FPM0104_SE se = new FPM0104_SE();
  119. se.GroutingDate = this.dtpGroutingDate.Value.Date;
  120. se.GroutingLineCode = this.txtGroutingLineCode.Text;
  121. se.GroutingLineName = this.txtGroutingLineName.Text;
  122. se.GroutingUserCode = this.txtUserCode.Text;
  123. se.Monitorcode = this.txtMUserCode.Text;
  124. this.dgvGroutingLine.DataSource = null;
  125. this.DataSource = null;
  126. this.dgvGroutingLine.Columns["NoGroutingRreason"].ReadOnly = false;
  127. this._groutinguser = null;
  128. this.dgvGroutingUser.DataSource = null;
  129. // 根据注浆日期、成型线获取所有可注浆模具信息
  130. ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
  131. {
  132. return PMModuleProxyNew.Service.GetFPM0104SData(se);
  133. }
  134. );
  135. // 异常情况处理
  136. if (sre.Status == Constant.ServiceResultStatus.Success)
  137. {
  138. this._groutingDate = se.GroutingDate;
  139. this.DataSource = sre.Data;
  140. this.DataSource.Tables[0].Columns.Add("NoGroutingRreason", typeof(decimal));
  141. this.DataSource.Tables[0].Columns.Add("SEL", typeof(int));
  142. this.dgvGroutingLine.DataSource = this.DataSource.Tables[0];
  143. foreach (DataGridViewRow row in this.dgvGroutingLine.Rows)
  144. {
  145. string canManyTimes = row.Cells["CanManyTimes"].Value.ToString();
  146. // 多次注浆
  147. if ("1" == canManyTimes)
  148. {
  149. row.Cells["GroutingNum"].ReadOnly = false;
  150. row.Cells["GroutingNum"].Value = 1;
  151. }
  152. else
  153. {
  154. row.Cells["GroutingNum"].ReadOnly = true;
  155. }
  156. }
  157. this.dgvGroutingLine.IsSetInputColumnsColor = true;
  158. this._groutinguser = this.DataSource.Tables[1];
  159. this._groutinguser.DefaultView.RowFilter = "1=0";
  160. this.dgvGroutingUser.DataSource = this._groutinguser;
  161. }
  162. if (sre.Status == Constant.ServiceResultStatus.Other)
  163. {
  164. if (sre.OtherStatus == -1)
  165. {
  166. MessageBox.Show(sre.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  167. }
  168. }
  169. }
  170. catch (Exception ex)
  171. {
  172. // 对异常进行共通处理
  173. ExceptionManager.HandleEventException(this.ToString(),
  174. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  175. }
  176. }
  177. /// <summary>
  178. /// 提交选择列内容的修改
  179. /// </summary>
  180. /// <param name="sender"></param>
  181. /// <param name="e"></param>
  182. private void dgvGroutingLine_CurrentCellDirtyStateChanged(object sender, EventArgs e)
  183. {
  184. try
  185. {
  186. if (this.dgvGroutingLine.CurrentRow != null && this.dgvGroutingLine.IsCurrentCellDirty)
  187. {
  188. if ("sel".Equals(this.dgvGroutingLine.Columns
  189. [this.dgvGroutingLine.CurrentCell.ColumnIndex].Name))
  190. {
  191. this.dgvGroutingLine.CommitEdit(DataGridViewDataErrorContexts.Commit);
  192. }
  193. }
  194. }
  195. catch (Exception ex)
  196. {
  197. // 对异常进行共通处理
  198. ExceptionManager.HandleEventException(this.ToString(),
  199. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  200. }
  201. }
  202. /// <summary>
  203. /// 选择复选框选中改变,未注浆原因才可以修改
  204. /// </summary>
  205. /// <param name="sender"></param>
  206. /// <param name="e"></param>
  207. private void dgvGroutingLine_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  208. {
  209. try
  210. {
  211. if (e.RowIndex > -1)
  212. {
  213. DataGridViewRow dataGridViewRow = this.dgvGroutingLine.Rows[e.RowIndex];
  214. // 如果是选择了该成型线,则对未注浆原因进行控制输入
  215. if ("sel".Equals(this.dgvGroutingLine.Columns[e.ColumnIndex].Name))
  216. {
  217. // 选择了成型线
  218. if ("1" == dataGridViewRow.Cells["sel"].Value.ToString())
  219. {
  220. dataGridViewRow.Cells["NoGroutingRreason"].ReadOnly = true;
  221. dataGridViewRow.Cells["NoGroutingRreason"].Value = DBNull.Value;
  222. }
  223. else
  224. {
  225. dataGridViewRow.Cells["NoGroutingRreason"].ReadOnly = false;
  226. }
  227. }
  228. }
  229. }
  230. catch (Exception ex)
  231. {
  232. // 对异常进行共通处理
  233. ExceptionManager.HandleEventException(this.ToString(),
  234. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  235. }
  236. }
  237. /// <summary>
  238. /// 排序后设置Grid状态
  239. /// </summary>
  240. /// <param name="sender"></param>
  241. /// <param name="e"></param>
  242. private void dgvGroutingLine_Sorted(object sender, EventArgs e)
  243. {
  244. foreach (DataGridViewRow row in this.dgvGroutingLine.Rows)
  245. {
  246. // 未注浆,可以输入未注浆原因
  247. if ("1" == row.Cells["sel"].Value.ToString())
  248. {
  249. row.Cells["NoGroutingRreason"].Value = DBNull.Value;
  250. row.Cells["NoGroutingRreason"].ReadOnly = true;
  251. }
  252. else
  253. {
  254. row.Cells["NoGroutingRreason"].ReadOnly = false;
  255. }
  256. string canManyTimes = row.Cells["CanManyTimes"].Value.ToString();
  257. // 多次注浆
  258. if ("1" == canManyTimes)
  259. {
  260. row.Cells["GroutingNum"].ReadOnly = false;
  261. }
  262. else
  263. {
  264. row.Cells["GroutingNum"].ReadOnly = true;
  265. }
  266. }
  267. this.dgvGroutingLine.IsSetInputColumnsColor = true;
  268. }
  269. /// <summary>
  270. /// 确定按钮按下事件
  271. /// </summary>
  272. /// <param name="sender"></param>
  273. /// <param name="e"></param>
  274. private void btnOK_Click(object sender, System.EventArgs e)
  275. {
  276. try
  277. {
  278. this._groutinginfo = null;
  279. if (this.DataSource == null || this.DataSource.Tables.Count == 0)
  280. {
  281. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_001);
  282. return;
  283. }
  284. this.DataSource.AcceptChanges();
  285. DataRow[] groutinginfo = this.DataSource.Tables[0].Select("SEL = 1 OR NoGroutingRreason IS NOT NULL");
  286. if (groutinginfo == null || groutinginfo.Length == 0)
  287. {
  288. this.dgvGroutingLine.IsSetInputColumnsColor = true;
  289. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_001);
  290. return;
  291. }
  292. foreach (DataRow item in groutinginfo)
  293. {
  294. object userid = item["GroutingUserID"];
  295. if (userid == null || userid == DBNull.Value)
  296. {
  297. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_006,
  298. string.Format("成型线【{0}】没有选择成型工号。", item["GroutingLineCode"]));
  299. return;
  300. }
  301. object num = item["GroutingNum"];
  302. if (num == null || num == DBNull.Value)
  303. {
  304. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_006,
  305. string.Format("成型线【{0}】没有输入注浆次数。", item["GroutingLineCode"]));
  306. return;
  307. }
  308. }
  309. this._groutinginfo = groutinginfo;
  310. this.DialogResult = DialogResult.OK;
  311. this.Close();
  312. }
  313. catch (Exception ex)
  314. {
  315. // 对异常进行共通处理
  316. ExceptionManager.HandleEventException(this.ToString(),
  317. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  318. }
  319. finally
  320. {
  321. if (this._groutinginfo == null)
  322. {
  323. this.dgvGroutingLine_Sorted(null, null);
  324. }
  325. }
  326. }
  327. /// <summary>
  328. /// 关闭按钮按下事件
  329. /// </summary>
  330. /// <param name="sender"></param>
  331. /// <param name="e"></param>
  332. private void btnClose_Click(object sender, System.EventArgs e)
  333. {
  334. this.DialogResult = DialogResult.Cancel;
  335. this.Close();
  336. }
  337. /// <summary>
  338. /// 全选复选框状态改变事件
  339. /// </summary>
  340. /// <param name="sender"></param>
  341. /// <param name="e"></param>
  342. private void cbSelectAll_CheckedChanged(object sender, EventArgs e)
  343. {
  344. foreach (DataGridViewRow dataGridViewRow in this.dgvGroutingLine.Rows)
  345. {
  346. dataGridViewRow.Cells["sel"].Value = this.cbSelectAll.Checked ? 1 : 0;
  347. }
  348. }
  349. #endregion
  350. #region 私有方法/函数
  351. /// <summary>
  352. /// 初始化控件
  353. /// </summary>
  354. private void InitializeControls()
  355. {
  356. this.Text = FormTitles.F_PM_0104;
  357. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  358. this.btnOK.Text = ButtonText.BTN_OK;
  359. this.btnCancel.Text = ButtonText.BTN_CANCEL;
  360. // 取客户端当天日期
  361. this.dtpGroutingDate.Value = DateTime.Now.Date;
  362. }
  363. #endregion
  364. private void dgvGroutingLine_SelectionChanged(object sender, EventArgs e)
  365. {
  366. try
  367. {
  368. if (this._groutinguser == null || this._groutinguser.Rows.Count == 0)
  369. {
  370. return;
  371. }
  372. DataGridViewRow dgvr = this.dgvGroutingLine.CurrentRow;
  373. if (dgvr == null)
  374. {
  375. this._groutinguser.DefaultView.RowFilter = "1=0";
  376. return;
  377. }
  378. int glid = System.Convert.ToInt32(dgvr.Cells["GroutingLineID"].Value);
  379. if (this._groutinglineid != glid)
  380. {
  381. // 成型工个数
  382. int uc = System.Convert.ToInt32(dgvr.Cells["UserCount"].Value);
  383. if (uc > 1)
  384. {
  385. this._groutinguser.DefaultView.RowFilter = "GroutingLineID = " + glid;
  386. }
  387. else
  388. {
  389. this._groutinguser.DefaultView.RowFilter = "1=0";
  390. }
  391. this._groutinglineid = glid;
  392. }
  393. }
  394. catch (Exception ex)
  395. {
  396. // 对异常进行共通处理
  397. ExceptionManager.HandleEventException(this.ToString(),
  398. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  399. }
  400. }
  401. private void dgvGroutingUser_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  402. {
  403. try
  404. {
  405. if (e.ColumnIndex < 0 || e.RowIndex < 0)
  406. {
  407. return;
  408. }
  409. if (this._groutinguser == null || this._groutinguser.Rows.Count == 0)
  410. {
  411. return;
  412. }
  413. DataGridViewRow dgvrGL = this.dgvGroutingLine.CurrentRow;
  414. if (dgvrGL == null)
  415. {
  416. return;
  417. }
  418. DataGridViewRow dgvrGU = this.dgvGroutingUser.CurrentRow;
  419. if (dgvrGU == null)
  420. {
  421. return;
  422. }
  423. dgvrGL.Cells["GroutingUserID"].Value = dgvrGU.Cells["GUUserID"].Value;
  424. dgvrGL.Cells["GroutingUserCode"].Value = dgvrGU.Cells["GUUserCode"].Value;
  425. //DataRowView drv = dgvrGL.DataBoundItem as DataRowView;
  426. //if (drv != null)
  427. //{
  428. // drv.EndEdit();
  429. //}
  430. }
  431. catch (Exception ex)
  432. {
  433. // 对异常进行共通处理
  434. ExceptionManager.HandleEventException(this.ToString(),
  435. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  436. }
  437. }
  438. private void btnAdaptive_Click(object sender, EventArgs e)
  439. {
  440. this.dgvGroutingLine.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  441. this.dgvGroutingUser.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  442. }
  443. private void btnClearCondition_Click(object sender, EventArgs e)
  444. {
  445. this.txtGroutingLineCode.Clear();
  446. this.txtUserCode.Clear();
  447. this.txtGroutingLineName.Clear();
  448. this.dtpGroutingDate.Value = DateTime.Now.Date;
  449. }
  450. }
  451. }