| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246 |
- 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<SelFundCustFundinoutExcel>(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<SelFundCustFundinoutExcel>()
- {
- 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<SelFundCustFundinoutExcel> 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<SelFundCustFundinoutExcel> ReadExcelToSelFundCustFundinoutExcel(string fileName)
- {
- //定义要返回的datatable对象
- List<SelFundCustFundinoutExcel> selFundCustFundinoutExcels = new List<SelFundCustFundinoutExcel>();
- 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 = "";
- /// <summary>
- /// 写记录
- /// </summary>
- 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)
- {
-
- }
-
-
- }
- }
|