| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_MST_1201.cs
- * 2.功能描述:工号分组一览
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 陈晓野 2016/11/10 1.00 新建
- *******************************************************************************/
- using System;
- using System.Reflection;
- using System.Windows.Forms;
- 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;
- using Dongke.WinForm.Controls;
- namespace Dongke.IBOSS.PRD.Client.SystemModule
- {
- public partial class F_MST_1201 : DKDockPanelBase
- {
- #region 成员变量
- private ClientRequestEntity _clientRequestEntity = null; // 查询条件实体
- private static F_MST_1201 _instance = null;
- #endregion
- #region 构造函数
- public F_MST_1201()
- {
- InitializeComponent();
- // 窗口标题
- this.Text = "工号分组(缺陷类型)";
- // 工具栏按钮文本赋值
- this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
- this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
- this.tsbtnStop.Text = ButtonText.TSBTN_DISABLE;
- this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
- this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
- // 查询、清空条件按钮文本赋值
- this.tsbtnSearch.Text = ButtonText.BTN_SEARCH;
- this.tsbtnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
- // 设置表格不自动创建列
- this.dgvGroup.AutoGenerateColumns = false;
- this.chkValueFlag.FlagBoxChecked = FlagCheckBoxChecked.Yes;
- // 编辑、导出和预览按钮不可用
- this.tsbtnEdit.Enabled = false;
- this.tsbtnStop.Visible = false;
- }
- #endregion
- #region 单例模式
- /// <summary>
- /// 单例模式,防止重复创建窗体
- /// </summary>
- public static F_MST_1201 Instance
- {
- get
- {
- if (_instance == null)
- {
- _instance = new F_MST_1201();
- }
- return _instance;
- }
- }
- #endregion
- #region 控件事件
- /// <summary>
- /// 打开画面
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_MST_1201_Load(object sender, EventArgs e)
- {
- try
- {
- // 加载权限
- FormPermissionManager.FormPermissionControl(this.Name, this,
- Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
- Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 画面关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_MST_012001_FormClosed(object sender, FormClosedEventArgs e)
- {
- _instance = null;
- }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnSearch_Click(object sender, EventArgs e)
- {
- try
- {
- this.QueryDataFromOther();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 清空查询条件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnClearCondition_Click(object sender, EventArgs e)
- {
- this.ClearConditions();
- }
- /// <summary>
- /// 点击新建票据按钮,新建票据
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAddInvoice_Click(object sender, System.EventArgs e)
- {
- try
- {
- F_MST_1202 frm012002 = new F_MST_1202(0);
- DialogResult dialogresult = frm012002.ShowDialog();
- if (DialogResult.OK == dialogresult)
- {
- QueryDataFromOther();
- }
- }
- 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 tsbtnEdit_Click(object sender, EventArgs e)
- {
- try
- {
- // 获取活动行
- DataGridViewRow currentRow = this.dgvGroup.CurrentRow;
- if (currentRow != null)
- {
- int id = Convert.ToInt32(currentRow.Cells["workergroupid"].Value);
- F_MST_1202 frm012002 = new F_MST_1202(id);
- DialogResult dialogresult = frm012002.ShowDialog();
- if (DialogResult.OK == dialogresult)
- {
- QueryDataFromOther();
- }
- }
- }
- 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 tsbtnAdaptive_Click(object sender, System.EventArgs e)
- {
- this.dgvGroup.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- this.dgvUser.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- }
- /// <summary>
- /// KeyDown事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvInvoice_KeyDown(object sender, KeyEventArgs e)
- {
- try
- {
- if (e.KeyData == (Keys.Control | Keys.C))
- {
- if (dgvGroup.CurrentRow != null
- && !string.IsNullOrEmpty(dgvGroup.CurrentRow.Cells
- [dgvGroup.CurrentCell.ColumnIndex].EditedFormattedValue + ""))
- {
- try
- {
- Clipboard.SetText(dgvGroup.CurrentRow.Cells
- [dgvGroup.CurrentCell.ColumnIndex].EditedFormattedValue + "");
- }
- catch { }
- }
- }
- }
- 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 tsbtnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 所选数据发生改变时
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvInvoice_SelectionChanged(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvGroup.CurrentCell == null)
- {
- this.tsbtnEdit.Enabled = false;
- this.tsbtnStop.Visible = false;
- }
- else
- {
- this.tsbtnEdit.Enabled = true;
- this.tsbtnStop.Visible = true;
- }
- DataGridViewRow currentRow = this.dgvGroup.CurrentRow;
- if (currentRow != null)
- {
- string flag = currentRow.Cells["valueflag"].Value.ToString();
- if ("1" == flag)
- {
- this.tsbtnStop.Text = ButtonText.TSBTN_DISABLE;
- }
- else
- {
- this.tsbtnStop.Text = "启用(&S)";
- }
- this.tsbtnStop.Tag = flag;
- int id = Convert.ToInt32(currentRow.Cells["workergroupid"].Value);
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "MST_WorkerGroup";
- cre.Name = "GetWorkerGroupList";
- cre.Properties["WorkerGroupDetail"] = 1;
- cre.Properties["GroupID"] = id;
- this.dgvUser.DataSource = null;
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return SystemModuleProxy.Service.DoBarCodePrint(cre);
- }
- );
- if (sre.Status == Constant.ServiceResultStatus.Success)
- {
- // 查询成功
- this.dgvUser.DataSource = sre.Data.Tables[0];
- if (sre.Data.Tables[0].Rows.Count > 0)
- {
- this.dgvUser.Rows[0].Selected = true;
- }
- }
- }
- }
- 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 dgvInvoice_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- if (-1 < e.RowIndex && -1 < e.ColumnIndex && this.tsbtnEdit.Enabled)
- {
- this.tsbtnEdit_Click(sender, e);
- }
- }
- /// <summary>
- /// 停用
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnStop_Click(object sender, EventArgs e)
- {
- try
- {
- DataGridViewRow currentRow = this.dgvGroup.CurrentRow;
- if (currentRow != null)
- {
- string flag = currentRow.Cells["valueflag"].Value.ToString();
- int id = Convert.ToInt32(currentRow.Cells["workergroupid"].Value);
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "MST_WorkerGroup";
- cre.Name = "SetWorkerGroupValueFlag";
- cre.Properties["ValueFlag"] = ("1" == flag ? "0" : "1");
- cre.Properties["GroupID"] = id;
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return SystemModuleProxy.Service.DoBarCodePrint(cre);
- }
- );
- if (sre.Status == Constant.ServiceResultStatus.Success)
- {
- // 查询成功
- QueryDataFromOther();
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- #region 重写方法
- /// <summary>
- /// 查询数据
- /// </summary>
- /// <returns>验证通过true,其他false</returns>
- private void QueryDataFromOther()
- {
- try
- {
- this.SearchSelectEntity();
- this.dgvGroup.DataSource = null;
- this.dgvUser.DataSource = null;
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return SystemModuleProxy.Service.DoBarCodePrint(this._clientRequestEntity);
- }
- );
- if (sre.Status == Constant.ServiceResultStatus.Success)
- {
- // 查询成功
- this.dgvGroup.DataSource = sre.Data.Tables[0];
- if (sre.Data.Tables[0].Rows.Count > 0)
- {
- this.dgvGroup.Rows[0].Selected = true;
- }
- this.dgvUser.DataSource = sre.Data.Tables[1];
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 清除查询条件
- /// </summary>
- public void ClearConditions()
- {
- this.txtGroupName.Text = string.Empty;
- this.dkDefectTypeNameSearchBox1.ClearControl();
- this.txtRemarks.Text = string.Empty;
- this.chkValueFlag.FlagBoxChecked = FlagCheckBoxChecked.Yes;
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 获取查询实体
- /// </summary>
- private void SearchSelectEntity()
- {
- this._clientRequestEntity = new ClientRequestEntity();
- this._clientRequestEntity.NameSpace = "MST_WorkerGroup";
- this._clientRequestEntity.Name = "GetWorkerGroupList";
- // 模板名称
- this._clientRequestEntity.Properties["GroupName"] = this.txtGroupName.Text.Trim();
- this._clientRequestEntity.Properties["Remarks"] = this.txtRemarks.Text;
- if (!string.IsNullOrEmpty(this.dkDefectTypeNameSearchBox1.DefectTypeIDS))
- {
- this._clientRequestEntity.Properties["DefectTypes"] = "," +this.dkDefectTypeNameSearchBox1.DefectTypeIDS + ",";
- }
- // 正常标识
- if (this.chkValueFlag.FlagBoxChecked == FlagCheckBoxChecked.Yes)
- {
- this._clientRequestEntity.Properties["valueflag"] = "1";
- }
- else if (this.chkValueFlag.FlagBoxChecked == FlagCheckBoxChecked.No)
- {
- this._clientRequestEntity.Properties["valueflag"] = "0";
- }
- }
- #endregion
- }
- }
|