F_PM_0104.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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 : DKFormBase
  29. {
  30. #region 成员变量
  31. private DataRow[] _groutinginfo; // 返回调用画面选择成型线信息,包括:成型线ID,未注浆原因
  32. private DataTable _notGroutingRreason; // 未注浆原因,防止再次连接数据库
  33. #endregion
  34. #region 构造函数
  35. /// <summary>
  36. /// 构造函数
  37. /// </summary>
  38. public F_PM_0104()
  39. {
  40. InitializeComponent();
  41. // 为各个控件文本赋值
  42. this.InitializeControls();
  43. }
  44. #endregion
  45. #region 属性
  46. /// <summary>
  47. /// 返回选择的数据行
  48. /// </summary>
  49. public DataRow[] GroutingInfo
  50. {
  51. get
  52. {
  53. return this._groutinginfo;
  54. }
  55. set
  56. {
  57. this._groutinginfo = value;
  58. }
  59. }
  60. /// <summary>
  61. /// 未注浆原因
  62. /// </summary>
  63. public DataTable NotGroutingRreason
  64. {
  65. get
  66. {
  67. return this._notGroutingRreason;
  68. }
  69. set
  70. {
  71. this._notGroutingRreason = value;
  72. }
  73. }
  74. /// <summary>
  75. /// 注浆日期
  76. /// </summary>
  77. public DateTime GroutingDate
  78. {
  79. get
  80. {
  81. return this.dtpGroutingDate.Value.Date;
  82. }
  83. set
  84. {
  85. this.dtpGroutingDate.Value = value.Date;
  86. }
  87. }
  88. #endregion
  89. #region 控件事件
  90. /// <summary>
  91. /// 页面Load事件
  92. /// </summary>
  93. /// <param name="sender"></param>
  94. /// <param name="e"></param>
  95. private void F_PM_0104_Load(object sender, EventArgs e)
  96. {
  97. // 未注浆原因绑定数据
  98. this.NoGroutingRreason.DataSource = this._notGroutingRreason;
  99. this.NoGroutingRreason.ValueMember = "DictionaryID";
  100. this.NoGroutingRreason.DisplayMember = "DictionaryValue";
  101. this.dgvGroutingLine.AutoGenerateColumns = false;
  102. }
  103. /// <summary>
  104. /// 查询按钮按下事件
  105. /// </summary>
  106. /// <param name="sender"></param>
  107. /// <param name="e"></param>
  108. private void btnSearch_Click(object sender, System.EventArgs e)
  109. {
  110. try
  111. {
  112. FPM0104_SE se = new FPM0104_SE();
  113. se.GroutingDate = this.dtpGroutingDate.Value.Date;
  114. se.GroutingLineCode = this.txtGroutingLineCode.Text;
  115. se.GroutingLineName = this.txtGroutingLineName.Text;
  116. se.GroutingUserCode = this.txtUserCode.Text;
  117. // 根据注浆日期、成型线获取所有可注浆模具信息
  118. ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
  119. {
  120. return PMModuleProxyNew.Service.GetFPM0104SData(se);
  121. }
  122. );
  123. this.dgvGroutingLine.DataSource = null;
  124. this.DataSource = null;
  125. this.dgvGroutingLine.Columns["NoGroutingRreason"].ReadOnly = false;
  126. // 异常情况处理
  127. if (sre.Status == Constant.ServiceResultStatus.Success)
  128. {
  129. this.DataSource = sre.Data;
  130. this.DataSource.Tables[0].Columns.Add("NoGroutingRreason", typeof(decimal));
  131. this.DataSource.Tables[0].Columns.Add("SEL", typeof(int));
  132. this.dgvGroutingLine.DataSource = this.DataSource.Tables[0];
  133. this.dgvGroutingLine.IsSetInputColumnsColor = true;
  134. }
  135. }
  136. catch (Exception ex)
  137. {
  138. // 对异常进行共通处理
  139. ExceptionManager.HandleEventException(this.ToString(),
  140. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  141. }
  142. }
  143. /// <summary>
  144. /// 提交选择列内容的修改
  145. /// </summary>
  146. /// <param name="sender"></param>
  147. /// <param name="e"></param>
  148. private void dgvGroutingLine_CurrentCellDirtyStateChanged(object sender, EventArgs e)
  149. {
  150. try
  151. {
  152. if (this.dgvGroutingLine.CurrentRow != null && this.dgvGroutingLine.IsCurrentCellDirty)
  153. {
  154. if ("sel".Equals(this.dgvGroutingLine.Columns
  155. [this.dgvGroutingLine.CurrentCell.ColumnIndex].Name))
  156. {
  157. this.dgvGroutingLine.CommitEdit(DataGridViewDataErrorContexts.Commit);
  158. }
  159. }
  160. }
  161. catch (Exception ex)
  162. {
  163. // 对异常进行共通处理
  164. ExceptionManager.HandleEventException(this.ToString(),
  165. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  166. }
  167. }
  168. /// <summary>
  169. /// 选择复选框选中改变,未注浆原因才可以修改
  170. /// </summary>
  171. /// <param name="sender"></param>
  172. /// <param name="e"></param>
  173. private void dgvGroutingLine_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  174. {
  175. try
  176. {
  177. if (e.RowIndex > -1)
  178. {
  179. DataGridViewRow dataGridViewRow = this.dgvGroutingLine.Rows[e.RowIndex];
  180. // 如果是选择了该成型线,则对未注浆原因进行控制输入
  181. if ("sel".Equals(this.dgvGroutingLine.Columns[e.ColumnIndex].Name))
  182. {
  183. // 选择了成型线
  184. if ("1" == dataGridViewRow.Cells["sel"].Value.ToString())
  185. {
  186. dataGridViewRow.Cells["NoGroutingRreason"].ReadOnly = true;
  187. dataGridViewRow.Cells["NoGroutingRreason"].Value = DBNull.Value;
  188. }
  189. else
  190. {
  191. dataGridViewRow.Cells["NoGroutingRreason"].ReadOnly = false;
  192. }
  193. }
  194. }
  195. }
  196. catch (Exception ex)
  197. {
  198. // 对异常进行共通处理
  199. ExceptionManager.HandleEventException(this.ToString(),
  200. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  201. }
  202. }
  203. /// <summary>
  204. /// 排序后设置Grid状态
  205. /// </summary>
  206. /// <param name="sender"></param>
  207. /// <param name="e"></param>
  208. private void dgvGroutingLine_Sorted(object sender, EventArgs e)
  209. {
  210. foreach (DataGridViewRow row in this.dgvGroutingLine.Rows)
  211. {
  212. // 未注浆,可以输入未注浆原因
  213. if ("1" == row.Cells["sel"].Value.ToString())
  214. {
  215. row.Cells["NoGroutingRreason"].Value = DBNull.Value;
  216. row.Cells["NoGroutingRreason"].ReadOnly = true;
  217. }
  218. else
  219. {
  220. row.Cells["NoGroutingRreason"].ReadOnly = false;
  221. }
  222. }
  223. this.dgvGroutingLine.IsSetInputColumnsColor = true;
  224. }
  225. /// <summary>
  226. /// 确定按钮按下事件
  227. /// </summary>
  228. /// <param name="sender"></param>
  229. /// <param name="e"></param>
  230. private void btnOK_Click(object sender, System.EventArgs e)
  231. {
  232. try
  233. {
  234. if(this.DataSource == null || this.DataSource.Tables.Count == 0)
  235. {
  236. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_001);
  237. return;
  238. }
  239. this.DataSource.AcceptChanges();
  240. DataRow[] groutinginfo = this.DataSource.Tables[0].Select("SEL = 1 OR NoGroutingRreason IS NOT NULL");
  241. if (groutinginfo == null || groutinginfo.Length == 0)
  242. {
  243. this.dgvGroutingLine.IsSetInputColumnsColor = true;
  244. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_C_001);
  245. return;
  246. }
  247. this._groutinginfo = groutinginfo;
  248. this.DialogResult = DialogResult.OK;
  249. this.Close();
  250. }
  251. catch (Exception ex)
  252. {
  253. // 对异常进行共通处理
  254. ExceptionManager.HandleEventException(this.ToString(),
  255. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  256. }
  257. }
  258. /// <summary>
  259. /// 关闭按钮按下事件
  260. /// </summary>
  261. /// <param name="sender"></param>
  262. /// <param name="e"></param>
  263. private void btnClose_Click(object sender, System.EventArgs e)
  264. {
  265. this.DialogResult = DialogResult.Cancel;
  266. this.Close();
  267. }
  268. /// <summary>
  269. /// 全选复选框状态改变事件
  270. /// </summary>
  271. /// <param name="sender"></param>
  272. /// <param name="e"></param>
  273. private void cbSelectAll_CheckedChanged(object sender, EventArgs e)
  274. {
  275. foreach (DataGridViewRow dataGridViewRow in this.dgvGroutingLine.Rows)
  276. {
  277. dataGridViewRow.Cells["sel"].Value = this.cbSelectAll.Checked ? 1 : 0;
  278. }
  279. }
  280. #endregion
  281. #region 私有方法/函数
  282. /// <summary>
  283. /// 初始化控件
  284. /// </summary>
  285. private void InitializeControls()
  286. {
  287. this.Text = FormTitles.F_PM_0104;
  288. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  289. this.btnOK.Text = ButtonText.BTN_OK;
  290. this.btnCancel.Text = ButtonText.BTN_CANCEL;
  291. // 取客户端当天日期
  292. this.dtpGroutingDate.Value = DateTime.Now.Date;
  293. }
  294. #endregion
  295. }
  296. }