F_PC_0103.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PC_0103.cs
  5. * 2.功能描述:编辑成型线信息
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 庄天威 2014/09/13 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  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.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. using Dongke.IBOSS.PRD.WCF.Proxys.PCModuleService;
  22. namespace Dongke.IBOSS.PRD.Client.PCModule
  23. {
  24. /// <summary>
  25. /// 编辑成型线信息
  26. /// </summary>
  27. public partial class F_PC_0103 : FormBase
  28. {
  29. #region 成员变量
  30. //当前编辑成型线ID
  31. private int _groutingLineId;
  32. //当前编辑成型线实体
  33. private GroutingLineEntity _lineEntity = new GroutingLineEntity();
  34. //当前编辑成型线明细集合
  35. private List<GroutingLineDetailEntity> _detailList = new List<GroutingLineDetailEntity>();
  36. //当前编辑成型线新增明细集合
  37. private List<GroutingLineDetailEntity> _AddDetailList = new List<GroutingLineDetailEntity>();
  38. //模具总数量
  39. private int _mouldCount = 0;
  40. //修改前成型线编号
  41. private string _lineCode = "";
  42. //范围权限
  43. private string _purview;
  44. #endregion
  45. #region 构造函数
  46. /// <summary>
  47. /// 编辑成型线窗体构造
  48. /// </summary>
  49. public F_PC_0103(int GroutingLineId)
  50. {
  51. InitializeComponent();
  52. this._groutingLineId = GroutingLineId;
  53. this.Text = FormTitles.F_PC_0103;
  54. this.btnSave.Text = ButtonText.BTN_SAVE;
  55. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  56. this.btnAddMould.Text = ButtonText.BTN_ADDMOULD;
  57. this.btnDeleteSelected.Text = ButtonText.BTN_DELETESELECTED;
  58. this.dkUser.IsWorker = true;
  59. }
  60. #endregion
  61. #region 事件
  62. /// <summary>
  63. /// 窗体加载
  64. /// </summary>
  65. private void F_PC_0103_Load(object sender, EventArgs e)
  66. {
  67. try
  68. {
  69. this.BindGrouting();
  70. }
  71. catch (Exception ex)
  72. {
  73. // 对异常进行共通处理
  74. ExceptionManager.HandleEventException(this.ToString(),
  75. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  76. }
  77. }
  78. /// <summary>
  79. /// 提交编辑
  80. /// </summary>
  81. private void btnSave_Click(object sender, EventArgs e)
  82. {
  83. try
  84. {
  85. int ErrorId = ValidationText();
  86. if (ErrorId != Constant.INT_IS_ZERO)
  87. {
  88. string errorAddress = "";
  89. switch (ErrorId)
  90. {
  91. case 1:
  92. this.txtBuildingNo.Focus();
  93. errorAddress = "楼号";
  94. break;
  95. case 2:
  96. this.txtFloorNo.Focus();
  97. errorAddress = "楼层";
  98. break;
  99. case 3:
  100. this.txtGroutingLineNo.Focus();
  101. errorAddress = "线号";
  102. break;
  103. case 4:
  104. this.txtGroutingLineCode.Focus();
  105. errorAddress = "成型线编码";
  106. break;
  107. case 5:
  108. this.txtGroutingLineName.Focus();
  109. errorAddress = "成型线名称";
  110. break;
  111. case 7:
  112. this.dkUser.Focus();
  113. errorAddress = "工号";
  114. break;
  115. case 8:
  116. this.dkType.Focus();
  117. errorAddress = "成型线类别";
  118. break;
  119. default:
  120. break;
  121. };
  122. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, errorAddress),
  123. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  124. return;
  125. }
  126. this._lineEntity.BUILDINGNO = this.txtBuildingNo.Text.Trim();
  127. this._lineEntity.FLOORNO = this.txtFloorNo.Text.Trim();
  128. this._lineEntity.GROUTINGLINENO = this.txtGroutingLineNo.Text.Trim();
  129. this._lineEntity.GROUTINGLINECODE = this.txtGroutingLineCode.Text.Trim();
  130. this._lineEntity.GROUTINGLINENAME = this.txtGroutingLineName.Text.Trim();
  131. this._lineEntity.REMARKS = this.txtRemarks.Text.Trim();
  132. this._lineEntity.USERID = this.dkUser.UserID;
  133. this._lineEntity.MOULDTYPEID = this.dkType.MouldTypeID;
  134. this._lineEntity.CANMANYTIMES = this.dkType.IsCanManyTimes;
  135. this._lineEntity.MOULDQUANTITY = _detailList.Count + _AddDetailList.Count;
  136. if (this.cbValueFlag.Checked == false)
  137. {
  138. this._lineEntity.VALUEFLAG = Convert.ToInt32(Constant.ValueFlag.Invalid);
  139. }
  140. else
  141. {
  142. this._lineEntity.VALUEFLAG = Convert.ToInt32(Constant.ValueFlag.Effective);
  143. }
  144. if (this._lineCode != this._lineEntity.GROUTINGLINECODE)
  145. {
  146. bool isHaveGroutingLineCode = (bool)DoAsync(new BaseAsyncMethod(() =>
  147. {
  148. return PCModuleProxy.Service.GroutingLineCodeIsRepeat(this.txtGroutingLineCode.Text);
  149. }));
  150. if (isHaveGroutingLineCode == false)
  151. {
  152. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "成型线编码"),
  153. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  154. return;
  155. }
  156. }
  157. int myReturn = (int)DoAsync(new BaseAsyncMethod(() =>
  158. {
  159. return PCModuleProxy.Service.UpdateGroutingLine(_lineEntity, _AddDetailList);
  160. }));
  161. if (myReturn > Constant.INT_IS_ZERO)
  162. {
  163. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "成型线信息", "保存"),
  164. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  165. this.DialogResult = DialogResult.OK;
  166. return;
  167. }
  168. else if (myReturn == -500)
  169. {
  170. MessageBox.Show(Messages.MSG_CMN_W012, this.Text,
  171. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  172. this.Close();
  173. }
  174. else
  175. {
  176. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "成型线信息", "保存"),
  177. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  178. }
  179. }
  180. catch (Exception ex)
  181. {
  182. // 对异常进行共通处理
  183. ExceptionManager.HandleEventException(this.ToString(),
  184. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  185. }
  186. }
  187. /// <summary>
  188. /// 关闭窗体
  189. /// </summary>
  190. private void btnCancel_Click(object sender, EventArgs e)
  191. {
  192. this.Close();
  193. }
  194. /// <summary>
  195. /// 删除新建明细信息
  196. /// </summary>
  197. private void btnDeleteSelected_Click(object sender, EventArgs e)
  198. {
  199. try
  200. {
  201. DataGridViewRow currentRow = this.dgvDetail.CurrentRow;
  202. if (currentRow == null || currentRow.Index < Constant.INT_IS_ZERO)
  203. {
  204. return;
  205. }
  206. int DeleteIndex = currentRow.Index - _detailList.Count;
  207. if (DeleteIndex >= Constant.INT_IS_ZERO)
  208. {
  209. this._AddDetailList.RemoveAt(DeleteIndex);
  210. }
  211. else
  212. {
  213. MessageBox.Show(Messages.MSG_PC_W002, this.Text,
  214. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  215. return;
  216. }
  217. this.dgvDetail.DataSource = this.ListToTable();
  218. }
  219. catch (Exception ex)
  220. {
  221. // 对异常进行共通处理
  222. ExceptionManager.HandleEventException(this.ToString(),
  223. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  224. }
  225. }
  226. /// <summary>
  227. /// 新建明细信息
  228. /// </summary>
  229. private void btnAddMould_Click(object sender, EventArgs e)
  230. {
  231. try
  232. {
  233. if (this.txtGroutingLineCode.Text == string.Empty)
  234. {
  235. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "成型线编码"), this.Text,
  236. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  237. return;
  238. }
  239. if (this.txtCount.Text == "")
  240. {
  241. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具数量"), this.Text,
  242. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  243. return;
  244. }
  245. if (this.dkGoods.GoodsID == null)
  246. {
  247. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具产品"), this.Text,
  248. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  249. return;
  250. }
  251. if (this._mouldCount == 999)
  252. {
  253. MessageBox.Show("成型线模具数量不可超过999个!", this.Text,
  254. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  255. return;
  256. }
  257. for (int i = 0; i < Convert.ToInt32(this.txtCount.Text); i++)
  258. {
  259. int GroutingMouldCodeNum = i + _mouldCount;
  260. GroutingLineDetailEntity detailInfo = new GroutingLineDetailEntity();
  261. detailInfo.GROUTINGMOULDCODE = this.txtGroutingLineCode.Text + "-" + (GroutingMouldCodeNum + 1).ToString().PadLeft(3, '0');
  262. detailInfo.MOULDCODE = Guid.NewGuid().ToString();
  263. detailInfo.GOODSID = Convert.ToInt32(this.dkGoods.GoodsID);
  264. detailInfo.GOODSNAME = this.dkGoods.GoodsName;
  265. detailInfo.GOODSCODE = this.dkGoods.GoodsCode;
  266. detailInfo.GoodsSpecification = this.dkGoods.GoodsSpecification;
  267. detailInfo.GROUTINGCOUNT = Constant.INT_IS_ZERO;
  268. detailInfo.MOULDSTATUS = Convert.ToInt32(Constant.GMouldStatus.Normal);
  269. detailInfo.REMARKS = "-";
  270. this._AddDetailList.Add(detailInfo);
  271. }
  272. this._mouldCount += Convert.ToInt32(this.txtCount.Text);
  273. this.dgvDetail.AutoGenerateColumns = false;
  274. this.dgvDetail.DataSource = ListToTable();
  275. }
  276. catch (Exception ex)
  277. {
  278. // 对异常进行共通处理
  279. ExceptionManager.HandleEventException(this.ToString(),
  280. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  281. }
  282. }
  283. /// <summary>
  284. /// 编号更改
  285. /// </summary>
  286. private void txtBuildingNo_TextChanged(object sender, EventArgs e)
  287. {
  288. this.txtGroutingLineCode.Text = this.txtBuildingNo.Text + this.txtFloorNo.Text
  289. + this.txtGroutingLineNo.Text;
  290. }
  291. /// <summary>
  292. /// 编号更改
  293. /// </summary>
  294. private void txtFloorNo_TextChanged(object sender, EventArgs e)
  295. {
  296. this.txtGroutingLineCode.Text = this.txtBuildingNo.Text + this.txtFloorNo.Text
  297. + this.txtGroutingLineNo.Text;
  298. }
  299. /// <summary>
  300. /// 编号更改
  301. /// </summary>
  302. private void txtGroutingLineNo_TextChanged(object sender, EventArgs e)
  303. {
  304. this.txtGroutingLineCode.Text = this.txtBuildingNo.Text + this.txtFloorNo.Text
  305. + this.txtGroutingLineNo.Text;
  306. }
  307. #endregion
  308. #region 私有方法
  309. /// <summary>
  310. /// 加载成型线数据
  311. /// </summary>
  312. private void BindGrouting()
  313. {
  314. try
  315. {
  316. //首先绑定成型线基础信息
  317. GroutingLineEntity ginfo = new GroutingLineEntity();
  318. ginfo.GROUTINGLINEID = _groutingLineId;
  319. DataSet dsGroutingLine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  320. {
  321. return PCModuleProxy.Service.GetGroutingLine(ginfo);
  322. }));
  323. if (dsGroutingLine.Tables[0].Rows.Count != Constant.INT_IS_ZERO)
  324. {
  325. //给实体绑定值
  326. BindGroutingEntity(dsGroutingLine.Tables[0].Rows[0]);
  327. //将实体值绑定给界面控件
  328. this.txtBuildingNo.Text = _lineEntity.BUILDINGNO;
  329. this.txtFloorNo.Text = _lineEntity.FLOORNO;
  330. this.txtGroutingLineNo.Text = _lineEntity.GROUTINGLINENO;
  331. this.txtGroutingLineCode.Text = _lineEntity.GROUTINGLINECODE;
  332. this.txtGroutingLineName.Text = _lineEntity.GROUTINGLINENAME;
  333. this.txtRemarks.Text = _lineEntity.REMARKS;
  334. this.dkUser.UserID = _lineEntity.USERID;
  335. this.dkUser.UserName = dsGroutingLine.Tables[0].Rows[0]["UserName"].ToString();
  336. this.dkUser.UserCode = dsGroutingLine.Tables[0].Rows[0]["UserCode"].ToString();
  337. this.dkUser.Text = dsGroutingLine.Tables[0].Rows[0]["UserCode"].ToString();
  338. this.dkType.MouldTypeID = _lineEntity.MOULDTYPEID;
  339. this.dkType.MouldTypeName = dsGroutingLine.Tables[0].Rows[0]["GMouldTypeName"].ToString();
  340. this.dkType.Text = dsGroutingLine.Tables[0].Rows[0]["GMouldTypeName"].ToString();
  341. if (this._lineEntity.VALUEFLAG == Convert.ToInt32(Constant.ValueFlag.Effective))
  342. {
  343. this.cbValueFlag.Checked = true;
  344. }
  345. this._lineCode = _lineEntity.GROUTINGLINECODE;
  346. }
  347. //然后绑定该成型线所属的明细信息
  348. BindDetailInfo(_groutingLineId);
  349. }
  350. catch (Exception ex)
  351. {
  352. throw ex;
  353. }
  354. }
  355. /// <summary>
  356. /// 将DataRow转换为实体
  357. /// </summary>
  358. private void BindGroutingEntity(DataRow drGrouting)
  359. {
  360. try
  361. {
  362. this._lineEntity.GROUTINGLINEID = Convert.ToInt32(drGrouting["GROUTINGLINEID"]);
  363. this._lineEntity.BUILDINGNO = drGrouting["BUILDINGNO"].ToString();
  364. this._lineEntity.FLOORNO = drGrouting["FLOORNO"].ToString();
  365. this._lineEntity.GROUTINGLINENO = drGrouting["GROUTINGLINENO"].ToString();
  366. this._lineEntity.GROUTINGLINECODE = drGrouting["GROUTINGLINECODE"].ToString();
  367. this._lineEntity.GROUTINGLINENAME = drGrouting["GROUTINGLINENAME"].ToString();
  368. this._lineEntity.MOULDQUANTITY = Convert.ToDecimal(drGrouting["MOULDQUANTITY"]);
  369. this._lineEntity.MOULDTYPEID = Convert.ToInt32(drGrouting["GMOULDTYPEID"]);
  370. this._lineEntity.USERID = Convert.ToInt32(drGrouting["USERID"]);
  371. this._lineEntity.BEGINUSEDDATE = Convert.ToDateTime(drGrouting["BEGINUSEDDATE"]);
  372. if (drGrouting["ENDUSEDDATE"].ToString() != string.Empty && drGrouting["ENDUSEDDATE"] != DBNull.Value)
  373. {
  374. this._lineEntity.ENDUSEDDATE = Convert.ToDateTime(drGrouting["ENDUSEDDATE"]);
  375. }
  376. this._lineEntity.MouldStatus = Convert.ToInt32(drGrouting["GMouldStatus"]);
  377. if (drGrouting["REMARKS"].ToString() != string.Empty && drGrouting["REMARKS"] != DBNull.Value)
  378. {
  379. this._lineEntity.REMARKS = drGrouting["REMARKS"].ToString();
  380. }
  381. this._lineEntity.ACCOUNTID = Convert.ToInt32(drGrouting["ACCOUNTID"]);
  382. this._lineEntity.VALUEFLAG = Convert.ToInt32(drGrouting["VALUEFLAG"]);
  383. this._lineEntity.CREATETIME = Convert.ToDateTime(drGrouting["CREATETIME"]);
  384. this._lineEntity.CREATEUSERID = Convert.ToInt32(drGrouting["CREATEUSERID"]);
  385. this._lineEntity.UPDATETIME = Convert.ToDateTime(drGrouting["UPDATETIME"]);
  386. this._lineEntity.UPDATEUSERID = Convert.ToInt32(drGrouting["UPDATEUSERID"]);
  387. this._lineEntity.OPTIMESTAMP = Convert.ToDateTime(drGrouting["OPTIMESTAMP"]);
  388. }
  389. catch (Exception ex)
  390. {
  391. throw ex;
  392. }
  393. }
  394. /// <summary>
  395. /// 根据成型线ID绑定该成型线所属成型线模具信息
  396. /// </summary>
  397. private void BindDetailInfo(int GroutingLineID)
  398. {
  399. try
  400. {
  401. this.dgvDetail.AutoGenerateColumns = false;
  402. DataSet dsDetail = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  403. {
  404. return PCModuleProxy.Service.GetGroutingLineDetailByMainId(GroutingLineID, null, 0);
  405. }));
  406. this.DataTableToListByDetail(dsDetail);
  407. }
  408. catch (Exception ex)
  409. {
  410. throw ex;
  411. }
  412. }
  413. /// <summary>
  414. /// 将成型线明细DataSet数据集转换为实体集合
  415. /// </summary>
  416. private void DataTableToListByDetail(DataSet dsDetail)
  417. {
  418. try
  419. {
  420. this._detailList.Clear();
  421. foreach (DataRow drFor in dsDetail.Tables[0].Rows)
  422. {
  423. GroutingLineDetailEntity detailEntity = new GroutingLineDetailEntity();
  424. detailEntity.GROUTINGLINEDETAILID = Convert.ToInt32(drFor["GROUTINGLINEDETAILID"]);
  425. detailEntity.GROUTINGLINEID = Convert.ToInt32(drFor["GROUTINGLINEID"]);
  426. detailEntity.GROUTINGMOULDCODE = drFor["GROUTINGMOULDCODE"].ToString();
  427. detailEntity.MOULDCODE = drFor["MOULDCODE"].ToString();
  428. detailEntity.GOODSID = Convert.ToInt32(drFor["GOODSID"]);
  429. detailEntity.GROUTINGCOUNT = Convert.ToDecimal(drFor["GROUTINGCOUNT"]);
  430. detailEntity.MOULDSTATUS = Convert.ToInt32(drFor["GMOULDSTATUS"]);
  431. detailEntity.BEGINUSEDDATE = Convert.ToDateTime(drFor["BEGINUSEDDATE"]);
  432. detailEntity.REMARKS = drFor["REMARKS"].ToString();
  433. detailEntity.ACCOUNTID = Convert.ToInt32(drFor["ACCOUNTID"]);
  434. detailEntity.VALUEFLAG = Convert.ToInt32(drFor["VALUEFLAG"]);
  435. detailEntity.CREATETIME = Convert.ToDateTime(drFor["CREATETIME"]);
  436. detailEntity.CREATEUSERID = Convert.ToInt32(drFor["CREATEUSERID"]);
  437. detailEntity.UPDATETIME = Convert.ToDateTime(drFor["UPDATETIME"]);
  438. detailEntity.UPDATEUSERID = Convert.ToInt32(drFor["UPDATEUSERID"]);
  439. detailEntity.OPTIMESTAMP = Convert.ToDateTime(drFor["OPTIMESTAMP"]);
  440. detailEntity.GOODSNAME = drFor["GOODSNAME"].ToString();
  441. detailEntity.GROUTINGLINENAME = drFor["GMOULDSTATUSNAME"].ToString();
  442. detailEntity.GOODSCODE = drFor["GOODSCODE"].ToString();
  443. detailEntity.GoodsSpecification = drFor["GoodsSpecification"].ToString();
  444. this._detailList.Add(detailEntity);
  445. }
  446. //获取最后一个模具编号的最后数字
  447. int lineIndexOf = _detailList[_detailList.Count - 1].GROUTINGMOULDCODE.LastIndexOf("-") + 1;
  448. this._mouldCount = Convert.ToInt32(_detailList[_detailList.Count - 1].GROUTINGMOULDCODE.Substring(lineIndexOf));
  449. this.dgvDetail.AutoGenerateColumns = false;
  450. this.dgvDetail.DataSource = ListToTable();
  451. }
  452. catch (Exception ex)
  453. {
  454. throw ex;
  455. }
  456. }
  457. /// <summary>
  458. /// 验证添加项
  459. /// </summary>
  460. private int ValidationText()
  461. {
  462. try
  463. {
  464. int ErrorId = 0;
  465. string txtBuildingNo = this.txtBuildingNo.Text.Trim();
  466. string txtFloorNo = this.txtFloorNo.Text.Trim();
  467. string txtGroutingLineNo = this.txtGroutingLineNo.Text.Trim();
  468. string txtGroutingLineCode = this.txtGroutingLineCode.Text.Trim();
  469. string txtGroutingLineName = this.txtGroutingLineName.Text.Trim();
  470. string txtRemarks = this.txtRemarks.Text.Trim();
  471. if (txtBuildingNo == string.Empty)
  472. {
  473. ErrorId = 1;
  474. return ErrorId;
  475. }
  476. if (txtFloorNo == string.Empty)
  477. {
  478. ErrorId = 2;
  479. return ErrorId;
  480. }
  481. if (txtGroutingLineNo == string.Empty)
  482. {
  483. ErrorId = 3;
  484. return ErrorId;
  485. }
  486. if (txtGroutingLineCode == string.Empty)
  487. {
  488. ErrorId = 4;
  489. return ErrorId;
  490. }
  491. if (txtGroutingLineName == string.Empty)
  492. {
  493. ErrorId = 5;
  494. return ErrorId;
  495. }
  496. if (dkUser.UserID == null)
  497. {
  498. ErrorId = 7;
  499. return ErrorId;
  500. }
  501. if (dkType.MouldTypeID == null)
  502. {
  503. ErrorId = 8;
  504. return ErrorId;
  505. }
  506. return ErrorId;
  507. }
  508. catch (Exception ex)
  509. {
  510. throw ex;
  511. }
  512. }
  513. /// <summary>
  514. /// 将实体数据转换为DataTable,绑定到控件中
  515. /// </summary>
  516. private DataTable ListToTable()
  517. {
  518. try
  519. {
  520. DataTable dtDataSourse = new DataTable();
  521. dtDataSourse.Columns.Add("GROUTINGMOULDCODE", System.Type.GetType("System.String"));
  522. dtDataSourse.Columns.Add("GOODSID", System.Type.GetType("System.String"));
  523. dtDataSourse.Columns.Add("GOODSNAME", System.Type.GetType("System.String"));
  524. dtDataSourse.Columns.Add("GoodsCode", System.Type.GetType("System.String"));
  525. dtDataSourse.Columns.Add("GoodsSpecification", System.Type.GetType("System.String"));
  526. dtDataSourse.Columns.Add("REMARKS", System.Type.GetType("System.String"));
  527. dtDataSourse.Columns.Add("MOULDSTATUS", System.Type.GetType("System.String"));
  528. for (int i = 0; i < this._detailList.Count; i++)
  529. {
  530. DataRow drRow = dtDataSourse.NewRow();
  531. drRow["GROUTINGMOULDCODE"] = this._detailList[i].GROUTINGMOULDCODE;
  532. drRow["GOODSID"] = this._detailList[i].GOODSID;
  533. drRow["GOODSNAME"] = this._detailList[i].GOODSNAME;
  534. drRow["GoodsCode"] = this._detailList[i].GOODSCODE;
  535. drRow["GoodsSpecification"] = this._detailList[i].GoodsSpecification;
  536. drRow["REMARKS"] = this._detailList[i].REMARKS;
  537. drRow["MOULDSTATUS"] = this._detailList[i].GROUTINGLINENAME;
  538. dtDataSourse.Rows.Add(drRow);
  539. }
  540. for (int i = 0; i < this._AddDetailList.Count; i++)
  541. {
  542. DataRow dr = dtDataSourse.NewRow();
  543. dr["GROUTINGMOULDCODE"] = _AddDetailList[i].GROUTINGMOULDCODE;
  544. dr["GOODSID"] = this._AddDetailList[i].GOODSID;
  545. dr["GOODSNAME"] = this._AddDetailList[i].GOODSNAME;
  546. dr["GoodsCode"] = this._AddDetailList[i].GOODSCODE;
  547. dr["GoodsSpecification"] = this._AddDetailList[i].GoodsSpecification;
  548. dr["REMARKS"] = this._AddDetailList[i].REMARKS;
  549. dr["MOULDSTATUS"] = "新建";
  550. dtDataSourse.Rows.Add(dr);
  551. }
  552. return dtDataSourse;
  553. }
  554. catch (Exception ex)
  555. {
  556. throw ex;
  557. }
  558. }
  559. /// <summary>
  560. /// 获取权限
  561. /// </summary>
  562. protected void getPurview()
  563. {
  564. try
  565. {
  566. StringBuilder sbPurview = new StringBuilder();
  567. DataSet dsPurview = SystemModuleProxy.Service.GetUserPurview(6, LogInUserInfo.CurrentUser.UserID);
  568. if (dsPurview != null)
  569. {
  570. foreach (DataRow dr in dsPurview.Tables[0].Rows)
  571. {
  572. sbPurview.Append(dr[0].ToString() + ",");
  573. }
  574. if (sbPurview.Length != 0)
  575. {
  576. this._purview = sbPurview.ToString().Substring(0, sbPurview.Length - 1);
  577. }
  578. }
  579. }
  580. catch (Exception ex)
  581. {
  582. throw ex;
  583. }
  584. }
  585. #endregion
  586. }
  587. }