F_PM_0104_1.cs 17 KB

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