| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PAM_0201.cs
- * 2.功能描述:工价分类
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 王鑫 2015/08/18 1.00 新建
- *******************************************************************************/
- using System;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Basics.DockPanel;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
- using Dongke.IBOSS.PRD.WCF.DataModels.PAMModule;
- namespace Dongke.IBOSS.PRD.Client.PAMModule
- {
- public partial class F_PAM_0301 : DockPanelBase
- {
- #region 成员变量
- //单例模式
- private static F_PAM_0301 _instance;
- // 最后选择行
- private int _selecedRow;
- #endregion
- #region 构造函数
- public F_PAM_0301()
- {
- InitializeComponent();
- this.Text = FormTitles.F_PAM_0301;
- this.btnSearch.Text = ButtonText.BTN_SEARCH;
- this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
- this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
- this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
- this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
- this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
- this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
- }
- #endregion
- #region 单例模式
- /// <summary>
- /// 单例模式,防止重复创建窗体
- /// </summary>
- public static F_PAM_0301 Instance
- {
- get
- {
- if (_instance == null)
- {
- _instance = new F_PAM_0301();
- }
- return _instance;
- }
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载
- /// </summary>
- private void F_PAM_0201_Load(object sender, EventArgs e)
- {
- this.dgvJobsPayPlan.AutoGenerateColumns = false;
- // 绑定工资方案数据源
- DataSet dsPayPlan = (DataSet)DoAsync(new AsyncMethod(() =>
- {
- return PAMModuleProxy.Service.GetPayPlan();
- }));
- if (dsPayPlan != null && dsPayPlan.Tables[0].Rows.Count > 0)
- {
- DataRow dr = dsPayPlan.Tables[0].NewRow();
- dr["PayPlanName"] = "";
- dr["PayPlanID"] = -1;
- dsPayPlan.Tables[0].Rows.InsertAt(dr, 0);
- cmbPayPlan.DataSource = dsPayPlan.Tables[0];
- cmbPayPlan.DisplayMember = "PayPlanName";
- cmbPayPlan.ValueMember = "PayPlanID";
- }
- tsbtnEdit.Size = new System.Drawing.Size(60,25);
- }
- /// <summary>
- /// 查询事件
- /// </summary>
- private void btnSearch_Click(object sender, EventArgs e)
- {
- try
- {
- // 记录当前选中行
- int selectRowIndex = this._selecedRow;
- // 异步处理
- this.btnSearch.Enabled = false;
- this.btnClearCondition.Enabled = false;
- PieceworkEntity pieceworkEndit = new PieceworkEntity();
- pieceworkEndit.PayPlanName = this.txtName.Text.Trim();
- if(cmbPayPlan.Text!="")
- {
- pieceworkEndit.PayPlanID = Convert.ToInt32(cmbPayPlan.SelectedValue);
- }
-
- DataSet dsProductionData = (DataSet)DoAsync(new AsyncMethod(() =>
- {
- return PAMModuleProxy.Service.GetPieceworkData(pieceworkEndit);
- }));
- this.btnSearch.Enabled = true;
- this.btnClearCondition.Enabled = true;
- if (dsProductionData != null)
- {
- base.DataSource = dsProductionData;
- if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
- {
- this.dgvJobsPayPlan.DataSource = this.DataSource.Tables[0];
- if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
- {
- // 提示未查找到数据
- MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- if (selectRowIndex >= Constant.INT_IS_ZERO)
- {
- if (selectRowIndex >= dsProductionData.Tables[0].Rows.Count)
- {
- this.dgvJobsPayPlan.Rows[this.dgvJobsPayPlan.Rows.Count - 1].Selected = true;
- this.dgvJobsPayPlan.CurrentCell = this.dgvJobsPayPlan.Rows[this.dgvJobsPayPlan.Rows.Count - 1].Cells["PayPlanName"];
- }
- else
- {
- this.dgvJobsPayPlan.Rows[selectRowIndex].Selected = true;
- this.dgvJobsPayPlan.CurrentCell = this.dgvJobsPayPlan.Rows[selectRowIndex].Cells["PayPlanName"];
- }
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- this.btnSearch.Enabled = true;
- this.btnClearCondition.Enabled = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 清空事件
- /// </summary>
- private void btnClearCondition_Click(object sender, EventArgs e)
- {
- //this.dkProcedureSearchBox.ClearControl();
- //this.radAll.Checked = true;
- this.txtName.Text = "";
- this.cmbPayPlan.SelectedValue = -1;
- }
- /// <summary>
- /// 关闭窗体事件
- /// </summary>
- private void tsbtnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 自适应事件
- /// </summary>
- private void tsbtnAdaptive_Click(object sender, EventArgs e)
- {
- this.dgvJobsPayPlan.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); ;
- }
- /// <summary>
- /// 窗体关闭事件
- /// </summary>
- private void F_PAM_0201_FormClosed(object sender, FormClosedEventArgs e)
- {
- _instance = null;
- }
- /// <summary>
- /// 添加事件
- /// </summary>
- private void tsbtnAdd_Click(object sender, EventArgs e)
- {
- try
- {
- //以新建模式打开信息窗体
- F_PAM_0302 frmPAM0302 = new F_PAM_0302(Constant.FormMode.Add, null);
- DialogResult dialogResult = frmPAM0302.ShowDialog();
- if (dialogResult == DialogResult.OK)
- {
- btnSearch_Click(sender, e);
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- ///编辑事件
- /// </summary>
- private void tsbtnEdit_Click(object sender, EventArgs e)
- {
- try
- {
- DataGridViewRow currentRow = this.dgvJobsPayPlan.CurrentRow;
- if (currentRow != null)
- {
- //获取需要的信息ID
- int entityId = Convert.ToInt32(currentRow.Cells["PayPlanID"].Value);
- //以复制模式打开信息窗体
- F_PAM_0103 frmPAM0103 = new F_PAM_0103(Constant.FormMode.Edit, entityId);
- DialogResult dialogResult = frmPAM0103.ShowDialog();
- //操作成功后刷新数据源
- if (dialogResult == DialogResult.OK)
- {
- btnSearch_Click(sender, e);
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- /// <summary>
- /// 编辑按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnEdit_Click_1(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvJobsPayPlan.CurrentRow != null)
- {
- F_PAM_0302 frmPAM0302 = new F_PAM_0302(Constant.FormMode.Edit, Convert.ToInt32(this.dgvJobsPayPlan.CurrentRow.Cells["PieceTacticsID"].Value));
- DialogResult dialogResult = frmPAM0302.ShowDialog();
- if (dialogResult.Equals(DialogResult.OK))
- {
- btnSearch_Click(sender, e);
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- }
- }
|