using System; using System.Collections.Generic; using System.Data; using System.Data.Common; using System.Text; using DSWeb.MvcShipping.Models.MsChFee; using DSWeb.MvcShipping.Models.MsOpAmend; using HcUtility.Comm; using HcUtility.Core; using System.Data.SqlClient; using WebSqlHelper; using Microsoft.Practices.EnterpriseLibrary.Data; using DSWeb.EntityDA; using DSWeb.Areas.Account.Models.MsOpBill; using DSWeb.Areas.CommMng.Models; using DSWeb.Areas.CommMng.DAL; using DSWeb.MvcShipping.DAL.MsChFeeDAL; using DSWeb.MvcShipping.DAL.MsSysParamSet; using DSWeb.MvcShipping.DAL.MsInfoClient; using DSWeb.Areas.Account.Models.ChMonthClose; namespace DSWeb.MvcShipping.DAL.ChMonthCloseDAL { public class ChMonthCloseDAL { #region 查询费用数据 static public Period GetData(string condition,string companyid) { var strSql = new StringBuilder(); strSql.Append("SELECT TOP 1 PERIOD,PYEAR,PMONTH,FDAY,TDAY,CLOSED,CLOSEUSER,CLOSEDATE,COMPANYID "); strSql.Append(",(select ShowName from [user] where GID=PERIOD.CLOSEUSER) as CLOSEUSERREF"); strSql.Append(" from PERIOD where companyid='" + companyid + "'"); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" AND " + condition); } strSql.Append(" ORDER BY PERIOD DESC "); var list = SetData(strSql); if (list.Count > 0) return GetNewData(list[0].PYEAR,list[0].PMONTH,list[0].FDAY,list[0].TDAY,companyid,list[0].PERIOD); Period data = new Period(); return data; } private static List SetData(StringBuilder strSql) { var bodyList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { Period data = new Period(); #region Set DB data to Object data.PERIOD = Convert.ToString(reader["PERIOD"]); data.PYEAR = Convert.ToInt16(reader["PYEAR"]); data.PMONTH = Convert.ToInt16(reader["PMONTH"]); data.FDAY = Convert.ToString(reader["FDAY"]); data.TDAY = Convert.ToDateTime(reader["TDAY"]).ToString("yyyy-MM-dd"); data.CLOSED = Convert.ToString(reader["CLOSED"]); data.CLOSEUSER = Convert.ToString(reader["CLOSEUSER"]); data.CLOSEUSERREF = Convert.ToString(reader["CLOSEUSERREF"]); data.CLOSEDATE = Convert.ToString(reader["CLOSEDATE"]); data.COMPANYID = Convert.ToString(reader["COMPANYID"]); #endregion bodyList.Add(data); } reader.Close(); } return bodyList; } static public Period GetNewData(int pyear, int pmonth, string fday, string tday, string companyid, string closeperiod) { int tmonth = 0; int tyear = 0; var closetype="会计期间"; if (pmonth == 12) { tmonth = 1; tyear = pyear + 1; } else { tyear = pyear; tmonth = pmonth + 1; } var amonth = tmonth.ToString(); if (amonth.Length == 1) amonth ="0"+amonth; var periodday = DateTime.Now; Period data = new Period(); var MONTHCLOSEDATE = MsSysParamSetDAL.GetData("PARAMNAME='MONTHCLOSEDATE'"); if (MONTHCLOSEDATE.PARAMVALUE != "0" && MONTHCLOSEDATE.PARAMVALUE != "") { periodday = Convert.ToDateTime(tyear.ToString() + "-" + amonth +"-"+ MONTHCLOSEDATE.PARAMVALUE); data.CLOSEDAY = Convert.ToInt16(MONTHCLOSEDATE.PARAMVALUE); } else { periodday = Convert.ToDateTime(tyear.ToString() + "-" + amonth + "-01").AddMonths(1).AddDays(-1); } var MONTHCLOSEDATETYPE = MsSysParamSetDAL.GetData("PARAMNAME='MONTHCLOSEDATETYPE'"); if (MONTHCLOSEDATETYPE.PARAMVALUE == "1") closetype = "业务日期"; data.PERIOD = tyear.ToString()+"-"+ amonth; data.PYEAR = tyear; data.PMONTH = tmonth; data.FDAY = Convert.ToDateTime(tday).AddDays(1).ToString("yyyy-MM-dd"); data.TDAY = periodday.ToString("yyyy-MM-dd"); data.COMPANYID = companyid; data.CLOSEDATETYPE = closetype; data.CLOSEPERIOD = closeperiod; return data; } #endregion public static DBResult MonthClose(Period period, string closetype, string companyid, string userid) { var result = new DBResult(); var aoffyear = period.PYEAR; var aoffmonth = period.PMONTH; var upyear = 0; var upmonth = 0; var sSQL = ""; if (aoffmonth == 1) { upyear = aoffyear - 1; upmonth = 12; } else { upyear = aoffyear; upmonth = aoffmonth-1; } T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); var modb = new ModelObjectDB(); if (closetype == "-1") { var strupmonth = upmonth.ToString(); if (strupmonth.Length == 1) strupmonth = "0" + strupmonth; Period upperiod = new Period(); upperiod.PERIOD = upyear.ToString()+"-"+strupmonth; upperiod.PYEAR = upyear; upperiod.PMONTH = upmonth; string blDelSQL = "delete from ch_custbalance where year=" + upyear.ToString() + " and month=" + strupmonth.ToString()+" and CORPID='"+companyid+"'"; bool bl = T_ALL_DA.GetExecuteSqlCommand(blDelSQL); result = modb.Delete(upperiod); return result; } string blDelSQL2 = "delete from ch_custbalance where year=" + aoffyear.ToString() + " and month=" + aoffmonth.ToString() + " and CORPID='" + companyid + "'"; bool bl2 = T_ALL_DA.GetExecuteSqlCommand(blDelSQL2); string blSQL = "INSERT INTO ch_custbalance ([YEAR],[MONTH],[CUSTOMERNAME],[SALE],[BSSOURCE],[BSSOURCEDETAIL],[OPLBNAME],[CORPID],[SALEDEPT],[CURRENCY],"; blSQL +=" [UPMONTHDRBAL],[MONTHDR],[MONTHDRSTL],[MONTHDRBAL],"; blSQL +="[UPMONTHTTLDRBAL],[MONTHTTLDR],[MONTHTTLDRSTL],[MONTHTTLDRBAL],[UPMONTHCRBAL],[MONTHCR],[MONTHCRSTL],[MONTHCRBAL],"; blSQL +="[UPMONTHTTLCRBAL],[MONTHTTLCR],[MONTHTTLCRSTL],[MONTHTTLCRBAL])"; blSQL += " SELECT '" + aoffyear.ToString() + "','" + aoffmonth.ToString() + "',CUSTOMERNAME,SALE,BSSOURCE,BSSOURCEDETAIL,OPLBNAME,CORPID,SALEDEPT,CURRENCY,"; blSQL +=" MONTHDRBAL,0,0,MONTHDRBAL,"; blSQL +="MONTHTTLDRBAL,0,0,MONTHTTLDRBAL,MONTHCRBAL,0,0,MONTHCRBAL,"; blSQL += "MONTHTTLCRBAL,0,0,MONTHTTLCRBAL from ch_custbalance"; blSQL += " WHERE YEAR=" + upyear.ToString() + " AND MONTH=" + upmonth.ToString() + " and CORPID='" + companyid + "'"; bool blInsert = T_ALL_DA.GetExecuteSqlCommand(blSQL); #region 更新应收账款 sSQL = "SELECT c.CUSTOMERNAME,c.FEETYPE,c.CURRENCY,c.EXCHANGERATE,b.BSSOURCE,b.BSSOURCEDETAIL,b.SALE,b.OPLBNAME,b.SALEDEPT,sum(isnull(c.AMOUNT,0)) AMOUNT,sum(isnull(c.AMOUNT*c.EXCHANGERATE,0)) TTLAMOUNT"; sSQL += " FROM ch_fee c,v_op_bill b WHERE b.BSNO=c.BSNO AND c.AMOUNT<>0 "; sSQL += " AND b.ACCDATE='"+period.PERIOD+"' AND b.FEESTATUS=1 and b.CORPID='"+companyid+"'"; sSQL += " GROUP BY c.CUSTOMERNAME,c.FEETYPE,c.CURRENCY,c.EXCHANGERATE,b.BSSOURCE,b.BSSOURCEDETAIL,b.SALE,b.OPLBNAME,b.SALEDEPT"; sSQL += " ORDER BY c.CUSTOMERNAME,c.FEETYPE,c.CURRENCY,c.EXCHANGERATE,b.BSSOURCE,b.BSSOURCEDETAIL,b.SALE,b.OPLBNAME,b.SALEDEPT"; DataSet dsAP = T_ALL_DA.GetAllSQL(sSQL); string sNum = ""; if (dsAP != null) { for (int i = 0; i < dsAP.Tables[0].Rows.Count; i++) { sSQL = "SELECT COUNT(*) as inum from ch_custbalance where YEAR="+aoffyear.ToString()+" AND MONTH="+aoffmonth.ToString()+" AND CORPID='" + companyid + "' and CUSTOMERNAME='" + dsAP.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "'"; sSQL += " and BSSOURCE='" + dsAP.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim() + "' and BSSOURCEDETAIL='" + dsAP.Tables[0].Rows[i]["BSSOURCEDETAIL"].ToString().Trim() + "'"; sSQL += " and SALE='" + dsAP.Tables[0].Rows[i]["SALE"].ToString().Trim() + "' and OPLBNAME='" + dsAP.Tables[0].Rows[i]["OPLBNAME"].ToString().Trim() + "'"; sSQL += " and SALEDEPT='" + dsAP.Tables[0].Rows[i]["SALEDEPT"].ToString().Trim() + "' and CURRENCY='" + dsAP.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() + "' "; sNum = T_ALL_DA.GetStrSQL("inum", sSQL); if (sNum == "" || sNum == "0") { blSQL = "INSERT INTO ch_custbalance ([YEAR],[MONTH],[CUSTOMERNAME],[SALE],[BSSOURCE],[BSSOURCEDETAIL],[OPLBNAME],[CORPID],[SALEDEPT],CURRENCY,"; blSQL += " [UPMONTHDRBAL],[MONTHDR],[MONTHDRSTL],[MONTHDRBAL],"; blSQL += "[UPMONTHTTLDRBAL],[MONTHTTLDR],[MONTHTTLDRSTL],[MONTHTTLDRBAL],[UPMONTHCRBAL],[MONTHCR],[MONTHCRSTL],[MONTHCRBAL],"; blSQL += "[UPMONTHTTLCRBAL],[MONTHTTLCR],[MONTHTTLCRSTL],[MONTHTTLCRBAL])"; blSQL += " VALUES('" + aoffyear.ToString() + "','" + aoffmonth.ToString() + "','" + dsAP.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "',"; blSQL += "'" + dsAP.Tables[0].Rows[i]["SALE"].ToString().Trim() + "','" + dsAP.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim() + "','" + dsAP.Tables[0].Rows[i]["BSSOURCEDETAIL"].ToString().Trim() + "',"; blSQL += "'" + dsAP.Tables[0].Rows[i]["OPLBNAME"].ToString().Trim() + "','" + companyid + "','" + dsAP.Tables[0].Rows[i]["SALEDEPT"].ToString().Trim() + "','" + dsAP.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() + "',"; if (dsAP.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "1") { blSQL += "0,"+dsAP.Tables[0].Rows[i]["AMOUNT"].ToString().Trim() + ",0," + dsAP.Tables[0].Rows[i]["AMOUNT"].ToString().Trim() + ","; blSQL += "0,"+dsAP.Tables[0].Rows[i]["TTLAMOUNT"].ToString().Trim() + ",0," + dsAP.Tables[0].Rows[i]["TTLAMOUNT"].ToString().Trim() + ",0,0,0,0,"; blSQL += "0,0,0,0)"; } else { blSQL += "0,0,0,0,"; blSQL += "0,0,0,0,0,"+dsAP.Tables[0].Rows[i]["AMOUNT"].ToString().Trim() + ",0," + dsAP.Tables[0].Rows[i]["AMOUNT"].ToString().Trim() + ","; blSQL += "0," + dsAP.Tables[0].Rows[i]["TTLAMOUNT"].ToString().Trim() + ",0," + dsAP.Tables[0].Rows[i]["TTLAMOUNT"].ToString().Trim() + ")"; } blInsert = T_ALL_DA.GetExecuteSqlCommand(blSQL); } else { blSQL = "UPDATE ch_custbalance SET "; if (dsAP.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "1") { blSQL += "MONTHDR=MONTHDR+" + dsAP.Tables[0].Rows[i]["AMOUNT"].ToString().Trim() + ",MONTHDRBAL=MONTHDRBAL+" + dsAP.Tables[0].Rows[i]["AMOUNT"].ToString().Trim() + ""; blSQL += ",MONTHTTLDR=MONTHTTLDR+" + dsAP.Tables[0].Rows[i]["TTLAMOUNT"].ToString().Trim() + ",MONTHTTLDRBAL=MONTHTTLDRBAL+" + dsAP.Tables[0].Rows[i]["TTLAMOUNT"].ToString().Trim() + ""; } else { blSQL += "MONTHCR=MONTHCR+" + dsAP.Tables[0].Rows[i]["AMOUNT"].ToString().Trim() + ",MONTHCRBAL=MONTHCRBAL+" + dsAP.Tables[0].Rows[i]["AMOUNT"].ToString().Trim() + ""; blSQL += ",MONTHTTLCR=MONTHTTLCR+" + dsAP.Tables[0].Rows[i]["TTLAMOUNT"].ToString().Trim() + ",MONTHTTLCRBAL=MONTHTTLCRBAL+" + dsAP.Tables[0].Rows[i]["TTLAMOUNT"].ToString().Trim() + ""; } blSQL += " where YEAR="+aoffyear.ToString()+" AND MONTH="+aoffmonth.ToString()+" AND CORPID='" + companyid + "' and CUSTOMERNAME='" + dsAP.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "'"; blSQL += " and BSSOURCE='" + dsAP.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim() + "' and BSSOURCEDETAIL='" + dsAP.Tables[0].Rows[i]["BSSOURCEDETAIL"].ToString().Trim() + "'"; blSQL += " and SALE='" + dsAP.Tables[0].Rows[i]["SALE"].ToString().Trim() + "' and OPLBNAME='" + dsAP.Tables[0].Rows[i]["OPLBNAME"].ToString().Trim() + "'"; blSQL += " and SALEDEPT='" + dsAP.Tables[0].Rows[i]["SALEDEPT"].ToString().Trim() + "' and CURRENCY='" + dsAP.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() + "' "; blInsert = T_ALL_DA.GetExecuteSqlCommand(blSQL); } } } #endregion #region 更新实收实付 sSQL = "SELECT CUSTOMERNAME,FEETYPE,ORIGCURRENCY CURRENCY,ORIGEXCHANGERATE EXCHANGERATE,BSSOURCE,BSSOURCEDETAIL,SALE,OPLBNAME,SALEDEPT,sum(isnull(ORIGAMOUNT,0)) AMOUNT,sum(isnull(ORIGAMOUNT*ORIGEXCHANGERATE,0)) TTLAMOUNT"; sSQL += " FROM v_fee_do_settlement_bs WHERE ORIGAMOUNT<>0 "; sSQL += " AND SETTLETIME>='" + period.FDAY + "' AND SETTLETIME<='" + period.TDAY + " 23:59:59' and CORPID='" + companyid + "'"; sSQL += " GROUP BY CUSTOMERNAME,FEETYPE,ORIGCURRENCY,ORIGEXCHANGERATE,BSSOURCE,BSSOURCEDETAIL,SALE,OPLBNAME,SALEDEPT"; sSQL += " ORDER BY CUSTOMERNAME,FEETYPE,ORIGCURRENCY,ORIGEXCHANGERATE,BSSOURCE,BSSOURCEDETAIL,SALE,OPLBNAME,SALEDEPT"; dsAP = T_ALL_DA.GetAllSQL(sSQL); if (dsAP != null) { for (int i = 0; i < dsAP.Tables[0].Rows.Count; i++) { sSQL = "SELECT COUNT(*) as inum from ch_custbalance where YEAR=" + aoffyear.ToString() + " AND MONTH=" + aoffmonth.ToString() + " AND CORPID='" + companyid + "' and CUSTOMERNAME='" + dsAP.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "'"; sSQL += " and BSSOURCE='" + dsAP.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim() + "' and BSSOURCEDETAIL='" + dsAP.Tables[0].Rows[i]["BSSOURCEDETAIL"].ToString().Trim() + "'"; sSQL += " and SALE='" + dsAP.Tables[0].Rows[i]["SALE"].ToString().Trim() + "' and OPLBNAME='" + dsAP.Tables[0].Rows[i]["OPLBNAME"].ToString().Trim() + "'"; sSQL += " and SALEDEPT='" + dsAP.Tables[0].Rows[i]["SALEDEPT"].ToString().Trim() + "' and CURRENCY='" + dsAP.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() + "'"; sNum = T_ALL_DA.GetStrSQL("inum", sSQL); if (sNum == "" || sNum == "0") { blSQL = "INSERT INTO ch_custbalance ([YEAR],[MONTH],[CUSTOMERNAME],[SALE],[BSSOURCE],[BSSOURCEDETAIL],[OPLBNAME],[CORPID],CURRENCY,[SALEDEPT],"; blSQL += " [UPMONTHDRBAL],[MONTHDR],[MONTHDRSTL],[MONTHDRBAL],"; blSQL += "[UPMONTHTTLDRBAL],[MONTHTTLDR],[MONTHTTLDRSTL],[MONTHTTLDRBAL],[UPMONTHCRBAL],[MONTHCR],[MONTHCRSTL],[MONTHCRBAL],"; blSQL += "[UPMONTHTTLCRBAL],[MONTHTTLCR],[MONTHTTLCRSTL],[MONTHTTLCRBAL])"; blSQL += " VALUES('" + aoffyear.ToString() + "','" + aoffmonth.ToString() + "','" + dsAP.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "',"; blSQL += "'" + dsAP.Tables[0].Rows[i]["SALE"].ToString().Trim() + "','" + dsAP.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim() + "','" + dsAP.Tables[0].Rows[i]["BSSOURCEDETAIL"].ToString().Trim() + "',"; blSQL += "'" + dsAP.Tables[0].Rows[i]["OPLBNAME"].ToString().Trim() + "','" + dsAP.Tables[0].Rows[i]["OPLBNAME"].ToString().Trim() + "','" + dsAP.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() + "','" + dsAP.Tables[0].Rows[i]["SALEDEPT"].ToString().Trim() + "',"; if (dsAP.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "1") { blSQL += "0,0," + dsAP.Tables[0].Rows[i]["AMOUNT"].ToString().Trim() + ",-" + dsAP.Tables[0].Rows[i]["AMOUNT"].ToString().Trim() + ","; blSQL += "0,0," + dsAP.Tables[0].Rows[i]["TTLAMOUNT"].ToString().Trim() + ",-" + dsAP.Tables[0].Rows[i]["TTLAMOUNT"].ToString().Trim() + ",0,0,0,0,"; blSQL += "0,0,0,0)"; } else { blSQL += "0,0,0,0,"; blSQL += "0,0,0,0,0,0," + dsAP.Tables[0].Rows[i]["AMOUNT"].ToString().Trim() + ",-" + dsAP.Tables[0].Rows[i]["AMOUNT"].ToString().Trim() + ","; blSQL += "0,0," + dsAP.Tables[0].Rows[i]["TTLAMOUNT"].ToString().Trim() + ",-" + dsAP.Tables[0].Rows[i]["TTLAMOUNT"].ToString().Trim() + ")"; } blInsert = T_ALL_DA.GetExecuteSqlCommand(blSQL); } else { blSQL = "UPDATE ch_custbalance SET "; if (dsAP.Tables[0].Rows[i]["FEETYPE"].ToString().Trim() == "1") { if (Convert.ToDecimal(dsAP.Tables[0].Rows[i]["AMOUNT"].ToString()) > 0) { blSQL += "MONTHDRSTL=MONTHDRSTL+" + dsAP.Tables[0].Rows[i]["AMOUNT"].ToString().Trim() + ",MONTHDRBAL=MONTHDRBAL-" + dsAP.Tables[0].Rows[i]["AMOUNT"].ToString().Trim() + ""; blSQL += ",MONTHTTLDRSTL=MONTHTTLDRSTL+" + dsAP.Tables[0].Rows[i]["TTLAMOUNT"].ToString().Trim() + ",MONTHTTLDRBAL=MONTHTTLDRBAL-" + dsAP.Tables[0].Rows[i]["TTLAMOUNT"].ToString().Trim() + ""; } else { var amount = System.Math.Abs(Convert.ToDecimal(dsAP.Tables[0].Rows[i]["AMOUNT"].ToString())); var ttlamount = System.Math.Abs(Convert.ToDecimal(dsAP.Tables[0].Rows[i]["TTLAMOUNT"].ToString())); blSQL += "MONTHDRSTL=MONTHDRSTL-" + amount.ToString().Trim() + ",MONTHDRBAL=MONTHDRBAL+" + amount.ToString().Trim() + ""; blSQL += ",MONTHTTLDRSTL=MONTHTTLDRSTL-" + ttlamount.ToString().Trim() + ",MONTHTTLDRBAL=MONTHTTLDRBAL+" + ttlamount.ToString().Trim() + ""; } } else { if (Convert.ToDecimal(dsAP.Tables[0].Rows[i]["AMOUNT"].ToString()) > 0) { blSQL += "MONTHCRSTL=MONTHCRSTL+" + dsAP.Tables[0].Rows[i]["AMOUNT"].ToString().Trim() + ",MONTHCRBAL=MONTHCRBAL-" + dsAP.Tables[0].Rows[i]["AMOUNT"].ToString().Trim() + ""; blSQL += ",MONTHTTLCRSTL=MONTHTTLCRSTL+" + dsAP.Tables[0].Rows[i]["TTLAMOUNT"].ToString().Trim() + ",MONTHTTLCRBAL=MONTHTTLCRBAL-" + dsAP.Tables[0].Rows[i]["TTLAMOUNT"].ToString().Trim() + ""; } else { var amount = System.Math.Abs(Convert.ToDecimal(dsAP.Tables[0].Rows[i]["AMOUNT"].ToString())); var ttlamount = System.Math.Abs(Convert.ToDecimal(dsAP.Tables[0].Rows[i]["TTLAMOUNT"].ToString())); blSQL += "MONTHCRSTL=MONTHCRSTL-" + amount.ToString().Trim() + ",MONTHCRBAL=MONTHCRBAL+" + amount.ToString().Trim() + ""; blSQL += ",MONTHTTLCRSTL=MONTHTTLCRSTL-" + ttlamount.ToString().Trim() + ",MONTHTTLCRBAL=MONTHTTLCRBAL+" + ttlamount.ToString().Trim() + ""; } } } blSQL += " where YEAR=" + aoffyear.ToString() + " AND MONTH=" + aoffmonth.ToString() + " AND CORPID='" + companyid + "' and CUSTOMERNAME='" + dsAP.Tables[0].Rows[i]["CUSTOMERNAME"].ToString().Trim() + "'"; blSQL += " and BSSOURCE='" + dsAP.Tables[0].Rows[i]["BSSOURCE"].ToString().Trim() + "' and BSSOURCEDETAIL='" + dsAP.Tables[0].Rows[i]["BSSOURCEDETAIL"].ToString().Trim() + "'"; blSQL += " and SALE='" + dsAP.Tables[0].Rows[i]["SALE"].ToString().Trim() + "' and OPLBNAME='" + dsAP.Tables[0].Rows[i]["OPLBNAME"].ToString().Trim() + "'"; blSQL += " and SALEDEPT='" + dsAP.Tables[0].Rows[i]["SALEDEPT"].ToString().Trim() + "' and CURRENCY='" + dsAP.Tables[0].Rows[i]["CURRENCY"].ToString().Trim() + "'"; blInsert = T_ALL_DA.GetExecuteSqlCommand(blSQL); } } #endregion period.CLOSEDATE = DateTime.Now.ToString("yyyy-MM-dd"); period.CLOSEUSER = userid; period.DbOperationType = DbOperationType.DbotIns; period.CLOSED ="T"; period.COMPANYID = companyid; result = modb.Save(period); result.Success = true; result.Message = "保存成功"; return result; } } }