F_MST_0202.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_0202.cs
  5. * 2.功能描述:新建/编辑用户管理
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2014/09/12 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.Basics.Library;
  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. using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
  24. namespace Dongke.IBOSS.PRD.Client.SystemModule
  25. {
  26. /// <summary>
  27. /// 新建/编辑用户管理
  28. /// </summary>
  29. public partial class F_MST_0202 : FormBase
  30. {
  31. #region 成员变量
  32. // 页面传过来用户ID
  33. private int _userID;
  34. // 用户实体类
  35. private SUserEntity _userEntity;
  36. // 编辑状态
  37. private Constant.FormMode _editStatus;
  38. // 新建的用户ID集合
  39. private List<int> _userIDList = new List<int>();
  40. // 用户代码
  41. private string _userCode;
  42. // 工种集合
  43. private DataTable _dtJobs;
  44. // 工种关联数据源
  45. private DataTable _dtUserJobs = new DataTable();
  46. // 记录编辑前的缺陷编码
  47. private string _jobsCodeValue;
  48. // 控制弹窗标识
  49. private bool _ShowFlag = true;
  50. #endregion
  51. #region 构造函数
  52. public F_MST_0202()
  53. {
  54. InitializeComponent();
  55. }
  56. /// <summary>
  57. /// 构造函数
  58. /// </summary>
  59. /// <param name="frmStatus">窗体状态</param>
  60. public F_MST_0202(Constant.FormMode frmStatus)
  61. {
  62. InitializeComponent();
  63. _editStatus = frmStatus;
  64. // 设置窗口标题,当为新建状态时显示新建用户,当为编辑状态时显示编辑用户
  65. if (frmStatus == Constant.FormMode.Add)
  66. {
  67. this.Text = FormTitles.F_MST_0202_ADD;
  68. this.dtpLimitStartTime.Text = "8:00:00";
  69. this.dtpLimitEndTime.Text = "17:00:00";
  70. }
  71. else if (frmStatus == Constant.FormMode.Edit)
  72. {
  73. this.Text = FormTitles.F_MST_0202_EDIT;
  74. this.txtUserCode.Enabled = false;
  75. }
  76. // 工具栏按钮文本赋值
  77. this.btnSave.Text = ButtonText.BTN_SAVE;
  78. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  79. }
  80. #endregion
  81. #region 属性
  82. /// <summary>
  83. /// 页面传过来的用户ID
  84. /// </summary>
  85. public int UserID
  86. {
  87. get
  88. {
  89. return this._userID;
  90. }
  91. set
  92. {
  93. this._userID = value;
  94. }
  95. }
  96. /// <summary>
  97. /// 页面传过来的用户代码
  98. /// </summary>
  99. public string UserCode
  100. {
  101. get
  102. {
  103. return this._userCode;
  104. }
  105. set
  106. {
  107. this._userCode = value;
  108. }
  109. }
  110. /// <summary>
  111. /// 用户ID集合
  112. /// </summary>
  113. public List<int> UserIDList
  114. {
  115. get
  116. {
  117. return _userIDList;
  118. }
  119. set
  120. {
  121. _userIDList = value;
  122. }
  123. }
  124. #endregion
  125. #region 事件
  126. /// <summary>
  127. /// 保存按钮事件
  128. /// </summary>
  129. /// <param name="sender"></param>
  130. /// <param name="e"></param>
  131. private void btnSave_Click(object sender, EventArgs e)
  132. {
  133. try
  134. {
  135. // 验证输入是否正确
  136. if (!this.CheckInputValidity())
  137. {
  138. return;
  139. }
  140. //校验绑定工种情况
  141. int rowCount = 0;
  142. foreach (DataGridViewRow gvrFor in this.dgvDataJobs.Rows)
  143. {
  144. if (gvrFor.IsNewRow == false)
  145. {
  146. //JobsID
  147. if (gvrFor.Cells["JobsID"].Value != null && gvrFor.Cells["JobsID"].Value.ToString() != "")
  148. {
  149. rowCount++;
  150. }
  151. }
  152. }
  153. if (chkIsWorker.Checked == true)
  154. {
  155. if (rowCount == Constant.INT_IS_ZERO)
  156. {
  157. // 提示信息
  158. MessageBox.Show("生产工号必须绑定至少一个工种!",
  159. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  160. return;
  161. }
  162. }
  163. else
  164. {
  165. if (rowCount > Constant.INT_IS_ONE)
  166. {
  167. // 提示信息
  168. MessageBox.Show("非生产工号只能绑定一个工种!",
  169. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  170. return;
  171. }
  172. }
  173. int returnUserID = Constant.INT_IS_ZERO;
  174. _userEntity = this.SetUserEntity();
  175. if (_editStatus == Constant.FormMode.Add || _editStatus == Constant.FormMode.CopyAndAdd)
  176. {
  177. // 判断是否存在重复的用户编号
  178. DataSet userCodeData = (DataSet)DoAsync(new BaseAsyncMethod(IsExistsUserCode));
  179. if (userCodeData.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  180. {
  181. MessageBox.Show(string.Format(Messages.MSG_CMN_W011, this.txtUserCode.Text.Trim(), "用户信息"),
  182. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  183. this.txtUserCode.Focus();
  184. return;
  185. }
  186. if (_editStatus == Constant.FormMode.CopyAndAdd)
  187. {
  188. _userEntity.UserID = UserID;
  189. }
  190. // 新建用户,返回新建的用户ID
  191. this.btnSave.Enabled = false;
  192. this.btnCancel.Enabled = false;
  193. returnUserID = (int)DoAsync(new BaseAsyncMethod(AddUserInfo));
  194. this.btnSave.Enabled = true;
  195. this.btnCancel.Enabled = true;
  196. if (returnUserID > Constant.INT_IS_ZERO)
  197. {
  198. // 提示信息
  199. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新建用户", "保存"),
  200. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  201. this._userIDList.Add(returnUserID);
  202. if (_editStatus == Constant.FormMode.CopyAndAdd)
  203. {
  204. this.Close();
  205. return;
  206. }
  207. this.InitializationForm();
  208. }// 组织机构不存在
  209. else if (returnUserID == -Constant.INT_IS_ONE)
  210. {
  211. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "不存在所选择的组织机构"),
  212. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  213. }
  214. // 组织机构是一级组织机构不允许建立用户
  215. else if (returnUserID == -Constant.INT_IS_TWO)
  216. {
  217. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "\r\n所选择的组织机构是一级组织机构,不允许创建用户"),
  218. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  219. }
  220. // 该组织机构下存在子级组织机构,不允许建立用户
  221. else if (returnUserID == -Constant.INT_IS_THREE)
  222. {
  223. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "\r\n所选择的组织机构存在子级组织,不允许创建用户"),
  224. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  225. }
  226. else if (returnUserID == -Constant.INT_IS_FIVE)
  227. {
  228. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "\r\n系统活动的用户数已经超过授权数,不允许创建用户"),
  229. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  230. }
  231. else if (returnUserID == Constant.INT_IS_NEGATIE_SIX)
  232. {
  233. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "\r\nAD域已存在,不允许创建用户"),
  234. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  235. }
  236. else
  237. {
  238. // 提示信息
  239. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "新建用户", "保存"),
  240. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  241. }
  242. }
  243. else
  244. {
  245. // 编辑
  246. this.btnSave.Enabled = false;
  247. this.btnCancel.Enabled = false;
  248. _userEntity.UserID = UserID;
  249. returnUserID = (int)DoAsync(new BaseAsyncMethod(EditUserInfo));
  250. this.btnSave.Enabled = true;
  251. this.btnCancel.Enabled = true;
  252. if (returnUserID > Constant.INT_IS_ZERO)
  253. {
  254. // 提示信息
  255. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "编辑用户", "保存"),
  256. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  257. this.Close();
  258. }
  259. // 组织机构不存在
  260. else if (returnUserID == -Constant.INT_IS_ONE)
  261. {
  262. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "不存在所选择的组织机构"),
  263. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  264. }
  265. // 组织机构是一级组织机构不允许建立用户
  266. else if (returnUserID == -Constant.INT_IS_TWO)
  267. {
  268. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "\r\n所选择的组织机构是一级组织机构,不允许创建用户"),
  269. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  270. }
  271. // 该组织机构下存在子级组织机构,不允许建立用户
  272. else if (returnUserID == -Constant.INT_IS_THREE)
  273. {
  274. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "\r\n所选择的组织机构存在子级组织,不允许创建用户"),
  275. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  276. }
  277. else if (returnUserID == -Constant.INT_IS_FIVE)
  278. {
  279. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "\r\n系统活动的用户数已经超过授权数,不允许创建用户"),
  280. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  281. }
  282. else if (returnUserID == -Constant.INT_IS_SIX)
  283. {
  284. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "\r\n在审批流程节点中存在的用户不能停用"),
  285. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  286. }
  287. else if (returnUserID == -Constant.INT_IS_EIGHT)
  288. {
  289. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "\r\nAD域已存在,不允许创建用户"),
  290. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  291. }
  292. else
  293. {
  294. // 提示信息
  295. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "编辑用户", "保存"),
  296. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  297. }
  298. }
  299. }
  300. catch (Exception ex)
  301. {
  302. this.btnSave.Enabled = true;
  303. this.btnCancel.Enabled = true;
  304. // 对异常进行共通处理
  305. ExceptionManager.HandleEventException(this.ToString(),
  306. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  307. }
  308. }
  309. /// <summary>
  310. /// 窗体加载事件
  311. /// </summary>
  312. /// <param name="sender"></param>
  313. /// <param name="e"></param>
  314. private void F_MST_0202_Load(object sender, EventArgs e)
  315. {
  316. try
  317. {
  318. if (this._editStatus == Constant.FormMode.CopyAndAdd)
  319. {
  320. this.Text = "复制工号【" + this.UserCode + "】";
  321. this.dtpLimitStartTime.Text = "8:00:00";
  322. this.dtpLimitEndTime.Text = "17:00:00";
  323. }
  324. //获取工种集合
  325. //GetJobs();
  326. // 为画面控件赋初始值
  327. this.chkValueFlag.Checked = true;
  328. this.dgvDataJobs.AutoGenerateColumns = false;
  329. // 加载打印机数据
  330. ClientRequestEntity cre = new ClientRequestEntity();
  331. cre.NameSpace = "MST0412";
  332. cre.Name = "GetBarcodePrinter";
  333. ServiceResultEntity sre = CommonModuleProxy.Service.DoRequest(cre);
  334. if (sre != null && sre.Status == Constant.ServiceResultStatus.Success)
  335. {
  336. DataTable dt = sre.Data.Tables[0];
  337. DataRow dr = dt.NewRow();
  338. dr["PrinterName"] = "无";
  339. dt.Rows.InsertAt(dr, 0);
  340. this.cobBarcodePrinter.DataSource = sre.Data.Tables[0];
  341. this.cobBarcodePrinter.DisplayMember = "PrinterName";
  342. this.cobBarcodePrinter.ValueMember = "PrinterID";
  343. }
  344. // 加载PLC
  345. cre = new ClientRequestEntity();
  346. cre.NameSpace = "MST0413";
  347. cre.Name = "GetPLC";
  348. sre = CommonModuleProxy.Service.DoRequest(cre);
  349. if (sre != null && sre.Status == Constant.ServiceResultStatus.Success)
  350. {
  351. DataTable dt = sre.Data.Tables[0];
  352. DataRow dr = dt.NewRow();
  353. dr["PLCName"] = "无";
  354. dt.Rows.InsertAt(dr, 0);
  355. this.cobPLC.DataSource = sre.Data.Tables[0];
  356. this.cobPLC.DisplayMember = "PLCName";
  357. this.cobPLC.ValueMember = "PLCID";
  358. }
  359. // 获取用户信息数据集
  360. DataSet userInfoData = (DataSet)DoAsync(new BaseAsyncMethod(GetUserRowData));
  361. int isJobsHave = 0;
  362. if (userInfoData != null && userInfoData.Tables.Count > Constant.INT_IS_ZERO)
  363. {
  364. // 编辑数据 给页面所有项赋值
  365. if (this._editStatus != Constant.FormMode.Add && userInfoData.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  366. {
  367. DataRow userData = userInfoData.Tables[0].Rows[0];
  368. if (this._editStatus == Constant.FormMode.Edit)
  369. {
  370. this.txtUserCode.Text = userData["UserCode"].ToString();
  371. this.txtUserCode.Enabled = false;
  372. this.txtUserName.Text = userData["UserName"].ToString();
  373. }
  374. this.txtADUserCode.Text = userData["AD_USER_CODE"].ToString();
  375. this.txtMAC.Text = userData["LIMITMAC"].ToString();
  376. this.txtRemarks.Text = userData["Remarks"].ToString();
  377. this.chkValueFlag.Checked = userData["ValueFlag"].ToString() == "1" ? true : false;
  378. this.chkCanSmartLogin.Checked = userData["CanSmartLogin"].ToString() == "1" ? true : false;
  379. this.chkCanPCLogin.Checked = userData["CanPCLogin"].ToString() == "1" ? true : false;
  380. this.cbplanflag.Checked = userData["PlanFlag"].ToString() == "1" ? true : false;
  381. scbOrganization.CheckedData = userInfoData.Tables[0];
  382. scbOrganization.Text = userData["OrganizationName"].ToString();
  383. this.chkIsWorker.Checked = userData["IsWorker"].ToString() == "1" ? true : false;
  384. this.chkIsGroutingWorker.Checked = userData["IsGroutingWorker"].ToString() == "1" ? true : false;
  385. this.chkPublicBody.Checked = userData["ispublicbody"].ToString() == "1" ? true : false;
  386. this.chkPRD.Checked = userData["CanLoginPRD"].ToString() == "1" ? true : false;
  387. this.chkMBC.Checked = userData["CanLoginMBC"].ToString() == "1" ? true : false;
  388. if (userData["POST"] != DBNull.Value && userData["POST"] != null)
  389. {
  390. this.dkPost.PostName = userData["POSTName"].ToString();
  391. this.dkPost.PostID = Convert.ToInt32(userData["POSTId"]);
  392. }
  393. if (userData["LimitStartTime"] != DBNull.Value && userData["LimitStartTime"] != null)
  394. {
  395. this.cbTime.Checked = true;
  396. this.dtpLimitStartTime.Text = userData["LimitStartTime"].ToString();
  397. this.dtpLimitEndTime.Text = userData["LimitEndTime"].ToString();
  398. }
  399. else
  400. {
  401. this.cbTime.Checked = false;
  402. this.dtpLimitStartTime.Text = "8:00:00";
  403. this.dtpLimitEndTime.Text = "17:00:00";
  404. }
  405. // 条码打印机
  406. this.cobBarcodePrinter.SelectedValue = userData["BarcodePrinterID"];
  407. this.cobPLC.SelectedValue = userData["plcID"];
  408. }
  409. if (this._editStatus != Constant.FormMode.Add && userInfoData.Tables[1].Rows.Count > Constant.INT_IS_ZERO)
  410. {
  411. this.dgvDataJobs.AutoGenerateColumns = false;
  412. this.dgvDataJobs.DataSource = userInfoData.Tables[1];
  413. isJobsHave++;
  414. }
  415. }
  416. if (isJobsHave == Constant.INT_IS_ZERO)
  417. {
  418. _dtUserJobs.Columns.Add("JobsCode", System.Type.GetType("System.String"));
  419. _dtUserJobs.Columns.Add("JobsID", System.Type.GetType("System.String"));
  420. _dtUserJobs.Columns.Add("JobsName", System.Type.GetType("System.String"));
  421. _dtUserJobs.Columns.Add("Remarks", System.Type.GetType("System.String"));
  422. this.dgvDataJobs.DataSource = _dtUserJobs;
  423. }
  424. this.dgvDataJobs.IsSetInputColumnsColor = true;
  425. this.dtpLimitStartTime.Enabled = this.cbTime.Checked;
  426. this.dtpLimitEndTime.Enabled = this.cbTime.Checked;
  427. }
  428. catch (Exception ex)
  429. {
  430. // 对异常进行共通处理
  431. ExceptionManager.HandleEventException(this.ToString(),
  432. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  433. }
  434. }
  435. /// <summary>
  436. /// 输入工种编码
  437. /// </summary>
  438. /// <param name="sender"></param>
  439. /// <param name="e"></param>
  440. private void dgvDataJobs_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
  441. {
  442. try
  443. {
  444. if (this.dgvDataJobs.Rows.Count <= Constant.INT_IS_ONE)
  445. {
  446. return;
  447. }
  448. DataGridViewColumn columnItem = this.dgvDataJobs.Columns[e.ColumnIndex];
  449. if ("JobsCode".Equals(columnItem.Name))
  450. {
  451. this._jobsCodeValue = this.dgvDataJobs.Rows[e.RowIndex].Cells[columnItem.Name].Value + "";
  452. }
  453. }
  454. catch (Exception ex)
  455. {
  456. // 对异常进行共通处理
  457. ExceptionManager.HandleEventException(this.ToString(),
  458. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  459. }
  460. }
  461. /// <summary>
  462. /// 弹出窗体
  463. /// </summary>
  464. /// <param name="sender"></param>
  465. /// <param name="e"></param>
  466. private void dgvDataJobs_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  467. {
  468. #region 改用弹出窗体模式
  469. /*
  470. if (e.RowIndex != -1)
  471. {
  472. if (this.dgvDataJobs.Columns[e.ColumnIndex].Name == "JobsCode")
  473. {
  474. string JobsCode = this.dgvDataJobs.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
  475. //看看这条记录有没有被选过
  476. for (int i = 0; i < this.dgvDataJobs.Rows.Count; i++)
  477. {
  478. if (i != e.RowIndex)
  479. {
  480. if (this.dgvDataJobs.Rows[i].Cells["JobsCode"].Value != null)
  481. {
  482. if (JobsCode == this.dgvDataJobs.Rows[i].Cells["JobsCode"].Value.ToString())
  483. {
  484. // 提示信息
  485. MessageBox.Show("已经选择了该工种!",
  486. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  487. this.dgvDataJobs.Rows.RemoveAt(e.RowIndex);
  488. return;
  489. }
  490. }
  491. }
  492. }
  493. StringBuilder strbFilterExpressions = new StringBuilder();
  494. strbFilterExpressions.Append(string.Format("JobsId='{0}'", JobsCode));
  495. DataTable TableCopy = _dtJobs.Copy();
  496. TableCopy.DefaultView.RowFilter = strbFilterExpressions.ToString();
  497. DataTable EndTable = TableCopy.DefaultView.ToTable();
  498. if (EndTable.Rows.Count != 0)
  499. {
  500. this.dgvDataJobs.Rows[e.RowIndex].Cells["JobsName"].Value = EndTable.Rows[0]["JobsName"].ToString();
  501. this.dgvDataJobs.Rows[e.RowIndex].Cells["Remarks"].Value = EndTable.Rows[0]["Remarks"].ToString();
  502. this.dgvDataJobs.Rows[e.RowIndex].Cells["JobsID"].Value = EndTable.Rows[0]["JobsID"].ToString();
  503. }
  504. else
  505. {
  506. this.dgvDataJobs.Rows.RemoveAt(e.RowIndex);
  507. }
  508. }
  509. }
  510. */
  511. #endregion
  512. try
  513. {
  514. if (this.dgvDataJobs.Rows.Count <= Constant.INT_IS_ONE || !_ShowFlag)
  515. {
  516. return;
  517. }
  518. DataGridViewRow rowItem = this.dgvDataJobs.Rows[e.RowIndex];
  519. DataGridViewColumn columnItem = this.dgvDataJobs.Columns[e.ColumnIndex];
  520. // 工种编号获取产品信息
  521. if ("JobsCode".Equals(columnItem.Name))
  522. {
  523. _ShowFlag = false;
  524. FormUtility.BindJobsRowDataSource(this.dgvDataJobs,
  525. e.RowIndex, columnItem.Name, _jobsCodeValue);
  526. // 设置可输入单元格的颜色
  527. this.dgvDataJobs.IsSetInputColumnsColor = true;
  528. }
  529. this._ShowFlag = true;
  530. }
  531. catch (Exception ex)
  532. {
  533. // 对异常进行共通处理
  534. ExceptionManager.HandleEventException(this.ToString(),
  535. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  536. }
  537. }
  538. /// <summary>
  539. /// 限制登陆时间选定改变事件
  540. /// </summary>
  541. /// <param name="sender"></param>
  542. /// <param name="e"></param>
  543. private void cbTime_CheckedChanged(object sender, EventArgs e)
  544. {
  545. this.dtpLimitStartTime.Enabled = this.cbTime.Checked;
  546. this.dtpLimitEndTime.Enabled = this.cbTime.Checked;
  547. }
  548. #endregion
  549. #region 私有方法
  550. /// <summary>
  551. /// 获取用户明细数据
  552. /// </summary>
  553. /// <returns></returns>
  554. private DataSet GetUserRowData()
  555. {
  556. try
  557. {
  558. return SystemModuleProxy.Service.GetUserRowData(UserID);
  559. }
  560. catch (Exception ex)
  561. {
  562. throw ex;
  563. }
  564. }
  565. /// <summary>
  566. /// 添加用户数据
  567. /// </summary>
  568. /// <returns></returns>
  569. private object AddUserInfo()
  570. {
  571. try
  572. {
  573. DataTable dtJobs = (DataTable)this.dgvDataJobs.DataSource;
  574. dtJobs.TableName = "dtJobs";
  575. this._userEntity.UserJobs = dtJobs;
  576. return SystemModuleProxy.Service.AddUserInfo(_userEntity);
  577. }
  578. catch (Exception ex)
  579. {
  580. throw ex;
  581. }
  582. }
  583. /// <summary>
  584. /// 是否存在相同的用户编码
  585. /// </summary>
  586. /// <returns></returns>
  587. private DataSet IsExistsUserCode()
  588. {
  589. try
  590. {
  591. return SystemModuleProxy.Service.IsExistsUserCode(this.txtUserCode.Text);
  592. }
  593. catch (Exception ex)
  594. {
  595. throw ex;
  596. }
  597. }
  598. /// <summary>
  599. /// 绑定下拉数据源
  600. /// </summary>
  601. /// <returns></returns>
  602. public DataTable datasourceCombox()
  603. {
  604. DataTable dt = new DataTable();
  605. dt.Columns.Add("ValueID");
  606. dt.Columns.Add("TextString");
  607. DataRow dr = dt.NewRow();
  608. dr["ValueID"] = 0;
  609. dr["TextString"] = "没有关联";
  610. dt.Rows.Add(dr);
  611. dr = dt.NewRow();
  612. dr["ValueID"] = 1;
  613. dr["TextString"] = "关联员工";
  614. dt.Rows.Add(dr);
  615. dr = dt.NewRow();
  616. dr["ValueID"] = 2;
  617. dr["TextString"] = "关联员工组";
  618. dt.Rows.Add(dr);
  619. return dt;
  620. }
  621. /// <summary>
  622. /// 编辑用户信息
  623. /// </summary>
  624. /// <returns></returns>
  625. private object EditUserInfo()
  626. {
  627. try
  628. {
  629. DataTable dtJobs = (DataTable)this.dgvDataJobs.DataSource;
  630. dtJobs.TableName = "dtJobs";
  631. this._userEntity.UserJobs = dtJobs;
  632. return SystemModuleProxy.Service.EditUserInfo(this._userEntity);
  633. }
  634. catch (Exception ex)
  635. {
  636. throw ex;
  637. }
  638. }
  639. /// <summary>
  640. /// 清空输入项
  641. /// </summary>
  642. private void InitializationForm()
  643. {
  644. this.txtUserCode.Clear();
  645. this.txtUserName.Clear();
  646. this.txtMAC.Clear();
  647. this.txtRemarks.Clear();
  648. this.scbOrganization.ClearValue();
  649. this.chkValueFlag.Checked = true;
  650. this._dtUserJobs.Rows.Clear();
  651. this.dgvDataJobs.IsSetInputColumnsColor = true;
  652. this.cobBarcodePrinter.SelectedIndex = 0;
  653. }
  654. /// <summary>
  655. /// 根据页面输入值,给用户对象实体赋值
  656. /// </summary>
  657. /// <returns></returns>
  658. private SUserEntity SetUserEntity()
  659. {
  660. SUserEntity userEntity = new SUserEntity();
  661. userEntity.AD_USER_CODE = this.txtADUserCode.Text.Trim();
  662. userEntity.UserCode = this.txtUserCode.Text.Trim();
  663. userEntity.UserName = this.txtUserName.Text.Trim();
  664. userEntity.OrganizationID = scbOrganization.SearchedPKMember;
  665. userEntity.IsWorker = chkIsWorker.Checked ? 1 : 0;
  666. userEntity.IsGroutingWorker = chkIsGroutingWorker.Checked ? 1 : 0;
  667. userEntity.LimitMAC = txtMAC.Text;
  668. if (this.cbTime.Checked == true)
  669. {
  670. userEntity.LimitStartTime = Convert.ToDateTime(dtpLimitStartTime.Text);
  671. userEntity.LimitEndTime = Convert.ToDateTime(dtpLimitEndTime.Text);
  672. }
  673. else
  674. {
  675. userEntity.LimitStartTime = null;
  676. userEntity.LimitEndTime = null;
  677. }
  678. if (this.dkPost.PostID != null)
  679. {
  680. userEntity.PostID = Convert.ToInt32(this.dkPost.PostID);
  681. }
  682. userEntity.CanSmartLogin = chkCanSmartLogin.Checked ? 1 : 0;
  683. userEntity.CanPCLogin = chkCanPCLogin.Checked ? 1 : 0;
  684. userEntity.Remarks = txtRemarks.Text;
  685. userEntity.ValueFlag = chkValueFlag.Checked ? 1 : 0;
  686. userEntity.Ispublicbody = chkPublicBody.Checked ? 1 : 0;
  687. userEntity.CanLoginPRD = "1"; // chkPRD.Checked ? "1" : "0";
  688. userEntity.CanLoginMBC = "0"; // chkMBC.Checked ? "1" : "0";
  689. // 新建用户默认密码
  690. DataSet ds = (DataSet)CommonModuleProxy.Service.GetSysSettingBySettingType("S_CMN_0001");
  691. string pwd = "dongke";
  692. if (ds.Tables[0].Rows.Count > 0)
  693. {
  694. pwd = ds.Tables[0].Rows[0]["SETTINGVALUE"].ToString();
  695. }
  696. userEntity.Password = Encryption.GetMD5String(pwd);
  697. if (this.cobBarcodePrinter.SelectedValue != null && this.cobBarcodePrinter.SelectedValue != DBNull.Value)
  698. {
  699. userEntity.BarcodePrinterID = Convert.ToInt32(this.cobBarcodePrinter.SelectedValue);
  700. }
  701. if (this.cobPLC.SelectedValue != null && this.cobPLC.SelectedValue != DBNull.Value)
  702. {
  703. userEntity.PLCID = Convert.ToInt32(this.cobPLC.SelectedValue);
  704. }
  705. userEntity.PlanFlag = cbplanflag.Checked ? 1 : 0;
  706. return userEntity;
  707. }
  708. /// <summary>
  709. /// 验证输入格式是否正确
  710. /// </summary>
  711. /// <returns></returns>
  712. private bool CheckInputValidity()
  713. {
  714. if (string.IsNullOrEmpty(this.txtUserCode.Text.Trim()))
  715. {
  716. this.txtUserCode.IsMustInput = true;
  717. this.txtUserCode.Focus();
  718. return false;
  719. }
  720. this.txtUserCode.IsMustInput = false;
  721. if (string.IsNullOrEmpty(this.txtUserName.Text.Trim()))
  722. {
  723. this.txtUserName.IsMustInput = true;
  724. this.txtUserName.Focus();
  725. return false;
  726. }
  727. this.txtUserName.IsMustInput = false;
  728. if (this.scbOrganization.SearchedPKMember == 0)
  729. {
  730. lblOrganization.IsMustInput = true;
  731. this.scbOrganization.Focus();
  732. return false;
  733. }
  734. lblOrganization.IsMustInput = false;
  735. return true;
  736. }
  737. /// <summary>
  738. /// 获取工种方法
  739. /// </summary>
  740. private void GetJobs()
  741. {
  742. try
  743. {
  744. //byte valueFlag = Convert.ToByte(false);
  745. //_dtJobs = SystemModuleProxy.Service.GetJobsData(valueFlag).Tables[0];
  746. //foreach(DataRow dr in _dtJobs.Rows)
  747. //{
  748. // dr["JobsCode"] = dr["JobsCode"].ToString() + "-" + dr["JobsName"].ToString();
  749. //}
  750. //this.JobsCode.DisplayMember = "JobsCode";
  751. //this.JobsCode.ValueMember = "JobsId";
  752. //this.JobsCode.DataSource = _dtJobs;
  753. }
  754. catch (Exception ex)
  755. {
  756. throw ex;
  757. }
  758. }
  759. #endregion
  760. }
  761. }