using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Threading; using System.Collections; using System.Reflection; using CoreFS.CA06; namespace Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIFrm { public partial class FrmFundTransfer : FrmFundBase { public FrmFundTransfer() { InitializeComponent(); } private DataSet dsBuyerCode = new DataSet(); private DataSet dsSecCode = new DataSet(); private DataSet dsPact = new DataSet(); private void InitDataSource() { dsBuyerCode = base.GetDataSetByColumnName(this.GetCustFundDataStruct(), new Hashtable(), base.GetFundColumnNameAndCaption()); this.ultraGrid1.DataSource = dsBuyerCode; dsSecCode = base.GetDataSetByColumnName(this.GetSecFundDataStruct(), new Hashtable(), base.GetFundColumnNameAndCaption()); this.ultraGrid2.DataSource = dsSecCode; dsPact = base.GetDataSetByColumnName(this.GetPactFundDataStruct(), new Hashtable(), base.GetFundColumnNameAndCaption()); this.ultraGrid3.DataSource = dsPact; } private void ClearDs() { this.dsSecCode.Clear(); this.dsPact.Clear(); } private void SetGridValue() { } private void InitGrid() { try { this.ultraGrid1.DisplayLayout.Bands[0].Columns["BUTTON"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Button; this.ultraGrid1.DisplayLayout.Bands[0].Columns["BUTTON"].ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle.OnMouseEnter; this.ultraGrid1.DisplayLayout.Bands[0].Columns["BUTTON"].Width = 40; this.ultraGrid2.DisplayLayout.Bands[0].Columns["BUTTON"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Button; this.ultraGrid2.DisplayLayout.Bands[0].Columns["BUTTON"].ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle.OnMouseEnter; this.ultraGrid2.DisplayLayout.Bands[0].Columns["RBUTTON"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Button; this.ultraGrid2.DisplayLayout.Bands[0].Columns["RBUTTON"].ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle.OnMouseEnter; this.ultraGrid2.DisplayLayout.Bands[0].Columns["BUTTON"].Width = 40; this.ultraGrid2.DisplayLayout.Bands[0].Columns["RBUTTON"].Width = 40; this.ultraGrid3.DisplayLayout.Bands[0].Columns["BUTTON"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Button; this.ultraGrid3.DisplayLayout.Bands[0].Columns["BUTTON"].ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle.OnMouseEnter; this.ultraGrid3.DisplayLayout.Bands[0].Columns["BUTTON"].Width = 40; this.ultraGrid1.DisplayLayout.Bands[0].Columns["RMONEY"].Width = 70; this.ultraGrid2.DisplayLayout.Bands[0].Columns["RMONEY"].Width = 70; this.ultraGrid2.DisplayLayout.Bands[0].Columns["LMONEY"].Width = 70; this.ultraGrid3.DisplayLayout.Bands[0].Columns["LMONEY"].Width = 70; this.ultraGrid1.DisplayLayout.Bands[0].Columns["RMONEY"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit; this.ultraGrid1.DisplayLayout.Bands[0].Columns["RMONEY"].CellAppearance.BackColor = base.GetEditColor(); this.ultraGrid2.DisplayLayout.Bands[0].Columns["RMONEY"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit; this.ultraGrid2.DisplayLayout.Bands[0].Columns["RMONEY"].CellAppearance.BackColor = base.GetEditColor(); this.ultraGrid2.DisplayLayout.Bands[0].Columns["LMONEY"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit; this.ultraGrid2.DisplayLayout.Bands[0].Columns["LMONEY"].CellAppearance.BackColor = base.GetEditColor(); this.ultraGrid3.DisplayLayout.Bands[0].Columns["LMONEY"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit; this.ultraGrid3.DisplayLayout.Bands[0].Columns["LMONEY"].CellAppearance.BackColor = base.GetEditColor(); } catch { } } protected override List GetNumberColumn() { return new List(new string[] { "RMONEY", "LMONEY" }); } private void FrmFundTransfer_Load(object sender, EventArgs e) { InitDataSource(); HIddenColumn(); base.SetGridStyle(ref this.ultraGrid1, ref this.ultraGrid3, ref this.ultraGrid2); InitGrid(); } private void HIddenColumn() { try { this.ultraGrid1.DisplayLayout.Bands[0].Columns[base._columnBalanceSubject].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns[base._columnBuyercode].Hidden = true; this.ultraGrid2.DisplayLayout.Bands[0].Columns[base._columnBalanceSubject].Hidden = true; this.ultraGrid2.DisplayLayout.Bands[0].Columns[base._columnBuyercode].Hidden = true; this.ultraGrid3.DisplayLayout.Bands[0].Columns[base._columnBalanceSubject].Hidden = true; this.ultraGrid3.DisplayLayout.Bands[0].Columns[base._columnBuyercode].Hidden = true; this.ultraGrid3.DisplayLayout.Bands[0].Columns[base._columnSecondaccount].Hidden = true; } catch { } } public override void ToolBar_Click(object sender, string ToolbarKey) { if (ToolbarKey == "Query") { this.Query(); } if (ToolbarKey == "Exit") { this.Close(); } if (ToolbarKey == "Close") { this.Close(); } } private string _buyercode = ""; private void Query() { if (this._buyercode.Length == 0) { Core.StlMes.Client.Sale.Util.MessageUtil.ShowError("请选择客户名称"); return; } ClearDs(); // 获取结算单位 string balanceSubject = base.GetSaleOrgDesc(); string buyercode = _buyercode; DataSet ds = base.GetInstanceCustAccount().GetCustAccountByBalanceSubjectAndBuyercode(balanceSubject, buyercode); Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsBuyerCode, ds); InitText(); } private void InitText() { try { foreach (DataRow dr in this.dsBuyerCode.Tables[0].Rows) { dr["BUTTON"] = ">>>"; } } catch { } try { foreach (DataRow dr in this.dsSecCode.Tables[0].Rows) { dr["BUTTON"] = "<<<"; dr["RBUTTON"] = ">>>"; } } catch { } try { foreach (DataRow dr in this.dsPact.Tables[0].Rows) { dr["BUTTON"] = "<<<"; } } catch { } } private void QuerySecAccount() { try { DataSet ds = null; Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null; string buyercode = ""; string balancesubject = ""; if (this.ultraGrid1.Rows.Count == 0) { return; } if (this.ultraGrid1.Rows.Count == 1) { ugr = this.ultraGrid1.Rows[0]; } else { ugr = this.ultraGrid1.ActiveRow; } if (ugr != null) { balancesubject = ugr.Cells[base._columnBalanceSubject].Value.ToString(); buyercode = ugr.Cells[base._columnBuyercode].Value.ToString(); } ds = base.GetInstanceSecondLevelAccount().GetSecondLevelAccountByBalanceAndBuyercode(balancesubject, buyercode); Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsSecCode, ds); InitText(); // Util.UltraGridUtil.SetStaticsInfoSum(ref this.ultraGrid2, this.TotalColumn(), true); // HiddenGrid2(); } catch { } } private void QueryPactAccount() { try { DataSet ds = null; Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null; string buyercode = ""; string balancesubject = ""; string secondAccount = ""; if (this.ultraGrid2.Rows.Count == 0) { return; } if (this.ultraGrid2.Rows.Count == 1) { ugr = this.ultraGrid2.Rows[0]; } else { ugr = this.ultraGrid2.ActiveRow; } if (ugr != null) { balancesubject = ugr.Cells[base._columnBalanceSubject].Value.ToString(); buyercode = ugr.Cells[base._columnBuyercode].Value.ToString(); secondAccount = ugr.Cells[base._columnSecondaccount].Value.ToString(); } ds = base.GetInstancePactAccount().GetFundPactAccountByBalanceAndBuyercodeAndSecondAccount(balancesubject, buyercode, secondAccount); Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsPact, ds); InitText(); } catch { } } /// /// 从合同账户调拨资金到二级账户 /// private void TransferMoneyPactToSecond() { try { string errMsg = ""; Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null; if (this.ultraGrid3.Rows.Count == 0) return; if (this.ultraGrid3.Rows.Count == 1) ugr = this.ultraGrid3.Rows[0]; else ugr = this.ultraGrid3.ActiveRow; if (ugr == null) return; double money = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(ugr.Cells["LMONEY"].Value); Model.SEL_FUND_TRANS_PACT sceact = GetTransPactAccount(money); if (sceact == null) return; base.GetInstanceTransfer().TransferMoneyPactToSecondAccount(sceact, out errMsg); if (errMsg.Length == 0) { MessageBox.Show(base._successMsg); } else { MessageBox.Show(errMsg); } } catch { } } private void TransferMoneySecondToPact() { try { string errMsg = ""; Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null; if (this.ultraGrid2.Rows.Count == 0) return; if (this.ultraGrid2.Rows.Count == 1) ugr = this.ultraGrid2.Rows[0]; else ugr = this.ultraGrid2.ActiveRow; if (ugr == null) return; double money = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(ugr.Cells["RMONEY"].Value); Model.SEL_FUND_TRANS_PACT sceact = GetTransPactAccount(money); if (sceact == null) return; base.GetInstanceTransfer().TransferMoneySecondAccountToPact(sceact, out errMsg); if (errMsg.Length == 0) { Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips(base._successMsg); } else { Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(errMsg); } } catch { } } private void TransferMoneyCustToSecond() { try { Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null; if (this.ultraGrid1.Rows.Count == 0) return; if (this.ultraGrid1.Rows.Count == 1) ugr = this.ultraGrid1.Rows[0]; else ugr = this.ultraGrid1.ActiveRow; if (ugr == null) return; double money = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble( ugr.Cells["RMONEY"].Value); string errMsg = ""; Model.SEL_FUND_TRANS_SECONDACCOUNT sceact = GetTransSecAccount(money); if (sceact == null) return; base.GetInstanceTransfer().TransferMoneyCustToSecondAccount(sceact, out errMsg); if (errMsg.Length == 0) { MessageBox.Show(base._successMsg); } else { MessageBox.Show(errMsg); } } catch { } } private void TransferMoneySecondToCust() { try { Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null; if (this.ultraGrid2.Rows.Count == 0) return; if (this.ultraGrid2.Rows.Count == 1) ugr = this.ultraGrid2.Rows[0]; else ugr = this.ultraGrid2.ActiveRow; if (ugr == null) return; double money = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(ugr.Cells["LMONEY"].Value); string errMsg = ""; Model.SEL_FUND_TRANS_SECONDACCOUNT sceact = GetTransSecAccount(money); if (sceact == null) return; base.GetInstanceTransfer().TransferMoneySecondAccountToCust(sceact, out errMsg); if (errMsg.Length == 0) { MessageBox.Show(base._successMsg); } else { MessageBox.Show(errMsg); } } catch { } } private Model.SEL_FUND_TRANS_PACT GetTransPactAccount(double money) { Model.SEL_FUND_TRANS_SECONDACCOUNT secact = GetTransSecAccount(money); Model.SEL_FUND_TRANS_PACT pact = new Model.SEL_FUND_TRANS_PACT(); if (secact == null) return null; if (this.ultraGrid3.Rows.Count == 0) return null; if (this.ultraGrid2.ActiveRow == null) return null; if (this.ultraGrid3.ActiveRow == null) return null; string pactno = this.ultraGrid3.ActiveRow.Cells[base._columnPactno].Value.ToString(); if (money <= 0) return null; pact.FUND_TRANS_SECONDACCOUNT = secact; pact.PACTNO = pactno; pact.TRANS_MONEY = money; return pact; } private Model.SEL_FUND_TRANS_SECONDACCOUNT GetTransSecAccount(double money) { Model.SEL_FUND_TRANS_CUST cust = GetTransCustAccount(money); if (cust == null) return null; if (this.ultraGrid1.Rows.Count == 0) return null; if (this.ultraGrid2.ActiveRow == null) return null; string secondLevelAccount = this.ultraGrid2.ActiveRow.Cells[base._columnSecondaccount].Value.ToString(); if (money <= 0) return null; Model.SEL_FUND_TRANS_SECONDACCOUNT sec = new Model.SEL_FUND_TRANS_SECONDACCOUNT(); sec.FUND_TRANS_CUST = cust; sec.SECONDACCOUNT = secondLevelAccount; sec.TRANS_MONEY = money; return sec; } private Model.SEL_FUND_TRANS_CUST GetTransCustAccount(double money) { Infragistics.Win.UltraWinGrid.UltraGridRow ugrLeft = null; Infragistics.Win.UltraWinGrid.UltraGridRow ugrRight = null; string balancesubject = ""; string buyercode = ""; string secondLevelAccount = ""; if (this.ultraGrid1.ActiveRow == null) return null; if (this.ultraGrid1.ActiveRow == null) return null; ugrLeft = this.ultraGrid1.ActiveRow; ugrRight = this.ultraGrid2.ActiveRow; // money = Convert.ToDouble(this.ultraNumericEditor1.Value); if (money <= 0) return null; balancesubject = ugrLeft.Cells[base._columnBalanceSubject].Value.ToString(); buyercode = ugrLeft.Cells[base._columnBuyercode].Value.ToString(); secondLevelAccount = ugrRight.Cells[base._columnSecondaccount].Value.ToString(); Model.SEL_FUND_TRANS_CUST cust = new Model.SEL_FUND_TRANS_CUST(); cust.BALANCESUBJECT = balancesubject; cust.BUYERCODE = buyercode; cust.TRANS_MONEY = money; cust.TRANS_PERSON = base.GetUserName(); cust.TRANS_TIME = Util.DateTimeUtil.GetSystemDate(); return cust; } protected override Hashtable GetDataSetColumnCaption() { Hashtable hs = new Hashtable(); hs.Add("RMONEY", "金额"); hs.Add("LMONEY", "金额"); hs.Add("BUTTON", ""); hs.Add("RBUTTON", ""); return hs; } protected override Hashtable ColumnNameAndWidht() { Hashtable hs = new Hashtable(); hs.Add("RMONEY", "80"); hs.Add("LMONEY", "80"); return hs; } protected override Hashtable GetGridColumnLength() { Hashtable hs = new Hashtable(); hs.Add("BUYERCODE",100); hs.Add("TOTALMONEY", 80); hs.Add("LEAVEMONEY", 80); hs.Add("SECONDACCOUNT", 100); hs.Add("PACTNO", 100); return hs; } private string[] GetCustFundDataStruct() { return new string[] { "BALANCESUBJECT", "BUYERCODE", "TOTALMONEY", "LEAVEMONEY", "RMONEY", "BUTTON" }; } private string[] GetSecFundDataStruct() { return new string[] { "BALANCESUBJECT", "BUYERCODE", "BUTTON", "LMONEY", "SECONDACCOUNT", "TOTALMONEY", "LEAVEMONEY", "RMONEY", "RBUTTON" }; } private string[] GetPactFundDataStruct() { return new string[] { "BALANCESUBJECT", "BUYERCODE", "SECONDACCOUNT", "BUTTON", "LMONEY", "PACTNO", "TOTALMONEY", "LEAVEMONEY" }; } private void button1_Click(object sender, EventArgs e) { UIDlgBox.DlgCustChoose custChoose = new Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIDlgBox.DlgCustChoose(this.ob); custChoose.CustUse = "100202"; custChoose.SaleOrg = base.GetSaleOrg(); custChoose.ShowDialog(); if (custChoose.DialogResult == DialogResult.OK) { this.textBox1.Text = custChoose.customerName; _buyercode = custChoose.customerNo; } } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { QuerySecAccount(); } private void ultraGrid2_AfterRowActivate(object sender, EventArgs e) { QueryPactAccount(); } private void ultraGrid1_ClickCellButton(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { if (e.Cell.Column.Key == "BUTTON") { this.TransferMoneyCustToSecond(); this.Query(); } } private void ultraGrid2_ClickCellButton(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { if (e.Cell.Column.Key == "BUTTON") { this.TransferMoneySecondToCust(); this.Query(); } if (e.Cell.Column.Key == "RBUTTON") { this.TransferMoneySecondToPact(); this.QuerySecAccount(); } } private void ultraGrid3_ClickCellButton(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { if (e.Cell.Column.Key == "BUTTON") { this.TransferMoneyPactToSecond(); this.QuerySecAccount(); } } } }