using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Infragistics.Win.UltraWinGrid; using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Sale.SaleFundMgt.Model; using System.IO; using NPOI.SS.UserModel; using CoreFS.CA06; using Core.Mes.Client.Comm.Format; using System.Collections; namespace Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIFrm { public partial class FrmFundInOut : FrmFundBase { public FrmFundInOut() { InitializeComponent(); EntityHelper.ShowGridCaption(ultraGrid3.DisplayLayout.Bands[0]); } private DataSet dsMain = new DataSet(); private DataSet dsDetail = new DataSet(); private string _buyercode = ""; private string _buyercodeNotChooseInfo = "未选择客户名称"; private string _FrmText = "客户资金进出管理"; FundBLL.ValueList.PubValueList PubValueList = null; private Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.Fund.FundBll fundBll = null; private System.Collections.Hashtable _hsDept = null; private void FrmFundInOut_Load(object sender, EventArgs e) { fundBll = new Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.Fund.FundBll(this.ob); PubValueList = new Core.StlMes.Client.Sale.SaleFundMgt.FundBLL.ValueList.PubValueList(this.ob); dsMain = base.GetDataSetByColumnName(base.GetTbColumn_SEL_FUND_SEC_ACCOUNT(), new System.Collections.Hashtable(), base.GetFundColumnNameAndCaption()); this.ultraGrid1.DataSource = dsMain; dsDetail = base.GetDataSetByColumnName(base.GetTbColumn_SEL_FUND_CUST_FUNDINOUT(), new System.Collections.Hashtable(), base.GetFundColumnNameAndCaption()); this.ultraGrid2.DataSource = dsDetail; Init(); base.SetGridStyle(ref this.ultraGrid1, ref this.ultraGrid2); _hsDept = this.GetDeptIdAndSaleArea(); this.checkBox3.Visible = true; this.checkBox2.Visible = true; this.checkBox2.Checked = true; string sqlStr = "SELECT T.ORDER_NO FROM SLM_ORDER_HEAD T WHERE T.VALIDFLAG='1' ORDER BY T.ORDER_NO"; DataSet dsOrder = base.ExecuteReader(sqlStr); utOrderNo.DataSource = dsOrder.Tables[0]; utOrderNo.DisplayMember = "ORDER_NO"; utOrderNo.ValueMember = "ORDER_NO"; selFundCustFundinoutExcelBindingSource.DataSource = new List() { new SelFundCustFundinoutExcel() { InvoiceSts = "0" } }; } private Infragistics.Win.ValueList GetIsValid() { Infragistics.Win.ValueList lit = new Infragistics.Win.ValueList(); lit.ValueListItems.Add("0", "无效"); lit.ValueListItems.Add("1", "有效"); return lit; } protected override System.Collections.Hashtable GetGridColumnLength() { return base.GetGridColumnLengthDefine(); } private void Init() { try { this.ultraGrid1.DisplayLayout.Bands[0].Columns["BUYERCODE"].ValueList = PubValueList.GetCustomerInfo(); } catch { } try { this.ultraGrid2.DisplayLayout.Bands[0].Columns[ISVALID].ValueList = GetIsValid(); } catch { } this.comboBox1.DataSource = new System.Collections.ArrayList(FundType()); this.textBox4.DataSource = new System.Collections.ArrayList(FundUse()); try { foreach (string s in new string[] { base._columnBalanceSubject, base._columnBuyercode }) { this.ultraGrid2.DisplayLayout.Bands[0].Columns[s].Hidden = true; } } catch { } } private void button4_Click(object sender, EventArgs e) { } private string _balanceSubject = ""; private string[] FundType() { return new string[] { "现金", "电汇", "纸质商业承兑", "纸质银行承兑", "转款", "抹账购管", "电子银行承兑", "电子商业承兑", "其他" }; } private string[] FundUse() { return new string[] { "预付款", "货款", "提货款", "质保金", "其它" }; } protected override string[] HiddenColumn() { return new string[] { }; } public override void ToolBar_Click(object sender, string ToolbarKey) { if (ToolbarKey == "Query") { this.Query(); } if (ToolbarKey == "Create") { this.CreateCustAccount(); } if (ToolbarKey == "Close") { this.Close(); } if (ToolbarKey == "InMny") { this.InMoney(); } if (ToolbarKey == "OutMny") { this.OutMoney(); } if (ToolbarKey == "Affrim") { this.Affrim(); } if (ToolbarKey == "Print") { this.Print(); } if (ToolbarKey == "Delete") { this.Delete(); } if (ToolbarKey == "Template") { GridHelper.ulGridToExcel(ultraGrid3, "导入模板"); } if (ToolbarKey == "Import") { this.Import(); } } private void Import() { List lists = null; var openFileDialog = new OpenFileDialog { Filter = "回款|*.xls;*.xlsx" }; if (openFileDialog.ShowDialog() == DialogResult.OK) { lists = ReadExcelToSelFundCustFundinoutExcel(openFileDialog.FileName); } if (lists == null) return; if (lists.Count <= 0) { MessageBox.Show("Excel无数据"); return; } DataSet ds = new Core.StlMes.Client.Sale.SaleFundMgt.FundBLL.InterfaceMgt.SlmBaseCustomer(ob).GetJsBaseCustomberInfo(); ArrayList lists1 = new ArrayList(); foreach (SelFundCustFundinoutExcel entity in lists) { if (ds.Tables[0].Select("CUSTOMER_NM ='" + entity.Buyercode + "'").Length <= 0) { MessageBox.Show("没有查询到该" + entity.Buyercode + "客户账户!"); return; } entity.Buyercode = ds.Tables[0].Select("CUSTOMER_NM ='" + entity.Buyercode + "'")[0]["CUSTOMER_NO"].ToString2(); lists1.Add(JSONFormat.Format(entity)); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.sale.order.FrmFundInOut"; ccp.MethodName = "save"; ccp.ServerParams = new object[] { lists1 }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == -1) { MessageUtil.ShowWarning(ccp.ReturnInfo); return; } if (ccp.ReturnCode == 0) { MessageUtil.ShowTips(ccp.ReturnInfo); return; } } public List ReadExcelToSelFundCustFundinoutExcel(string fileName) { //定义要返回的datatable对象 List selFundCustFundinoutExcels = new List(); try { if (!File.Exists(fileName)) { return null; } //根据指定路径读取文件 using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { //根据文件流创建excel数据结构 NPOI.SS.UserModel.IWorkbook workbook = NPOI.SS.UserModel.WorkbookFactory.Create(fs); //IWorkbook workbook = new HSSFWorkbook(fs); for (int k = 0; k < workbook.NumberOfSheets; k++) { NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(k); if (sheet != null) { //最后一列的标号 int rowCount = sheet.LastRowNum; for (int i = 1; i <= rowCount; ++i) { NPOI.SS.UserModel.IRow row = sheet.GetRow(i); if (row == null) continue; //没有数据的行默认是null        SelFundCustFundinoutExcel selFundCustFundinoutExcel = new SelFundCustFundinoutExcel(); decimal inoutmoney, leavemoney; selFundCustFundinoutExcel.Busiseq = GetBusiSeq1(); selFundCustFundinoutExcel.Balancesubject = GetCellValue(row.Cells[0]); selFundCustFundinoutExcel.Buyercode = GetCellValue(row.Cells[1]); decimal.TryParse(GetCellValue(row.Cells[2]), out inoutmoney); selFundCustFundinoutExcel.Inoutmoney = inoutmoney; selFundCustFundinoutExcel.Inouttime = GetCellValue(row.Cells[3]); selFundCustFundinoutExcel.Fundtype = GetCellValue(row.Cells[4]); selFundCustFundinoutExcel.Billno = GetCellValue(row.Cells[5]); selFundCustFundinoutExcel.Remark = GetCellValue(row.Cells[6]); selFundCustFundinoutExcel.Importor = GetCellValue(row.Cells[7]); selFundCustFundinoutExcel.Importtime = GetCellValue(row.Cells[8]); decimal.TryParse(GetCellValue(row.Cells[9]), out leavemoney); selFundCustFundinoutExcel.Leavemoney = leavemoney; selFundCustFundinoutExcel.Affrimper = GetCellValue(row.Cells[10]); selFundCustFundinoutExcel.Affrimdate = GetCellValue(row.Cells[11]); selFundCustFundinoutExcel.Secondaccount = GetCellValue(row.Cells[12]); selFundCustFundinoutExcel.Orderno = GetCellValue(row.Cells[13]); selFundCustFundinoutExcel.MoneyDeliver = GetCellValue(row.Cells[14]); selFundCustFundinoutExcels.Add(selFundCustFundinoutExcel); } } } } return selFundCustFundinoutExcels; } catch (Exception ex) { MessageBox.Show("EXCEL格式错误:" + ex.Message); return null; } } private string GetCellValue(ICell cell) { string value = ""; switch (cell.CellType) { case CellType.Blank: value = ""; break; case CellType.Numeric: short format = cell.CellStyle.DataFormat; value = cell.NumericCellValue.ToString2(); break; case CellType.String: value = cell.StringCellValue; break; } return value; } private string GetBusiSeq() { string guid = "QWERTYUIOPLKJHGFDSAZXCVBNM"; String busi = System.DateTime.Now.ToString("yyyyMMdd-HHmmss"); int randon = new System.Random().Next(guid.Length - 2); busi = busi + guid.Substring(randon, 1).ToUpper(); return busi; } private string GetBusiSeq1() { string[] arr = Guid.NewGuid().ToString().Split('-'); string guid = "QWERTYUIOPLKJHGFDSAZXCVBNM"; String busi = System.DateTime.Now.ToString("yyyyMMdd-HHmmss"); int randon = new System.Random().Next(guid.Length - 2); busi = busi + guid.Substring(randon, 1).ToUpper(); return busi + "-" + Guid.NewGuid().ToString().Split('-')[0].ToString2(); } private void Print() { 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) { Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(" 请选择行 "); return; } if (ugr.Cells[this.ISVALID].Value.ToString() == "1") { Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(" 已经确认,不能打印 "); return; } string busiseq = ugr.Cells[BUSISEQ].Value.ToString(); string url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepInMoney.cpt&__bypagesize__=false" + "&busiseq="; url = url + busiseq; Core.StlMes.Client.SaleOrder.ReviewForm.FrmOrderRepExcel fBug = new Core.StlMes.Client.SaleOrder.ReviewForm.FrmOrderRepExcel(this.ob, url); fBug.AutoSize = true; fBug.Text = "打印进款通知单"; fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); fBug.WindowState = FormWindowState.Maximized; fBug.Show(); } private void Affrim() { 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) { Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(" 请选择需要确认的行 "); return; } if (ugr.Cells[this.ISVALID].Value.ToString() == "1") { Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(" 已经确认,不能重复确认 "); return; } string busiseq = ugr.Cells[BUSISEQ].Value.ToString(); string balnacesub = ugr.Cells[BALANCESUBJECT].Value.ToString(); string buyercode = ugr.Cells[BUYERCODE].Value.ToString(); string fundtype = ugr.Cells[FUNDTYPE].Value.ToString(); string billno = ""; double money = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(ugr.Cells[INOUTMONEY].Value); string import = base.GetUserName(); string importtime = ""; string inouttime = ""; string remark = ""; string orderno = ""; double leavemny = 0; string seccount = ugr.Cells[SECONDACCOUNT].Value.ToString(); string err = ""; _activeSecAccount = seccount; base.GetIInstanceCustInout().AffrimFundRecord(busiseq, balnacesub, buyercode, fundtype, billno, money, import, importtime, inouttime, remark, orderno, leavemny, seccount, out err); if (err.Length == 0) { this.Query(); // this.QueryInOutDetail(); Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips(base._MessageSuccess); } else { // Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(err); } } catch { } } private void Delete() { 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) { Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(" 请选择需要删除的行 "); return; } if (ugr.Cells[this.ISVALID].Value.ToString() == "1") { Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(" 已经生效,不能删除 "); return; } if (Core.StlMes.Client.Sale.Util.MessageUtil.ShowYesNoAndTips("是否确认删除选择的行") == DialogResult.No) return; string busiseq = ugr.Cells[BUSISEQ].Value.ToString(); string import = base.GetUserName(); string err = ""; string seccount = ugr.Cells[SECONDACCOUNT].Value.ToString(); _activeSecAccount = seccount; base.GetIInstanceCustInout().DeleteFundRecord(busiseq, import, out err); if (err.Length == 0) { this.Query(); // this.QueryInOutDetail(); Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips(base._MessageSuccess); } else { // Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(err); } } catch { } } private System.Collections.Hashtable GetDeptIdAndSaleArea() { System.Collections.Hashtable hs = new System.Collections.Hashtable(); try { string sql = " select * from slm_base_sale_area_typ where validflag = '1' "; DataSet ds = base.ExecuteReader(sql); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { return hs; } System.Collections.ArrayList list = null; foreach (DataRow dr in ds.Tables[0].Rows) { list = new System.Collections.ArrayList(); if (hs.ContainsKey(dr["DEPARTID"].ToString())) { list = (System.Collections.ArrayList)hs[dr["DEPARTID"].ToString()]; list.Add(dr["SALE_AREA_DESC"].ToString()); hs.Remove(dr["DEPARTID"].ToString()); hs.Add(dr["DEPARTID"].ToString(), list); } else { list.Add(dr["SALE_AREA_DESC"].ToString()); hs.Add(dr["DEPARTID"].ToString(), list); } } } catch { } return hs; } private void Query() { string err = ""; dsMain.Clear(); Boolean isOpenFilter = !this.checkBox4.Checked; if (this.textBox1.Text.Length == 0) { Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips("请选择客户单位 "); return; } string sqlConditon = this.GetSqlCondition(out err); // 获取结算单位 string balanceSubject = base.GetSaleOrgDesc(); string buyercode = sqlConditon; DataSet ds = null; System.Collections.ArrayList list = new System.Collections.ArrayList(); string deptName = ""; try { list = (System.Collections.ArrayList)_hsDept[CoreFS.SA06.CoreUserInfo.UserInfo.GetDeptid()]; } catch { } // DataSet ds = base.GetInstanceCustAccount().GetCustAccountByBalanceSubjectAndBuyercode(balanceSubject, buyercode); ds = base.GetInstanceSecondLevelAccount().GetSecondLevelAccountByBalanceAndBuyercode(balanceSubject, buyercode); try { if (ds.Tables[0].Rows.Count == 0) { Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips("无该客户账户,请先点击创建按钮创建该客户资金账户信息"); return; } } catch { } if (list != null && list.Count > 0) { object[] obj = list.ToArray(); string[] s = new string[obj.Length]; for (int i = 0; i < s.Length; i++) { s[i] = obj[i].ToString(); } if (isOpenFilter) { ds = Core.StlMes.Client.Sale.Util.UtilDataSet.GetDataSetWithRowFilter(ds, "SECONDACCOUNT", s); } } Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsMain,ds); // base.InitGrid(ref this.ultraGrid1); //if (dsMain.Tables[0].Rows.Count == 0) //{ // Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips("无该客户账户,请先点击创建按钮创建该客户资金账户信息"); // return; //} try { if (this._activeSecAccount.Length > 0) { if (this.ultraGrid1.Rows.Count > 0) { foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugs in this.ultraGrid1.Rows) { if (ugs.Cells[base._columnSecondaccount].Value.ToString() == this._activeSecAccount) { ugs.Activated = true; break; } } } } } catch { } base.SetGridTimeFormat(ref this.ultraGrid1); } private void QueryWithNoTips() { string err = ""; dsMain.Clear(); if (this.textBox1.Text.Length == 0) { return; } string sqlConditon = this.GetSqlCondition(out err); // 获取结算单位 string balanceSubject = base.GetSaleOrgDesc(); string buyercode = sqlConditon; // 获取结算单位 DataSet ds = null; // DataSet ds = base.GetInstanceCustAccount().GetCustAccountByBalanceSubjectAndBuyercode(balanceSubject, buyercode); ds = base.GetInstanceSecondLevelAccount().GetSecondLevelAccountByBalanceAndBuyercode(balanceSubject, buyercode); Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsMain, ds); //DataSet ds = base.GetInstanceCustAccount().GetCustAccountByBalanceSubjectAndBuyercode(balanceSubject, buyercode); //Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsMain, ds); // base.InitGrid(ref this.ultraGrid1); if (dsMain.Tables[0].Rows.Count == 0) { return; } base.SetGridTimeFormat(ref this.ultraGrid1); } private void QueryInOutDetail() { string buyercode = ""; UltraGridRow ugr = null; if (this.ultraGrid1.Rows.Count > 0) { ugr = this.ultraGrid1.ActiveRow; } if (this.ultraGrid1.Rows.Count == 1) ugr = this.ultraGrid1.Rows[0]; if (ugr != null) { buyercode = ugr.Cells[base._columnBuyercode].Value.ToString(); } string balanceSubject = ugr.Cells[base._columnBalanceSubject].Value.ToString(); string begintime = this.dateTimePicker2.Value.ToString(base._dateTimeFormatYyyyMmdd); string endtime = this.dateTimePicker3.Value.ToString(base._dateTimeFormatYyyyMmdd); if (!this.checkBox1.Checked) { begintime = System.DateTime.Now.AddYears(-100).ToString(base._dateTimeFormatYyyyMmdd); endtime = System.DateTime.Now.AddYears(2).ToString(base._dateTimeFormatYyyyMmdd); } DataSet ds = base.GetIInstanceCustInout().GetSelFundCustFundInOutByBalanceAndBuyercodeAndTime (balanceSubject, buyercode, begintime, endtime); ds = Core.StlMes.Client.Sale.Util.UtilDataSet.GetDataSetWithRowFilter(ds, base._columnSecondaccount, ugr.Cells [base._columnSecondaccount].Value.ToString()); Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsDetail, ds); // base.InitGrid(ref this.ultraGrid2); this.HiddenGridColumn(); base.SetGridTimeFormat(ref this.ultraGrid2); } private void HiddenGridColumn() { try { this.ultraGrid2.DisplayLayout.Bands[0].Columns[base._columnLeaveMoney].Hidden = true; } catch { } } private void TransferMoneyCustToSecond(double money) { try { 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 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; string secondLevelAccount = this.ultraGrid1.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; // 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 = ugrLeft.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; } private Model.SEL_FUND_CUST_FUNDINOUT GetSelFundCustFundInout() { Model.SEL_FUND_CUST_FUNDINOUT cust = new Model.SEL_FUND_CUST_FUNDINOUT(); string buyercode = ""; string balanceSubject = ""; string err = ""; UltraGridRow ugr = null; if (this.ultraGrid1.Rows.Count == 1) this.ultraGrid1.Rows[0].Activated = true; if (this.ultraGrid1.Rows.Count > 0) { ugr = this.ultraGrid1.ActiveRow; } if (ugr != null) { buyercode = ugr.Cells[base._columnBuyercode].Value.ToString(); balanceSubject = ugr.Cells[base._columnBalanceSubject].Value.ToString(); } if (buyercode.Length == 0) return null; double money = 0; try { money = Convert.ToDouble(this.ultraNumericEditor1.Value); } catch { } if (money == 0) return null; //if (IsMoneyLessThanZero(money)) // return null; cust.BALANCESUBJECT = balanceSubject; cust.BUYERCODE = buyercode; cust.INOUTMONEY = money; cust.IMPORTOR = base.GetUserName(); cust.INOUTTIME = this.dateTimePicker1.Value.ToString(base._dateTimeFormatYyyyMmdd) + System.DateTime.Now.ToString("HHmmss") ; cust.REMARK = this.textBox6.Text.Trim(); cust.ORDERNO = this.utOrderNo.Text.Trim(); cust.BILLNO = this.textBox4.Text; cust.FUNDTYPE = this.comboBox1.Text.Trim(); cust.LEAVEMONEY = Convert.ToDouble( ugr.Cells[base._columnLeaveMoney].Value.ToString()); return cust; } private Boolean IsMoneyLessThanZero(double money) { if (money < 0) { MessageBox.Show("资金不能为负"); return true; } return false; } private void CreateCustAccount01() { string saleOrg = base.GetSaleOrgDesc(); string buyercode = this._buyercode; if (this.textBox1.Text.Length == 0) { Core.StlMes.Client.Sale.Util.MessageUtil.ShowError("请选择客户单位"); return; } System.Collections.Hashtable hs = new System.Collections.Hashtable(); hs.Add(this.BALANCESUBJECT, saleOrg); hs.Add(this.BUYERCODE, buyercode); hs.Add(this.TOTALMONEY, 0); hs.Add(this.LEAVEMONEY, 0); hs.Add(this.IMPORTOR, base.GetUserName()); hs.Add(this.IMPORTTIME, System.DateTime.Now); string errMsg = ""; this.fundBll.CreateCustAccount(hs, out errMsg); if (errMsg.Length > 0) { } else { QueryWithNoTips(); Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips(base._MessageSuccess); return; } } private void CreateCustAccount() { string saleOrg = base.GetSaleOrgDesc(); string buyercode = this._buyercode; if (this.textBox1.Text.Length == 0) { Core.StlMes.Client.Sale.Util.MessageUtil.ShowError("请选择客户单位"); return; } Model.SEL_FUND_CUST_ACCOUNT account = new Core.StlMes.Client.Sale.SaleFundMgt.Model.SEL_FUND_CUST_ACCOUNT(); string errMsg = ""; foreach (string s in new string[] {"国内贸易部","国际贸易部" }) { account = new Core.StlMes.Client.Sale.SaleFundMgt.Model.SEL_FUND_CUST_ACCOUNT(); account.BALANCESUBJECT = s; account.BUYERCODE = buyercode; account.TOTALMONEY = 0; account.LEAVEMONEY = 0; account.IMPORTOR = "System"; account.IMPORTTIME = Core.StlMes.Client.Sale.Util.ConverObject.ConvertDataTimeToString(System.DateTime.Now); base.GetInstanceCustAccount().CreateCustAccount(account, "System", out errMsg); } if (errMsg.Length > 0) { } else { QueryWithNoTips(); Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips(base._MessageSuccess); this.Query(); return; } } private System.Collections.Hashtable GetInOutParam() { System.Collections.Hashtable hs = new System.Collections.Hashtable(); string buyercode = ""; string balanceSubject = ""; string err = ""; UltraGridRow ugr = null; if (this.ultraGrid1.Rows.Count == 1) this.ultraGrid1.Rows[0].Activated = true; if (this.ultraGrid1.Rows.Count > 0) { ugr = this.ultraGrid1.ActiveRow; } if (ugr != null) { buyercode = ugr.Cells[base._columnBuyercode].Value.ToString(); balanceSubject = ugr.Cells[base._columnBalanceSubject].Value.ToString(); } if (buyercode.Length == 0) return hs; double money = 0; try { money = Convert.ToDouble(this.ultraNumericEditor1.Value); } catch { } if (money == 0) return hs; if (IsMoneyLessThanZero(money)) return hs; hs.Add(this.BALANCESUBJECT, balanceSubject); hs.Add(this.BUYERCODE, buyercode); hs.Add(this.INOUTMONEY, money); hs.Add(this.IMPORTOR, base.GetUserName()); hs.Add(this.INOUTTIME, this.dateTimePicker1.Value); hs.Add(this.REMARK, this.textBox6.Text.Trim()); hs.Add(this.ORDERNO, this.utOrderNo.Text.Trim()); hs.Add(this.BILLNO, this.textBox4.Text.Trim()); hs.Add(this.FUNDTYPE, this.comboBox1.Text.Trim()); hs.Add(this.LEAVEMONEY, Convert.ToDouble(ugr.Cells[base._columnLeaveMoney].Value.ToString())); return hs; } private string _activeSecAccount = ""; /// /// 写记录 /// private void InMoney() { string err = ""; Model.SEL_FUND_CUST_FUNDINOUT inout = this.GetSelFundCustFundInout(); if (inout == null) return; Infragistics.Win.UltraWinGrid.UltraGridRow ugr = this.ultraGrid1.ActiveRow; if (ugr == null) return; _activeSecAccount = ugr.Cells[base._columnSecondaccount].Value.ToString(); String moneyDel = (this.checkBox2.Checked) ? "1" : "2"; if (this.checkBox2.Checked && this.checkBox3.Checked) { Core.StlMes.Client.Sale.Util.MessageUtil.ShowError("去向只能选择一个"); return; } if (this.checkBox2.Checked) moneyDel = "1"; else if (this.checkBox3.Checked) moneyDel = "2"; else moneyDel = "0"; if (base.GetSaleOrgDesc() == "国内贸易部") { if (moneyDel == "0") { Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips("请选择回款去向"); return; } } string busiseq = this.GetBusiSeq(); base.GetIInstanceCustInout().AddFundRecord(this.GetBusiSeq(), inout.BALANCESUBJECT, inout.BUYERCODE, inout.FUNDTYPE, inout.BILLNO, inout.INOUTMONEY, inout.IMPORTOR, Util.DateTimeUtil.GetSystemDate(), inout.INOUTTIME, inout.REMARK,inout.ORDERNO,inout.LEAVEMONEY,ugr.Cells[base._columnSecondaccount].Value.ToString(),moneyDel,"", out err); /* 进款: 钢贸 每输入的一笔款项,同步也可以看成是钢贸公司给制造公司的款项 可以理解为钢贸最终客户的每笔款项,先入钢贸帐户,再入制造帐户 这里,制造的帐户由销售管理,客户为天津钢管钢铁贸易有限公司,编码为1010101184 */ if (base.GetSaleOrgDesc() == "钢贸公司") { if (this.checkBox2.Checked) { string remk = "原序号: " + busiseq + " 原单位:" + ugr.Cells[base._columnBuyercode].Text + ",制造进款"; base.GetIInstanceCustInout().AddFundRecord(busiseq + "-1", "销售公司", inout.BUYERCODE, inout.FUNDTYPE, inout.BILLNO, inout.INOUTMONEY, inout.IMPORTOR, Util.DateTimeUtil.GetSystemDate(), inout.INOUTTIME, remk, inout.ORDERNO, 0, ugr.Cells[base._columnSecondaccount].Value.ToString(), moneyDel, inout.BUYERCODE, out err); } else if (this.checkBox3.Checked) { string remk = "原序号: " + busiseq + " 原单位:" + ugr.Cells[base._columnBuyercode].Text + ",集团进款"; base.GetIInstanceCustInout().AddFundRecord(busiseq + "-1", "销售公司", inout.BUYERCODE, inout.FUNDTYPE, inout.BILLNO, inout.INOUTMONEY, inout.IMPORTOR, Util.DateTimeUtil.GetSystemDate(), inout.INOUTTIME, remk, inout.ORDERNO, 0, ugr.Cells[base._columnSecondaccount].Value.ToString(), moneyDel, inout.BUYERCODE, out err); } else { string remk = ""; base.GetIInstanceCustInout().AddFundRecord(busiseq + "-1", "销售公司", inout.BUYERCODE, inout.FUNDTYPE, inout.BILLNO, inout.INOUTMONEY, inout.IMPORTOR, Util.DateTimeUtil.GetSystemDate(), inout.INOUTTIME, remk, inout.ORDERNO, 0, ugr.Cells[base._columnSecondaccount].Value.ToString(), "0", inout.BUYERCODE, out err); } } if (err.Length == 0) { // this.QueryInOutDetail(); Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips(base._MessageSuccess); this.Query(); } else { // Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(err); } } private void InMoney02() { string err = ""; System.Collections.Hashtable hs = new System.Collections.Hashtable(); hs = GetInOutParam(); if (hs == null || hs.Count == 0) return; this.fundBll.AddFundRecord(hs, out err); if (err.Length == 0) { this.Query(); this.QueryInOutDetail(); Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips(base._MessageSuccess); } else { // Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(err); } } private void OutMoney() { return; //出账,资金为负 // 检查当前账户的剩余资金是否足够 try { string err = ""; Model.SEL_FUND_CUST_FUNDINOUT inout = this.GetSelFundCustFundInout(); if (inout == null) return; Infragistics.Win.UltraWinGrid.UltraGridRow ugr = this.ultraGrid1.ActiveRow; if (ugr == null) return; _activeSecAccount = ugr.Cells[base._columnSecondaccount].Value.ToString(); //Model.SEL_FUND_CUST_ACCOUNT cust = base.GetInstanceCustAccount() //.GetSelFundCustAccountByBalanceSubjectAndBuyercode(inout.BALANCESUBJECT, inout.BUYERCODE); double moneys = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble (ugr.Cells[base._columnLeaveMoney].Value.ToString()); if (moneys < inout.INOUTMONEY) { Core.StlMes.Client.Sale.Util.MessageUtil.ShowError("剩余资金不足,无法出账"); return; } inout.INOUTMONEY = -inout.INOUTMONEY; //System.Collections.Hashtable hs = new System.Collections.Hashtable(); //hs = GetInOutParam(); //if (hs == null || hs.Count == 0) // return; //hs[this.INOUTMONEY] = -Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(hs[this.INOUTMONEY]); //this.fundBll.AddFundRecord(hs, out err); base.GetIInstanceCustInout().AddFundRecord(inout.BALANCESUBJECT, inout.BUYERCODE, inout.FUNDTYPE, inout.BILLNO, inout.INOUTMONEY, inout.IMPORTOR, Util.DateTimeUtil.GetSystemDate(), inout.INOUTTIME, inout.REMARK, inout.ORDERNO, inout.LEAVEMONEY, ugr.Cells[base._columnSecondaccount].Value.ToString(), out err); if (err.Length == 0) { this.Query(); // this.QueryInOutDetail(); Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips(base._MessageSuccess); } else { // Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(err); } } catch { } } private string GetSqlCondition(out string errMsg) { errMsg = ""; if (_buyercode.Length == 0) { errMsg = _buyercodeNotChooseInfo; return ""; } return this._buyercode; } 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; this.Query(); } } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { this.QueryInOutDetail(); } private string BALANCESUBJECT = "BALANCESUBJECT"; private string BILLNO = "BILLNO"; private string BUSISEQ = "BUSISEQ"; private string BUYERCODE = "BUYERCODE"; private string FUNDTYPE = "FUNDTYPE"; private string IMPORTOR = "IMPORTOR"; private string IMPORTTIME = "IMPORTTIME"; private string INOUTMONEY = "INOUTMONEY"; private string INOUTTIME = "INOUTTIME"; private string ISVALID = "ISVALID"; private string LEAVEMONEY = "LEAVEMONEY"; private string REMARK = "REMARK"; private string ORDERNO = "ORDERNO"; private string TOTALMONEY = "TOTALMONEY"; private string UPDATETIME = "UPDATETIME"; private string SECONDACCOUNT = "SECONDACCOUNT"; private void checkBox2_CheckedChanged(object sender, EventArgs e) { // this.checkBox3.Checked = !this.checkBox2.Checked; } private void checkBox3_CheckedChanged(object sender, EventArgs e) { // this.checkBox2.Checked = !this.checkBox3.Checked; } private void ultraNumericEditor2_MouseLeave(object sender, EventArgs e) { } private void ultraNumericEditor1_MouseLeave(object sender, EventArgs e) { } private void ultraNumericEditor1_KeyPress(object sender, KeyPressEventArgs e) { } private void ultraNumericEditor1_KeyDown(object sender, KeyEventArgs e) { } } }