F_PM_0104_1.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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. }
  151. else
  152. {
  153. row.Cells["GroutingNum"].ReadOnly = true;
  154. }
  155. }
  156. this.dgvGroutingLine.IsSetInputColumnsColor = true;
  157. this._groutinguser = this.DataSource.Tables[1];
  158. this._groutinguser.DefaultView.RowFilter = "1=0";
  159. this.dgvGroutingUser.DataSource = this._groutinguser;
  160. }
  161. if (sre.Status == Constant.ServiceResultStatus.Other)
  162. {
  163. if (sre.OtherStatus == -1)
  164. {
  165. MessageBox.Show(sre.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  166. }
  167. }
  168. }
  169. catch (Exception ex)
  170. {
  171. // 对异常进行共通处理
  172. ExceptionManager.HandleEventException(this.ToString(),
  173. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  174. }
  175. }
  176. /// <summary>
  177. /// 提交选择列内容的修改
  178. /// </summary>
  179. /// <param name="sender"></param>
  180. /// <param name="e"></param>
  181. private void dgvGroutingLine_CurrentCellDirtyStateChanged(object sender, EventArgs e)
  182. {
  183. try
  184. {
  185. if (this.dgvGroutingLine.CurrentRow != null && this.dgvGroutingLine.IsCurrentCellDirty)
  186. {
  187. if ("sel".Equals(this.dgvGroutingLine.Columns
  188. [this.dgvGroutingLine.CurrentCell.ColumnIndex].Name))
  189. {
  190. this.dgvGroutingLine.CommitEdit(DataGridViewDataErrorContexts.Commit);
  191. }
  192. }
  193. }
  194. catch (Exception ex)
  195. {
  196. // 对异常进行共通处理
  197. ExceptionManager.HandleEventException(this.ToString(),
  198. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  199. }
  200. }
  201. /// <summary>
  202. /// 选择复选框选中改变,未注浆原因才可以修改
  203. /// </summary>
  204. /// <param name="sender"></param>
  205. /// <param name="e"></param>
  206. private void dgvGroutingLine_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  207. {
  208. try
  209. {
  210. if (e.RowIndex > -1)
  211. {
  212. DataGridViewRow dataGridViewRow = this.dgvGroutingLine.Rows[e.RowIndex];
  213. // 如果是选择了该成型线,则对未注浆原因进行控制输入
  214. if ("sel".Equals(this.dgvGroutingLine.Columns[e.ColumnIndex].Name))
  215. {
  216. // 选择了成型线
  217. if ("1" == dataGridViewRow.Cells["sel"].Value.ToString())
  218. {
  219. dataGridViewRow.Cells["NoGroutingRreason"].ReadOnly = true;
  220. dataGridViewRow.Cells["NoGroutingRreason"].Value = DBNull.Value;
  221. }
  222. else
  223. {
  224. dataGridViewRow.Cells["NoGroutingRreason"].ReadOnly = false;
  225. }
  226. }
  227. }
  228. }
  229. catch (Exception ex)
  230. {
  231. // 对异常进行共通处理
  232. ExceptionManager.HandleEventException(this.ToString(),
  233. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  234. }
  235. }
  236. /// <summary>
  237. /// 排序后设置Grid状态
  238. /// </summary>
  239. /// <param name="sender"></param>
  240. /// <param name="e"></param>
  241. private void dgvGroutingLine_Sorted(object sender, EventArgs e)
  242. {
  243. foreach (DataGridViewRow row in this.dgvGroutingLine.Rows)
  244. {
  245. // 未注浆,可以输入未注浆原因
  246. if ("1" == row.Cells["sel"].Value.ToString())
  247. {
  248. row.Cells["NoGroutingRreason"].Value = DBNull.Value;
  249. row.Cells["NoGroutingRreason"].ReadOnly = true;
  250. }
  251. else
  252. {
  253. row.Cells["NoGroutingRreason"].ReadOnly = false;
  254. }
  255. string canManyTimes = row.Cells["CanManyTimes"].Value.ToString();
  256. // 多次注浆
  257. if ("1" == canManyTimes)
  258. {
  259. row.Cells["GroutingNum"].ReadOnly = false;
  260. }
  261. else
  262. {
  263. row.Cells["GroutingNum"].ReadOnly = true;
  264. }
  265. }
  266. this.dgvGroutingLine.IsSetInputColumnsColor = true;
  267. }
  268. /// <summary>
  269. /// 确定按钮按下事件
  270. /// </summary>
  271. /// <param name="sender"></param>
  272. /// <param name="e"></param>
  273. private void btnOK_Click(object sender, System.EventArgs e)
  274. {
  275. try
  276. {
  277. this._groutinginfo = null;
  278. if (this.DataSource == null || this.DataSource.Tables.Count == 0)
  279. {
  280. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_001);
  281. return;
  282. }
  283. this.DataSource.AcceptChanges();
  284. DataRow[] groutinginfo = this.DataSource.Tables[0].Select("SEL = 1 OR NoGroutingRreason IS NOT NULL");
  285. if (groutinginfo == null || groutinginfo.Length == 0)
  286. {
  287. this.dgvGroutingLine.IsSetInputColumnsColor = true;
  288. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_001);
  289. return;
  290. }
  291. foreach (DataRow item in groutinginfo)
  292. {
  293. object userid = item["GroutingUserID"];
  294. if (userid == null || userid == DBNull.Value)
  295. {
  296. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_006,
  297. string.Format("成型线【{0}】没有选择成型工号。", item["GroutingLineCode"]));
  298. return;
  299. }
  300. object num = item["GroutingNum"];
  301. if (num == null || num == DBNull.Value)
  302. {
  303. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_006,
  304. string.Format("成型线【{0}】没有输入注浆次数。", item["GroutingLineCode"]));
  305. return;
  306. }
  307. }
  308. this._groutinginfo = groutinginfo;
  309. this.DialogResult = DialogResult.OK;
  310. this.Close();
  311. }
  312. catch (Exception ex)
  313. {
  314. // 对异常进行共通处理
  315. ExceptionManager.HandleEventException(this.ToString(),
  316. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  317. }
  318. finally
  319. {
  320. if (this._groutinginfo == null)
  321. {
  322. this.dgvGroutingLine_Sorted(null, null);
  323. }
  324. }
  325. }
  326. /// <summary>
  327. /// 关闭按钮按下事件
  328. /// </summary>
  329. /// <param name="sender"></param>
  330. /// <param name="e"></param>
  331. private void btnClose_Click(object sender, System.EventArgs e)
  332. {
  333. this.DialogResult = DialogResult.Cancel;
  334. this.Close();
  335. }
  336. /// <summary>
  337. /// 全选复选框状态改变事件
  338. /// </summary>
  339. /// <param name="sender"></param>
  340. /// <param name="e"></param>
  341. private void cbSelectAll_CheckedChanged(object sender, EventArgs e)
  342. {
  343. foreach (DataGridViewRow dataGridViewRow in this.dgvGroutingLine.Rows)
  344. {
  345. dataGridViewRow.Cells["sel"].Value = this.cbSelectAll.Checked ? 1 : 0;
  346. }
  347. }
  348. #endregion
  349. #region 私有方法/函数
  350. /// <summary>
  351. /// 初始化控件
  352. /// </summary>
  353. private void InitializeControls()
  354. {
  355. this.Text = FormTitles.F_PM_0104;
  356. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  357. this.btnOK.Text = ButtonText.BTN_OK;
  358. this.btnCancel.Text = ButtonText.BTN_CANCEL;
  359. // 取客户端当天日期
  360. this.dtpGroutingDate.Value = DateTime.Now.Date;
  361. }
  362. #endregion
  363. private void dgvGroutingLine_SelectionChanged(object sender, EventArgs e)
  364. {
  365. try
  366. {
  367. if (this._groutinguser == null || this._groutinguser.Rows.Count == 0)
  368. {
  369. return;
  370. }
  371. DataGridViewRow dgvr = this.dgvGroutingLine.CurrentRow;
  372. if (dgvr == null)
  373. {
  374. this._groutinguser.DefaultView.RowFilter = "1=0";
  375. return;
  376. }
  377. int glid = System.Convert.ToInt32(dgvr.Cells["GroutingLineID"].Value);
  378. if (this._groutinglineid != glid)
  379. {
  380. // 成型工个数
  381. int uc = System.Convert.ToInt32(dgvr.Cells["UserCount"].Value);
  382. if (uc > 1)
  383. {
  384. this._groutinguser.DefaultView.RowFilter = "GroutingLineID = " + glid;
  385. }
  386. else
  387. {
  388. this._groutinguser.DefaultView.RowFilter = "1=0";
  389. }
  390. this._groutinglineid = glid;
  391. }
  392. }
  393. catch (Exception ex)
  394. {
  395. // 对异常进行共通处理
  396. ExceptionManager.HandleEventException(this.ToString(),
  397. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  398. }
  399. }
  400. private void dgvGroutingUser_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  401. {
  402. try
  403. {
  404. if (e.ColumnIndex < 0 || e.RowIndex < 0)
  405. {
  406. return;
  407. }
  408. if (this._groutinguser == null || this._groutinguser.Rows.Count == 0)
  409. {
  410. return;
  411. }
  412. DataGridViewRow dgvrGL = this.dgvGroutingLine.CurrentRow;
  413. if (dgvrGL == null)
  414. {
  415. return;
  416. }
  417. DataGridViewRow dgvrGU = this.dgvGroutingUser.CurrentRow;
  418. if (dgvrGU == null)
  419. {
  420. return;
  421. }
  422. dgvrGL.Cells["GroutingUserID"].Value = dgvrGU.Cells["GUUserID"].Value;
  423. dgvrGL.Cells["GroutingUserCode"].Value = dgvrGU.Cells["GUUserCode"].Value;
  424. //DataRowView drv = dgvrGL.DataBoundItem as DataRowView;
  425. //if (drv != null)
  426. //{
  427. // drv.EndEdit();
  428. //}
  429. }
  430. catch (Exception ex)
  431. {
  432. // 对异常进行共通处理
  433. ExceptionManager.HandleEventException(this.ToString(),
  434. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  435. }
  436. }
  437. private void btnAdaptive_Click(object sender, EventArgs e)
  438. {
  439. this.dgvGroutingLine.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  440. this.dgvGroutingUser.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  441. }
  442. private void btnClearCondition_Click(object sender, EventArgs e)
  443. {
  444. this.txtGroutingLineCode.Clear();
  445. this.txtUserCode.Clear();
  446. this.txtGroutingLineName.Clear();
  447. this.dtpGroutingDate.Value = DateTime.Now.Date;
  448. }
  449. }
  450. }