F_PM_2105.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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. this.bcode.Text = "";
  99. }
  100. /// <summary>
  101. /// 查询按钮事件
  102. /// </summary>
  103. /// <param name="sender"></param>
  104. /// <param name="e"></param>
  105. private void btnSearch_Click(object sender, EventArgs e)
  106. {
  107. try
  108. {
  109. if (this.bcode.Text == string.Empty)
  110. {
  111. if (this.scbGroutingLine.Text == string.Empty)
  112. {
  113. // 提示
  114. MessageBox.Show("请选择成型线", this.Text,
  115. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  116. this.scbGroutingLine.Focus();
  117. return;
  118. }
  119. }
  120. this.dgvGroutingDaily.DataSource = null;
  121. this.dgvGroutingDaily.DataSource = this.GetSearchData();
  122. }
  123. catch (Exception ex)
  124. {
  125. // 对异常进行共通处理
  126. ExceptionManager.HandleEventException(this.ToString(),
  127. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  128. }
  129. }
  130. /// <summary>
  131. /// 根据界面查询条件获取数据集
  132. /// </summary>
  133. private DataTable GetSearchData()
  134. {
  135. try
  136. {
  137. GroutingDailyEntity se = new GroutingDailyEntity();
  138. if (this.bcode.Text == string.Empty)
  139. {
  140. se.GroutingLineID = this.scbGroutingLine.SearchedPKMember;
  141. se.GroutingDate = this.txtGroutingDate.Value;
  142. se.GroutingBatchNo = (this.txtGroutingBatchNo.DataValue.HasValue ? (int)this.txtGroutingBatchNo.DataValue : 1);
  143. }
  144. else
  145. {
  146. se.BarCode = this.bcode.TextValue;
  147. }
  148. // 调用服务器端获取数据集
  149. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  150. {
  151. return PCModuleProxy.Service.GetFPM2105Data(se);
  152. }
  153. );
  154. if (sre.Status == Constant.ServiceResultStatus.Success)
  155. {
  156. if (sre.Data.Tables[0].Rows.Count > 0)
  157. {
  158. this._groutingDailyID = Convert.ToInt32(sre.Data.Tables[0].Rows[0]["GroutingDailyID"]);
  159. this._groutingDate = Convert.ToDateTime(sre.Data.Tables[0].Rows[0]["GroutingDate"]);
  160. this._groutingLineID = Convert.ToInt32(sre.Data.Tables[0].Rows[0]["GroutingLineId"]);
  161. }
  162. return sre.Data.Tables[0];
  163. }
  164. return null;
  165. }
  166. catch (Exception ex)
  167. {
  168. throw ex;
  169. }
  170. }
  171. /// <summary>
  172. /// 获取成型线权限
  173. /// </summary>
  174. protected void getPurviewLine()
  175. {
  176. try
  177. {
  178. //StringBuilder sbProcedurePurview = new StringBuilder();
  179. ////权限
  180. //DataSet dsProcedurePurview = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  181. //{
  182. // return SystemModuleProxy.Service.GetUserPurview(6, LogInUserInfo.CurrentUser.UserID);
  183. //}));
  184. //if (dsProcedurePurview != null)
  185. //{
  186. // foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  187. // {
  188. // sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  189. // }
  190. // if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  191. // {
  192. // this.dkGroutingLine.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  193. // this.dkGroutingLine.GroutingLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  194. // }
  195. //}
  196. }
  197. catch (Exception ex)
  198. {
  199. throw ex;
  200. }
  201. }
  202. /// <summary>
  203. /// 全选按钮事件
  204. /// </summary>
  205. /// <param name="sender"></param>
  206. /// <param name="e"></param>
  207. private void chkUserChoose_CheckedChanged(object sender, EventArgs e)
  208. {
  209. DataTable returnData = (DataTable)this.dgvGroutingDaily.DataSource;
  210. if (returnData != null)
  211. {
  212. int rightFlag = Convert.ToInt16(chkUserChoose.Checked);
  213. for (int i = 0; i < returnData.Rows.Count; i++)
  214. {
  215. returnData.Rows[i]["Sel"] = rightFlag;
  216. }
  217. }
  218. }
  219. /// <summary>
  220. /// 替换按钮事件
  221. /// </summary>
  222. /// <param name="sender"></param>
  223. /// <param name="e"></param>
  224. private void btnReplace_Click(object sender, EventArgs e)
  225. {
  226. //表格选择框必须有选中项
  227. DataTable dtSel = this.dgvGroutingDaily.DataSource as DataTable;
  228. int SelCount = 0;
  229. if (dtSel != null && dtSel.Rows.Count > 0)
  230. {
  231. for (int i = 0; i < dtSel.Rows.Count; i++)
  232. {
  233. if (Convert.ToInt32(dtSel.Rows[i]["Sel"]) == 1)
  234. {
  235. SelCount++;
  236. }
  237. }
  238. if (SelCount == 0)
  239. {
  240. // 提示信息
  241. MessageBox.Show("请选择要变更项!",
  242. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  243. return;
  244. }
  245. SelCount = 0;
  246. }
  247. string groutingUserCode = this.txtGroutingUserCode.Text.Trim();
  248. int? goodsid = this.dkGoodsCode.GoodsID;
  249. try
  250. {
  251. if (this._groutingDailyID == null)
  252. {
  253. // 提示信息
  254. MessageBox.Show("请先查询注浆信息!",
  255. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  256. return;
  257. }
  258. if (string.IsNullOrWhiteSpace(groutingUserCode) && goodsid == null)
  259. {
  260. // 提示信息
  261. MessageBox.Show("成型工号与产品编码至少填写一项!",
  262. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  263. return;
  264. }
  265. string GroutingDailyDetailIDs = "";
  266. DataTable dt = this.dgvGroutingDaily.DataSource as DataTable;
  267. if (dt != null && dt.Rows.Count > 0)
  268. {
  269. //dt.AcceptChanges();
  270. for (int i = 0; i < dt.Rows.Count; i++)
  271. {
  272. if (Convert.ToInt32(dt.Rows[i]["Sel"]) == 1)
  273. {
  274. GroutingDailyDetailIDs += dt.Rows[i]["GroutingDailyDetailID"].ToString() + ",";
  275. }
  276. }
  277. GroutingDailyDetailIDs = GroutingDailyDetailIDs.TrimEnd(',');
  278. }
  279. ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
  280. {
  281. return PCModuleProxy.Service.SetFPM2105Data(this._groutingLineID, this._groutingDailyID, GroutingDailyDetailIDs, Convert.ToDateTime(this._groutingDate), this.txtGroutingUserCode.Text.Trim(), this.dkGoodsCode.GoodsID);
  282. }
  283. );
  284. if (sre.Status == Constant.ServiceResultStatus.Success)
  285. {
  286. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  287. this.DialogResult = DialogResult.OK;
  288. this._groutingDailyID = null;
  289. this._groutingDate = null;
  290. this.dgvGroutingDaily.DataSource = null;
  291. this.txtGroutingUserCode.Text = string.Empty;
  292. this.dkGoodsCode.ClearControl();
  293. this.scbGroutingLine.ClearValue();
  294. this.txtGroutingDate.Value = DateTime.Now.Date;
  295. //this.Close();
  296. return;
  297. }
  298. if (sre.Status == Constant.ServiceResultStatus.Other)
  299. {
  300. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, sre.Message);
  301. }
  302. }
  303. catch (Exception ex)
  304. {
  305. // 对异常进行共通处理
  306. ExceptionManager.HandleEventException(this.ToString(),
  307. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  308. }
  309. }
  310. /// <summary>
  311. /// 取消绑定事件
  312. /// </summary>
  313. /// <param name="sender"></param>
  314. /// <param name="e"></param>
  315. private void btnCancelBarCode_Click(object sender, EventArgs e)
  316. {
  317. try
  318. {
  319. if (this._groutingDailyID == null)
  320. {
  321. // 提示信息
  322. MessageBox.Show("请先查询注浆信息!",
  323. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  324. return;
  325. }
  326. string BarCodes = "";
  327. DataTable dt = this.dgvGroutingDaily.DataSource as DataTable;
  328. if (dt != null && dt.Rows.Count > 0)
  329. {
  330. //dt.AcceptChanges();
  331. for (int i = 0; i < dt.Rows.Count; i++)
  332. {
  333. if (Convert.ToInt32(dt.Rows[i]["Sel"]) == 1 && dt.Rows[i]["BarCode"].ToString()!="")
  334. {
  335. BarCodes += dt.Rows[i]["BarCode"].ToString() + ",";
  336. }
  337. }
  338. BarCodes = BarCodes.TrimEnd(',');
  339. }
  340. if(BarCodes==string.Empty)
  341. {
  342. MessageBox.Show("请先选择取消绑定的条码!",
  343. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  344. return;
  345. }
  346. ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
  347. {
  348. return PCModuleProxy.Service.SetFPM2105CancelBarCodeData(BarCodes);
  349. }
  350. );
  351. if (sre.Status == Constant.ServiceResultStatus.Success)
  352. {
  353. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  354. this.DialogResult = DialogResult.OK;
  355. this._groutingDailyID = null;
  356. this._groutingDate = null;
  357. this.dgvGroutingDaily.DataSource = null;
  358. this.txtGroutingUserCode.Text = string.Empty;
  359. this.dkGoodsCode.ClearControl();
  360. this.scbGroutingLine.ClearValue();
  361. this.txtGroutingDate.Value = DateTime.Now.Date;
  362. return;
  363. }
  364. if (sre.Status == Constant.ServiceResultStatus.Other)
  365. {
  366. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, sre.Message);
  367. }
  368. }
  369. catch (Exception ex)
  370. {
  371. // 对异常进行共通处理
  372. ExceptionManager.HandleEventException(this.ToString(),
  373. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  374. }
  375. }
  376. }
  377. }