F_PM_2602.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_2602.cs
  5. * 2.功能描述:新增注浆盘点单
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2015/05/13 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.Client.CommonModule;
  18. using Dongke.IBOSS.PRD.Client.Controls;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. using Dongke.IBOSS.PRD.Basics.Library;
  22. namespace Dongke.IBOSS.PRD.Client.PMModule
  23. {
  24. /// <summary>
  25. /// 新增注浆盘点单
  26. /// </summary>
  27. public partial class F_PM_2602 : DKFormBase
  28. {
  29. #region 成员变量
  30. private DataTable _dtGrid = null;
  31. private int _checkedID = 0;
  32. private string _userCodeValue;
  33. private bool _ShowFlag = true;
  34. #endregion
  35. #region 构造函数
  36. public F_PM_2602()
  37. {
  38. InitializeComponent();
  39. this.btnClose.Text = ButtonText.BTN_CLOSE;
  40. this.btnSave.Text = ButtonText.BTN_SAVE;
  41. }
  42. public F_PM_2602(int id)
  43. {
  44. InitializeComponent();
  45. this.btnClose.Text = ButtonText.BTN_CLOSE;
  46. this.btnSave.Text = ButtonText.BTN_SAVE;
  47. this._checkedID = id;
  48. //this.dkProcedureSearchBox.Enabled = false;
  49. this.scbGoods.Enabled = false;
  50. this.scbGoodsType.Enabled = false;
  51. this.chkDateTime.Enabled = false;
  52. this.txtBUILDINGNO.Enabled = false;
  53. this.txtFLOORNO.Enabled = false;
  54. }
  55. #endregion
  56. #region 事件
  57. /// <summary>
  58. /// 关闭按钮事件
  59. /// </summary>
  60. /// <param name="sender"></param>
  61. /// <param name="e"></param>
  62. private void tsbtnClose_Click(object sender, EventArgs e)
  63. {
  64. this.Close();
  65. }
  66. /// <summary>
  67. /// 窗体加载事件
  68. /// </summary>
  69. /// <param name="sender"></param>
  70. /// <param name="e"></param>
  71. private void F_PM_2102_Load(object sender, EventArgs e)
  72. {
  73. // 初始化时间控件为当前日期
  74. this.dtpDateStart.Value = DateTime.Now.Date;
  75. this.dtpDateEnd.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
  76. this.dtpDateStart.ValueChanged += dtpDateStart_ValueChanged;
  77. this.dtpDateEnd.ValueChanged += dtpDateStart_ValueChanged;
  78. //this.dkProcedureSearchBox.TextChanged += new System.EventHandler(this.dkProcedureSearchBox_TextChanged);
  79. this.scbGoods.SearchedItemChanged += new System.EventHandler(this.dkProcedureSearchBox_TextChanged);
  80. this.scbGoodsType.SearchedItemChanged += new System.EventHandler(this.dkProcedureSearchBox_TextChanged);
  81. this.dgvFunctionUsers.AutoGenerateColumns = false;
  82. if (_checkedID > 0)
  83. {
  84. this.Text = "编辑盘点单";
  85. ClientRequestEntity cre = new ClientRequestEntity();
  86. cre.NameSpace = "GBChecked";
  87. cre.Name = "GetGBCheckedInfoForUpdate";
  88. cre.Properties["CheckedID"] = _checkedID;
  89. ServiceResultEntity sre = PMModuleProxyNew.Service.HandleRequest(cre);
  90. if (sre != null && sre.Data != null && sre.Data.Tables.Count > 1 && sre.Data.Tables[0].Rows.Count > 0)
  91. {
  92. this.Text += "【" + sre.Data.Tables[0].Rows[0]["gbcheckedno"] + "】";
  93. this.txtInvoiceName.Text = sre.Data.Tables[0].Rows[0]["gbcheckname"].ToString();
  94. this.txtRemarks.Text = sre.Data.Tables[0].Rows[0]["remarks"].ToString();
  95. this._dtGrid = sre.Data.Tables[1];
  96. }
  97. }
  98. else
  99. {
  100. this._dtGrid = new DataTable("CheckedUser");
  101. this._dtGrid.Columns.Add("UserID", typeof(int));
  102. this._dtGrid.Columns.Add("UserCode", typeof(string));
  103. this._dtGrid.Columns.Add("UserName", typeof(string));
  104. }
  105. this.dgvFunctionUsers.DataSource = this._dtGrid;
  106. }
  107. void dtpDateStart_ValueChanged(object sender, EventArgs e)
  108. {
  109. dkProcedureSearchBox_TextChanged(sender, e);
  110. }
  111. void dkProcedureSearchBox_TextChanged(object sender, EventArgs e)
  112. {
  113. string remarks = null;
  114. //if (!string.IsNullOrWhiteSpace(this.dkProcedureSearchBox.Text))
  115. //{
  116. // remarks = "盘点工序: " + this.dkProcedureSearchBox.Text;
  117. //}
  118. if (chkDateTime.Checked)
  119. {
  120. if (remarks != null)
  121. {
  122. remarks += "\r\n";
  123. }
  124. remarks += "注浆时间: " + this.dtpDateStart.Value.ToString("yyyy-MM-dd HH:mm:ss") + " 至 "
  125. + this.dtpDateEnd.Value.ToString("yyyy-MM-dd HH:mm:ss");
  126. }
  127. if (!string.IsNullOrWhiteSpace(this.scbGoodsType.Text))
  128. {
  129. if (remarks != null)
  130. {
  131. remarks += "\r\n";
  132. }
  133. remarks += "产品类别: " + this.scbGoodsType.Text;
  134. }
  135. if (!string.IsNullOrWhiteSpace(this.scbGoods.Text))
  136. {
  137. if (remarks != null)
  138. {
  139. remarks += "\r\n";
  140. }
  141. remarks += "产品编码: " + this.scbGoods.Text;
  142. }
  143. if (!string.IsNullOrWhiteSpace(this.txtBUILDINGNO.Text))
  144. {
  145. if (remarks != null)
  146. {
  147. remarks += "\r\n";
  148. }
  149. remarks += "楼号: " + this.txtBUILDINGNO.Text.Trim();
  150. }
  151. if (!string.IsNullOrWhiteSpace(this.txtFLOORNO.Text))
  152. {
  153. if (remarks != null)
  154. {
  155. remarks += "\r\n";
  156. }
  157. remarks += "楼层: " + this.txtFLOORNO.Text.Trim();
  158. }
  159. this.txtRemarks.Text = remarks;
  160. }
  161. /// <summary>
  162. /// 保存按钮事件
  163. /// </summary>
  164. /// <param name="sender"></param>
  165. /// <param name="e"></param>
  166. private void btnSave_Click(object sender, EventArgs e)
  167. {
  168. try
  169. {
  170. // 自动生成的备注会超长
  171. if (this.txtRemarks.Text.Length > 500)
  172. {
  173. MessageBox.Show("备注的内容超过最大长度【500个字】,请重新输入", this.Text
  174. , MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  175. this.txtRemarks.Focus();
  176. return;
  177. }
  178. // 删除空白行
  179. DataRow[] rows = this._dtGrid.Select("userid is null");
  180. if (rows != null && rows.Length > 0)
  181. {
  182. foreach (DataRow item in rows)
  183. {
  184. item.Delete();
  185. }
  186. }
  187. this._dtGrid.AcceptChanges();
  188. ClientRequestEntity cre = new ClientRequestEntity();
  189. cre.NameSpace = "GBChecked";
  190. cre.Name = "SaveGBChecked";
  191. cre.Data = new DataSet();
  192. cre.Data.Merge(this._dtGrid);
  193. cre.Properties["CheckedID"] = _checkedID;
  194. cre.Properties["CheckedName"] = this.txtInvoiceName.Text.Trim();
  195. cre.Properties["Remarks"] = this.txtRemarks.Text.Trim();
  196. if (_checkedID == 0)
  197. {
  198. cre.Properties["GoodsCodeList"] = this.scbGoods.CheckedPKMember;
  199. cre.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
  200. if (chkDateTime.Checked)
  201. {
  202. cre.Properties["DateBegin"] = this.dtpDateStart.Value;
  203. cre.Properties["DateEnd"] = this.dtpDateEnd.Value;
  204. }
  205. cre.Properties["BUILDINGNO"] = this.txtBUILDINGNO.Text.Trim();
  206. cre.Properties["FLOORNO"] = this.txtFLOORNO.Text.Trim();
  207. }
  208. ServiceResultEntity returnValue = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
  209. {
  210. return PMModuleProxyNew.Service.HandleRequest(cre);
  211. }));
  212. if (returnValue != null && returnValue.Status == Constant.ServiceResultStatus.Success)
  213. {
  214. // 提示信息
  215. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
  216. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  217. this.DialogResult = DialogResult.OK;
  218. }
  219. else
  220. {
  221. // 提示信息
  222. MessageBox.Show("保存失败",
  223. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  224. }
  225. }
  226. catch (Exception ex)
  227. {
  228. // 对异常进行共通处理
  229. ExceptionManager.HandleEventException(this.ToString(),
  230. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  231. }
  232. }
  233. /// <summary>
  234. /// 完成复选框改变事件
  235. /// </summary>
  236. /// <param name="sender"></param>
  237. /// <param name="e"></param>
  238. private void chkDateTime_CheckedChanged(object sender, EventArgs e)
  239. {
  240. dtpDateStart.Enabled = chkDateTime.Checked;
  241. dtpDateEnd.Enabled = chkDateTime.Checked;
  242. dkProcedureSearchBox_TextChanged(sender, e);
  243. }
  244. private void dgvFunctionUsers_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
  245. {
  246. try
  247. {
  248. if (this.dgvFunctionUsers.Rows.Count <= 1)
  249. {
  250. return;
  251. }
  252. DataGridViewColumn columnItem = this.dgvFunctionUsers.Columns[e.ColumnIndex];
  253. if ("UserCode".Equals(columnItem.Name))
  254. {
  255. _userCodeValue = this.dgvFunctionUsers.Rows[e.RowIndex].Cells[columnItem.Name].Value + "";
  256. }
  257. }
  258. catch (Exception ex)
  259. {
  260. // 对异常进行共通处理
  261. ExceptionManager.HandleEventException(this.ToString(),
  262. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  263. }
  264. }
  265. private void dgvFunctionUsers_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  266. {
  267. //if (e.Row.Index != -1)
  268. //{
  269. // DataTable dt = this.dgvFunctionUsers.DataSource as DataTable;
  270. // string userID = dt.Rows[e.Row.Index]["userID"].ToString();
  271. // DataRow[] isR = this._dtGrid.Select("UserID=" + userID);
  272. // isR[0].Delete();
  273. // this.btnSave.Enabled = true;
  274. //}
  275. }
  276. private void dgvFunctionUsers_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  277. {
  278. try
  279. {
  280. if (this.dgvFunctionUsers.Rows.Count <= 1 || !_ShowFlag)
  281. {
  282. return;
  283. }
  284. DataGridViewRow rowItem = this.dgvFunctionUsers.Rows[e.RowIndex];
  285. DataGridViewColumn columnItem = this.dgvFunctionUsers.Columns[e.ColumnIndex];
  286. //string OrganizationName = this.dgvFunctionUsers.Rows[e.RowIndex].Cells["OrganizationName"].Value.ToString();
  287. // 用编号获取产品信息
  288. if ("UserCode".Equals(columnItem.Name))
  289. {
  290. _ShowFlag = false;
  291. DataTable dtNew = FormUtility.BindUserRowDataSource(this.dgvFunctionUsers,
  292. e.RowIndex, columnItem.Name, _userCodeValue);
  293. if (dtNew != null && dtNew.Rows.Count > 0)
  294. {
  295. foreach (DataRow r in dtNew.Rows)
  296. {
  297. DataRow[] isR = _dtGrid.Select("UserID=" + r["UserID"]);
  298. if (isR.Length == 0)
  299. {
  300. DataRow drNew = _dtGrid.NewRow();
  301. drNew["UserID"] = r["UserID"];
  302. drNew["UserCode"] = r["UserCode"];
  303. drNew["UserName"] = r["UserName"];
  304. _dtGrid.Rows.Add(drNew);
  305. dgvFunctionUsers.Rows[e.RowIndex].Cells["UserCode"].ReadOnly = true;
  306. // BindReadOnly();
  307. }
  308. }
  309. }
  310. this.btnSave.Enabled = DataJudge.IsChange(_dtGrid);
  311. //this.dgvFunctionUsers.Rows[e.RowIndex].Cells["FunctionCode"].Value = this._functionCode;
  312. //this._dtDataGird.AcceptChanges();
  313. // 设置可输入单元格的颜色
  314. this.dgvFunctionUsers.IsSetInputColumnsColor = true;
  315. }
  316. _ShowFlag = true;
  317. }
  318. catch (Exception ex)
  319. {
  320. //_ShowFlag = true;
  321. // 对异常进行共通处理
  322. ExceptionManager.HandleEventException(this.ToString(),
  323. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  324. }
  325. }
  326. #endregion
  327. }
  328. }