| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- /*******************************************************************************
- * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_MST_1202.cs
- * 2.功能描述:工号分组
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 陈晓野 2016/11/10 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.Client.Controls;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- namespace Dongke.IBOSS.PRD.Client.SystemModule
- {
- /// <summary>
- /// 工号分组
- /// </summary>
- public partial class F_MST_1202 : DKFormBase
- {
- #region 成员变量
- private int _groupID = 0;
- private DataTable _info = null;
- private DataTable _users = null;
- #endregion
- #region 构造函数
- public F_MST_1202(int groupID)
- {
- InitializeComponent();
- if (groupID > 0)
- {
- this.Text = "编辑工号分组";
- }
- else
- {
- this.Text = "新建工号分组";
- }
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.btnCancel.Text = ButtonText.BTN_CLOSE;
- this.dgvUser.AutoGenerateColumns = false;
- this._groupID = groupID;
- }
- #endregion
- #region 事件
- /// <summary>
- /// 关闭窗体
- /// </summary>
- private void btnCancel_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 提交新建
- /// </summary>
- private void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- if (string.IsNullOrEmpty(this.txtName.Text.Trim()))
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "分组名称"), this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtName.Focus();
- return;
- }
- if (this.dkDefectTypeNameSearchBox1.DefectTypeID == null)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "缺陷类别"), this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.dkDefectTypeNameSearchBox1.Focus();
- return;
- }
- int displayno = (this.txtDisplayNo.DataValue == null ? 0:Convert.ToInt32(this.txtDisplayNo.DataValue));
- this._info.Rows[0]["workergroupname"] = this.txtName.Text.Trim();
- this._info.Rows[0]["remarks"] = this.txtRemarks.Text;
- this._info.Rows[0]["displayno"] = displayno;
- this._info.Rows[0]["defecttypeid"] = this.dkDefectTypeNameSearchBox1.DefectTypeID.Value;
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "MST_WorkerGroup";
- cre.Name = "SetWorkerGroup";
- cre.Data = this._info.DataSet;
- cre.Data.AcceptChanges();
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return SystemModuleProxy.Service.DoBarCodePrint(cre);
- }
- );
- if (sre.Status == Constant.ServiceResultStatus.Success)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "工号分组", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.DialogResult = System.Windows.Forms.DialogResult.OK;
- this.Close();
- return;
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_MST_1202_Load(object sender, EventArgs e)
- {
- try
- {
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "MST_WorkerGroup";
- cre.Name = "GetWorkerGroupList";
- cre.Properties["GroupID"] = this._groupID;
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return SystemModuleProxy.Service.DoBarCodePrint(cre);
- }
- );
- if (sre.Status != Constant.ServiceResultStatus.Success)
- {
- this.Close();
- return;
- }
- this._info = sre.Data.Tables[0];
- this._users = sre.Data.Tables[1];
- if (this._groupID > 0)
- {
- if (this._info.Rows.Count == 0)
- {
- MessageBox.Show("数据不存在,请确认后再操作。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.Close();
- return;
- }
- this.txtName.Text = this._info.Rows[0]["WorkerGroupName"].ToString();
- this.txtDisplayNo.Text = this._info.Rows[0]["DisplayNo"].ToString();
- this.txtRemarks.Text = this._info.Rows[0]["Remarks"].ToString();
- this.dkDefectTypeNameSearchBox1.DefectTypeID = Convert.ToInt32(this._info.Rows[0]["DefectTypeID"]);
- //this.dkDefectTypeNameSearchBox1.DefectTypeName = this._info.Rows[0]["DefectTypeName"].ToString();
- this.dkDefectTypeNameSearchBox1.Text = this._info.Rows[0]["DefectTypeName"].ToString();
- }
- else
- {
- DataRow newRow = this._info.NewRow();
- newRow["WorkerGroupID"] = 0;
- this._info.Rows.Add(newRow);
- }
- this.dgvUser.DataSource = this._users;
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- private void btnAddUser_Click(object sender, EventArgs e)
- {
- try
- {
- S_CMN_013 frmSCMN013 = new S_CMN_013();
- DialogResult dialogResult = frmSCMN013.ShowDialog();
- if (dialogResult != System.Windows.Forms.DialogResult.OK)
- {
- return;
- }
- DataTable selDt = frmSCMN013.SelTable;
- if (selDt == null)
- {
- return;
- }
- foreach (DataRow userRow in selDt.Rows)
- {
- DataRow[] urs = this._users.Select(" userid = " + userRow["UserID"]);
- if (urs == null || urs.Length == 0)
- {
- this._users.Rows.Add(new object[] { userRow["UserID"], userRow["UserCode"], userRow["UserName"] });
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- private void btnDeleteUser_Click(object sender, EventArgs e)
- {
- try
- {
- DataGridViewRow dgvRow = this.dgvUser.CurrentRow;
- if (dgvRow != null)
- {
- DataRowView drv = dgvRow.DataBoundItem as DataRowView;
- if (drv != null)
- {
- drv.Delete();
- drv.EndEdit();
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #region 私有方法
- #endregion
- }
- }
|