F_PM_2105.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_2105.cs
  5. * 2.功能描述:注浆变更
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2015/06/19 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Reflection;
  13. using System.Text;
  14. using System.Windows.Forms;
  15. using Dongke.IBOSS.PRD.Basics.BaseControls;
  16. using Dongke.IBOSS.PRD.Basics.BaseResources;
  17. using Dongke.IBOSS.PRD.Basics.DockPanel;
  18. using Dongke.IBOSS.PRD.Client.CommonModule;
  19. using Dongke.IBOSS.PRD.Client.Controls;
  20. using Dongke.IBOSS.PRD.Client.DataModels;
  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_2105 : DKFormBase
  29. {
  30. #region 成员变量
  31. private int? _groutingDailyID; //注浆主表ID
  32. private DateTime? _groutingDate; //注浆日期
  33. private int? _groutingLineID; //成型线ID
  34. #endregion
  35. #region 构造函数
  36. public F_PM_2105()
  37. {
  38. InitializeComponent();
  39. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  40. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  41. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  42. this.Text = FormTitles.F_PM_2105;
  43. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  44. this.btnReplace.Text = ButtonText.BTN_REPLACE;
  45. this.btnCancelBarCode.Text = ButtonText.BTN_CANCELBINDBARCODE;
  46. }
  47. #endregion
  48. #region 事件
  49. /// <summary>
  50. /// 关闭按钮事件
  51. /// </summary>
  52. /// <param name="sender"></param>
  53. /// <param name="e"></param>
  54. private void tsbtnClose_Click(object sender, EventArgs e)
  55. {
  56. this.Close();
  57. }
  58. /// <summary>
  59. /// 窗体加载事件
  60. /// </summary>
  61. /// <param name="sender"></param>
  62. /// <param name="e"></param>
  63. private void F_PM_2105_Load(object sender, EventArgs e)
  64. {
  65. try
  66. {
  67. this.dgvGroutingDaily.AutoGenerateColumns = false;
  68. this.txtGroutingDate.Value = DateTime.Now;
  69. //this.dkGroutingLine.IsEnablePurview = true;
  70. //getPurviewLine();//获取成型线权限
  71. }
  72. catch (Exception ex)
  73. {
  74. // 对异常进行共通处理
  75. ExceptionManager.HandleEventException(this.ToString(),
  76. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  77. }
  78. }
  79. /// <summary>
  80. /// 自动列宽事件
  81. /// </summary>
  82. /// <param name="sender"></param>
  83. /// <param name="e"></param>
  84. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  85. {
  86. this.dgvGroutingDaily.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  87. }
  88. #endregion
  89. /// <summary>
  90. /// 清空条件按钮事件
  91. /// </summary>
  92. /// <param name="sender"></param>
  93. /// <param name="e"></param>
  94. private void btnClearCondition_Click(object sender, EventArgs e)
  95. {
  96. this.scbGroutingLine.ClearValue();
  97. this.txtGroutingDate.Value = DateTime.Now;
  98. }
  99. /// <summary>
  100. /// 查询按钮事件
  101. /// </summary>
  102. /// <param name="sender"></param>
  103. /// <param name="e"></param>
  104. private void btnSearch_Click(object sender, EventArgs e)
  105. {
  106. try
  107. {
  108. if (this.scbGroutingLine.Text == string.Empty)
  109. {
  110. // 提示
  111. MessageBox.Show("请选择成型线", this.Text,
  112. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  113. this.scbGroutingLine.Focus();
  114. return;
  115. }
  116. this.dgvGroutingDaily.DataSource = null;
  117. this.dgvGroutingDaily.DataSource = this.GetSearchData();
  118. }
  119. catch (Exception ex)
  120. {
  121. // 对异常进行共通处理
  122. ExceptionManager.HandleEventException(this.ToString(),
  123. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  124. }
  125. }
  126. /// <summary>
  127. /// 根据界面查询条件获取数据集
  128. /// </summary>
  129. private DataTable GetSearchData()
  130. {
  131. try
  132. {
  133. GroutingDailyEntity se = new GroutingDailyEntity();
  134. se.GroutingLineID = this.scbGroutingLine.SearchedPKMember;
  135. se.GroutingDate = this.txtGroutingDate.Value;
  136. se.GroutingBatchNo = (this.txtGroutingBatchNo.DataValue.HasValue ? (int)this.txtGroutingBatchNo.DataValue : 1);
  137. // 调用服务器端获取数据集
  138. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  139. {
  140. return PCModuleProxy.Service.GetFPM2105Data(se);
  141. }
  142. );
  143. if (sre.Status == Constant.ServiceResultStatus.Success)
  144. {
  145. if (sre.Data.Tables[0].Rows.Count > 0)
  146. {
  147. this._groutingDailyID = Convert.ToInt32(sre.Data.Tables[0].Rows[0]["GroutingDailyID"]);
  148. this._groutingDate = Convert.ToDateTime(sre.Data.Tables[0].Rows[0]["GroutingDate"]);
  149. this._groutingLineID = Convert.ToInt32(sre.Data.Tables[0].Rows[0]["GroutingLineId"]);
  150. }
  151. return sre.Data.Tables[0];
  152. }
  153. return null;
  154. }
  155. catch (Exception ex)
  156. {
  157. throw ex;
  158. }
  159. }
  160. /// <summary>
  161. /// 获取成型线权限
  162. /// </summary>
  163. protected void getPurviewLine()
  164. {
  165. try
  166. {
  167. //StringBuilder sbProcedurePurview = new StringBuilder();
  168. ////权限
  169. //DataSet dsProcedurePurview = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  170. //{
  171. // return SystemModuleProxy.Service.GetUserPurview(6, LogInUserInfo.CurrentUser.UserID);
  172. //}));
  173. //if (dsProcedurePurview != null)
  174. //{
  175. // foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  176. // {
  177. // sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  178. // }
  179. // if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  180. // {
  181. // this.dkGroutingLine.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  182. // this.dkGroutingLine.GroutingLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  183. // }
  184. //}
  185. }
  186. catch (Exception ex)
  187. {
  188. throw ex;
  189. }
  190. }
  191. /// <summary>
  192. /// 全选按钮事件
  193. /// </summary>
  194. /// <param name="sender"></param>
  195. /// <param name="e"></param>
  196. private void chkUserChoose_CheckedChanged(object sender, EventArgs e)
  197. {
  198. DataTable returnData = (DataTable)this.dgvGroutingDaily.DataSource;
  199. if (returnData != null)
  200. {
  201. int rightFlag = Convert.ToInt16(chkUserChoose.Checked);
  202. for (int i = 0; i < returnData.Rows.Count; i++)
  203. {
  204. returnData.Rows[i]["Sel"] = rightFlag;
  205. }
  206. }
  207. }
  208. /// <summary>
  209. /// 替换按钮事件
  210. /// </summary>
  211. /// <param name="sender"></param>
  212. /// <param name="e"></param>
  213. private void btnReplace_Click(object sender, EventArgs e)
  214. {
  215. string groutingUserCode = this.txtGroutingUserCode.Text.Trim();
  216. int? goodsid = this.dkGoodsCode.GoodsID;
  217. try
  218. {
  219. if (this._groutingDailyID == null)
  220. {
  221. // 提示信息
  222. MessageBox.Show("请先查询注浆信息!",
  223. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  224. return;
  225. }
  226. if (string.IsNullOrWhiteSpace(groutingUserCode) && goodsid == null)
  227. {
  228. // 提示信息
  229. MessageBox.Show("成型工号与产品编码至少填写一项!",
  230. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  231. return;
  232. }
  233. string GroutingDailyDetailIDs = "";
  234. DataTable dt = this.dgvGroutingDaily.DataSource as DataTable;
  235. if (dt != null && dt.Rows.Count > 0)
  236. {
  237. //dt.AcceptChanges();
  238. for (int i = 0; i < dt.Rows.Count; i++)
  239. {
  240. if (Convert.ToInt32(dt.Rows[i]["Sel"]) == 1)
  241. {
  242. GroutingDailyDetailIDs += dt.Rows[i]["GroutingDailyDetailID"].ToString() + ",";
  243. }
  244. }
  245. GroutingDailyDetailIDs = GroutingDailyDetailIDs.TrimEnd(',');
  246. }
  247. ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
  248. {
  249. return PCModuleProxy.Service.SetFPM2105Data(this._groutingLineID, this._groutingDailyID, GroutingDailyDetailIDs, Convert.ToDateTime(this._groutingDate), this.txtGroutingUserCode.Text.Trim(), this.dkGoodsCode.GoodsID);
  250. }
  251. );
  252. if (sre.Status == Constant.ServiceResultStatus.Success)
  253. {
  254. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  255. this.DialogResult = DialogResult.OK;
  256. this._groutingDailyID = null;
  257. this._groutingDate = null;
  258. this.dgvGroutingDaily.DataSource = null;
  259. this.txtGroutingUserCode.Text = string.Empty;
  260. this.dkGoodsCode.ClearControl();
  261. this.scbGroutingLine.ClearValue();
  262. this.txtGroutingDate.Value = DateTime.Now.Date;
  263. //this.Close();
  264. return;
  265. }
  266. if (sre.Status == Constant.ServiceResultStatus.Other)
  267. {
  268. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, sre.Message);
  269. }
  270. }
  271. catch (Exception ex)
  272. {
  273. // 对异常进行共通处理
  274. ExceptionManager.HandleEventException(this.ToString(),
  275. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  276. }
  277. }
  278. /// <summary>
  279. /// 取消绑定事件
  280. /// </summary>
  281. /// <param name="sender"></param>
  282. /// <param name="e"></param>
  283. private void btnCancelBarCode_Click(object sender, EventArgs e)
  284. {
  285. try
  286. {
  287. if (this._groutingDailyID == null)
  288. {
  289. // 提示信息
  290. MessageBox.Show("请先查询注浆信息!",
  291. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  292. return;
  293. }
  294. string BarCodes = "";
  295. DataTable dt = this.dgvGroutingDaily.DataSource as DataTable;
  296. if (dt != null && dt.Rows.Count > 0)
  297. {
  298. //dt.AcceptChanges();
  299. for (int i = 0; i < dt.Rows.Count; i++)
  300. {
  301. if (Convert.ToInt32(dt.Rows[i]["Sel"]) == 1 && dt.Rows[i]["BarCode"].ToString()!="")
  302. {
  303. BarCodes += dt.Rows[i]["BarCode"].ToString() + ",";
  304. }
  305. }
  306. BarCodes = BarCodes.TrimEnd(',');
  307. }
  308. if(BarCodes==string.Empty)
  309. {
  310. MessageBox.Show("请先选择取消绑定的条码!",
  311. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  312. return;
  313. }
  314. ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
  315. {
  316. return PCModuleProxy.Service.SetFPM2105CancelBarCodeData(BarCodes);
  317. }
  318. );
  319. if (sre.Status == Constant.ServiceResultStatus.Success)
  320. {
  321. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  322. this.DialogResult = DialogResult.OK;
  323. this._groutingDailyID = null;
  324. this._groutingDate = null;
  325. this.dgvGroutingDaily.DataSource = null;
  326. this.txtGroutingUserCode.Text = string.Empty;
  327. this.dkGoodsCode.ClearControl();
  328. this.scbGroutingLine.ClearValue();
  329. this.txtGroutingDate.Value = DateTime.Now.Date;
  330. return;
  331. }
  332. if (sre.Status == Constant.ServiceResultStatus.Other)
  333. {
  334. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, sre.Message);
  335. }
  336. }
  337. catch (Exception ex)
  338. {
  339. // 对异常进行共通处理
  340. ExceptionManager.HandleEventException(this.ToString(),
  341. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  342. }
  343. }
  344. }
  345. }