| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- 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;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Windows.Forms;
- namespace Dongke.IBOSS.PRD.Client.SAPDataModule.Hegii
- {
- public partial class F_SAP_HEGII_0110 : DKDockPanelBase
- {
- #region 成员变量
- private static F_SAP_HEGII_0110 _instance = null;
- private static DataTable _CostCenterDt = null;
- #endregion
- #region 单例模式
- /// <summary>
- /// 单例模式,防止重复创建窗体
- /// </summary>
- public static F_SAP_HEGII_0110 Instance
- {
- get
- {
- if (_instance == null)
- {
- _instance = new F_SAP_HEGII_0110();
- }
- return _instance;
- }
- }
- #endregion
- #region 构造函数
- public F_SAP_HEGII_0110()
- {
- InitializeComponent();
- }
- public F_SAP_HEGII_0110(DataTable dt)
- {
- InitializeComponent();
- this.Text = "BPM成本中心设置 ";
- this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
- _CostCenterDt = dt;
- this.dgvCenter.AutoGenerateColumns = false;
- }
- #endregion
- #region 事件
- /// <summary>
- /// 查询事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnSearch_Click(object sender, EventArgs e)
- {
- try
- {
- this.QueryDataFromOther();
- this.tsbtnAdaptive_Click(null, null) ;
- }
- 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 btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- tsrToolStrip1.Focus();
- DataTable data = (DataTable)this.dgvCenter.DataSource;
- if (data == null || data.Rows.Count == 0)
- {
- return;
- }
- DataTable datacp = data.Copy();
- datacp.DefaultView.RowFilter = "check1 =1 ";
- DataTable checkedDt = datacp.DefaultView.ToTable();
- if (checkedDt.Rows.Count == 0)
- {
- DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, "未选择任何数据");
- return;
- }
- else if (checkedDt.Rows.Count >1)
- {
- DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, "请选择一条数据");
- return;
- }
- DialogResult dr = MessageBox.Show("是否对所选数据进行保存?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (dr != System.Windows.Forms.DialogResult.Yes)
- {
- return;
- }
- // 调用服务器端获取数据集
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "Hegii";
- cre.Name = "SaveCostCenter";
- cre.Properties["CostCenter"] = checkedDt.Rows[0]["COSTCENTER"];
- cre.Properties["CostCenterName"] = checkedDt.Rows[0]["COSTCENTERNAME"];
- DataTable costdt = _CostCenterDt.Copy();
- DataSet ds = new DataSet();
- ds.Tables.Add(costdt);
- cre.Data=ds;
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return SAPDataModuleProxy.Service.DoRequest(cre);
- });
- if (sre.Status == Constant.ServiceResultStatus.Success)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "成本中心", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.DialogResult = DialogResult.OK;
- }
- }
- 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_SAP_HEGII_0110_FormClosed(object sender, FormClosedEventArgs e)
- {
- _instance = null;
- }
- /// <summary>
- /// 清空条件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnClearCondition_Click(object sender, EventArgs e)
- {
- this.txtCostcenter.Clear();
- this.txtCostcenterName.Clear();
- }
- /// <summary>
- /// 自适应列宽
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAdaptive_Click(object sender, EventArgs e)
- {
- this.dgvCenter.AutoResizeColumns();
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- #endregion
- #region 私有方法
- private void QueryDataFromOther()
- {
-
- this.dgvCenter.DataSource = null;
- this.tsrToolStrip1.Focus();
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.Properties["CostCenter"] = this.txtCostcenter.Text.Trim();
- cre.Properties["CostcenterName"] = this.txtCostcenterName.Text.Trim();
- cre.NameSpace = "Hegii";
- cre.Name = "GetCostCenter";
- ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
- {
- return SAPDataModuleProxy.Service.DoRequest(cre);
- });
- if (sre.Status == Constant.ServiceResultStatus.Success)
- {
- // 查询成功
- this.dgvCenter.DataSource = sre.Data.Tables[0];
- if (this.dgvCenter.RowCount == 0)
- {
- DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_001);
- }
- }
- }
- #endregion
-
- }
- }
|