|
|
using System;
|
|
|
using System.Data;
|
|
|
using System.Data.Common;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Text;
|
|
|
using System.IO;
|
|
|
using System.Data.SqlClient;
|
|
|
using HcUtility.Core;
|
|
|
using HcUtility.Comm;
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
using DSWeb.MvcShipping.Models.MsOpBillProfit;
|
|
|
using DSWeb.MvcShipping.Models.InfoSaleProfitSharePlan;
|
|
|
using DSWeb.MvcShipping.Models.MsRptSaleLiRunTiCheng;
|
|
|
using DSWeb.EntityDA;
|
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
using DSWeb.DataAccess;
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
using DSWeb.MvcShipping.DAL.MsInfoSaleProfitShareSet;
|
|
|
|
|
|
namespace DSWeb.MvcShipping.DAL.MsRptSaleLiRunTiChengDAL
|
|
|
{
|
|
|
public class MsRptSaleLiRunTiChengDAL
|
|
|
{
|
|
|
#region 报表页面查询
|
|
|
static public List<MsOpBillProfit> GetDataList(string strCondition, string ShuiLv, string YeWuFeiYong, string GeRenFeiYong, string accDate, string userid, string usercode, string companyid, string sort = null)
|
|
|
{
|
|
|
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strCondition = strCondition + " and " + rangstr;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strCondition = rangstr;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#region 列
|
|
|
//BSNO//编号
|
|
|
//ISSALEFEE//提成发放
|
|
|
//SALE//业务员
|
|
|
//CUSTOMERNAME//委托单位
|
|
|
//OPLBNAME//业务类型
|
|
|
//OPTYPE//更改单
|
|
|
//FEESTATUSREF//费用锁定
|
|
|
//CUSTNO//委托编号
|
|
|
//MBLNO//主提单号
|
|
|
//ETD//开船日期
|
|
|
//ACCDATE//会计期间
|
|
|
//RMBDR//RMB应收
|
|
|
//RMBCR//RMB应付
|
|
|
//USDDR//USD应收
|
|
|
//USDCR//USD应付
|
|
|
//OTDR//其他币别应收
|
|
|
//OTCR//其他币别应付
|
|
|
//TTLDR//合计应收
|
|
|
//TTLCR//合计应付
|
|
|
//TTLPROFIT//合计毛利润
|
|
|
//ShuiFei//税费
|
|
|
//YeWuFeiYong//业务费用
|
|
|
//JingLiRun//净利润
|
|
|
//TiChengJiShu////提成基数
|
|
|
//GeRenFeiYong//个人费用
|
|
|
//TiChengBiLi////提成比例
|
|
|
//TiCheng//提成
|
|
|
//YingJieRiQi//应结日期
|
|
|
//ShiJieRiQi//实结日期
|
|
|
#endregion
|
|
|
|
|
|
#region 基本语句
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("(");
|
|
|
strSql.Append("select B.BSNO");//编号
|
|
|
strSql.Append(",ISSALEFEE=isnull((select top 1 '已发放' from cw_user_ticheng_detail where bsno=B.BSNO),'')");//提成发放
|
|
|
strSql.Append(",SALE");//业务员
|
|
|
strSql.Append(",CUSTOMERNAME");//委托单位
|
|
|
strSql.Append(",OPLBNAME");//业务类型
|
|
|
strSql.Append(",OPTYPE");//更改单
|
|
|
strSql.Append(",FEESTATUSREF");//费用锁定
|
|
|
strSql.Append(",CUSTNO");//委托编号
|
|
|
strSql.Append(",MBLNO");//主提单号
|
|
|
strSql.Append(",ETD");//开船日期
|
|
|
strSql.Append(",ACCDATE");//会计期间
|
|
|
strSql.Append(",CORPID");//公司GID
|
|
|
strSql.Append(",isnull(RMBDR,0) as RMBDR");//RMB应收
|
|
|
strSql.Append(",isnull(RMBCR,0) as RMBCR");//RMB应付
|
|
|
strSql.Append(",isnull(USDDR,0) as USDDR");//USD应收
|
|
|
strSql.Append(",isnull(USDCR,0) as USDCR");//USD应付
|
|
|
strSql.Append(",isnull(OTDR,0) as OTDR");//其他币别应收
|
|
|
strSql.Append(",isnull(OTCR,0) as OTCR");//其他币别应付
|
|
|
strSql.Append(",isnull(TTLDR,0) as TTLDR");//合计应收
|
|
|
strSql.Append(",isnull(TTLCR,0) as TTLCR");//合计应付
|
|
|
strSql.Append(",isnull(OPFEE,0) As OPFEE");//合计毛利润
|
|
|
strSql.Append(",isnull(TTLPROFIT,0) as TTLPROFIT");//合计毛利润
|
|
|
strSql.Append(",0 as ShuiFei");//税费//毛利*税率
|
|
|
strSql.Append(",0 as YeWuFeiYong");//业务费用//其他费用模块中部分费用科目
|
|
|
strSql.Append(",0 as JingLiRun");//净利润//毛利-税费-业务费用
|
|
|
strSql.Append(",0 as TiChengJiShu");//");//提成基数 //ds6:“部门1=净利-底数1”,“部门2=净利-底数2”,“其他部门=净利”,ds7直接提取提成比例
|
|
|
strSql.Append(",0 as GeRenFeiYong");//个人费用//其他费用模块中部分费用科目(只提取用于出报表,不参与提成统计)
|
|
|
strSql.Append(",0 as TiChengBiLi");//");//提成比例//按提成设置分段提取,因有多个默认为0,暂不显示
|
|
|
strSql.Append(",0 as TiCheng");//提成//提成基数*提成比例
|
|
|
strSql.Append(",0 as ShiFa");//实发提成
|
|
|
strSql.Append(",STLDATE as YingJieRiQi");//应结日期
|
|
|
strSql.Append(",T.SETTLETIME as ShiJieRiQi");//实结日期
|
|
|
strSql.Append(" FROM v_op_bill_gain as B LEFT JOIN V_MAX_SETTLEMENTTIME_BSDR T ON (T.BSNO=B.BSNO) where 1=1");
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
strSql.Append(") union (");
|
|
|
strSql.Append("select (SALE+'合计') as BSNO");//编号
|
|
|
strSql.Append(",ISSALEFEE=(isnull((select top 1 '已发放' from cw_user_ticheng where USERGID=(select top 1 GID from [user] where SHOWNAME=B.SALE) and ACCDATE='" + accDate + "'),'')+'合计')");//提成发放
|
|
|
strSql.Append(",SALE");//业务员
|
|
|
strSql.Append(",'' as CUSTOMERNAME");//委托单位
|
|
|
strSql.Append(",'' as OPLBNAME");//业务类型
|
|
|
strSql.Append(",'' as OPTYPE");//更改单
|
|
|
strSql.Append(",'' as FEESTATUSREF");//费用锁定
|
|
|
strSql.Append(",'' as CUSTNO");//委托编号
|
|
|
strSql.Append(",'' as MBLNO");//主提单号
|
|
|
strSql.Append(",'' as ETD");//开船日期
|
|
|
strSql.Append(",'' as ACCDATE");//会计期间
|
|
|
strSql.Append(",'' as CORPID");//公司GID
|
|
|
strSql.Append(",isnull(sum(RMBDR),0) as RMBDR");//RMB应收
|
|
|
strSql.Append(",isnull(sum(RMBCR),0) as RMBCR");//RMB应付
|
|
|
strSql.Append(",isnull(sum(USDDR),0) as USDDR");//USD应收
|
|
|
strSql.Append(",isnull(sum(USDCR),0) as USDCR");//USD应付
|
|
|
strSql.Append(",isnull(sum(OTDR),0) as OTDR");//其他币别应收
|
|
|
strSql.Append(",isnull(sum(OTCR),0) as OTCR");//其他币别应付
|
|
|
strSql.Append(",isnull(sum(TTLDR),0) as TTLDR");//合计应收
|
|
|
strSql.Append(",isnull(sum(TTLCR),0) as TTLCR");//合计应付
|
|
|
strSql.Append(",isnull(sum(OPFEE),0) as OPFEE");//合计应付
|
|
|
strSql.Append(",isnull(sum(TTLPROFIT),0) as TTLPROFIT");//合计毛利润
|
|
|
strSql.Append(",isnull(Convert(decimal(18,2),(sum(TTLPROFIT)*" + ShuiLv + "/100)),0) as ShuiFei");//税费//毛利*税率
|
|
|
strSql.Append(",isnull((select isnull(sum(AMOUNT_F),0) as AMOUNT_F from [VW_ch_fee_management_mbody] where ACCDATE='" + accDate + "' and SALE=B.SALE and OPERATORSIDE like '" + YeWuFeiYong + "%'),0) as YeWuFeiYong");//业务费用//其他费用模块中部分费用科目
|
|
|
strSql.Append(",isnull((sum(TTLPROFIT)-sum(OPFEE)-Convert(decimal(18,2),(sum(TTLPROFIT)*" + ShuiLv + "/100))-isnull((select isnull(sum(AMOUNT_F),0) as AMOUNT_F from [VW_ch_fee_management_mbody] where ACCDATE='" + accDate + "' and SALE=B.SALE and OPERATORSIDE like '" + YeWuFeiYong + "%'),0)),0) as JingLiRun");//净利润//毛利-税费-业务费用
|
|
|
strSql.Append(",isnull((sum(TTLPROFIT)-sum(OPFEE)-Convert(decimal(18,2),(sum(TTLPROFIT)*" + ShuiLv + "/100))-isnull((select isnull(sum(AMOUNT_F),0) as AMOUNT_F from [VW_ch_fee_management_mbody] where ACCDATE='" + accDate + "' and SALE=B.SALE and OPERATORSIDE like '" + YeWuFeiYong + "%'),0)),0) as TiChengJiShu");//");//提成基数 //ds6:“部门1=净利-底数1”,“部门2=净利-底数2”,“其他部门=净利”,ds7直接提取提成比例
|
|
|
strSql.Append(",isnull((select isnull(sum(AMOUNT_F),0) as AMOUNT_F from [VW_ch_fee_management_mbody] where ACCDATE='" + accDate + "' and SALE=B.SALE and OPERATORSIDE like '" + GeRenFeiYong + "%'),0) as GeRenFeiYong");//个人费用//其他费用模块中部分费用科目(只提取用于出报表,不参与提成统计)
|
|
|
strSql.Append(",0 as TiChengBiLi");//");//提成比例//按提成设置分段提取,因有多个默认为0,暂不显示
|
|
|
strSql.Append(",0 as TiCheng");//提成//提成基数(净利润)*提成比例
|
|
|
strSql.Append(",ShiFa=isnull((select top 1 ShiFa from cw_user_ticheng where USERGID=(select top 1 GID from [user] where SHOWNAME=B.SALE) and ACCDATE='" + accDate + "'),0)");//实发提成
|
|
|
strSql.Append(",'' as YingJieRiQi");//应结日期
|
|
|
strSql.Append(",'' as ShiJieRiQi");//实结日期
|
|
|
strSql.Append(" FROM v_op_bill_gain as B where 1=1");
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
strSql.Append(" group by SALE");//,CORPID
|
|
|
strSql.Append(")");
|
|
|
//
|
|
|
//var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
//if (!string.IsNullOrEmpty(sortstring))
|
|
|
//{
|
|
|
// strSql.Append(" order by SALE,BSNO," + sortstring);
|
|
|
//}
|
|
|
//else
|
|
|
//{
|
|
|
// strSql.Append(" order by SALE,BSNO,ETD desc");
|
|
|
//}
|
|
|
#endregion
|
|
|
|
|
|
#region 清理临时表
|
|
|
int iState = 0;
|
|
|
int result = 0;
|
|
|
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
#region 清理临时表
|
|
|
String sSql = "delete from [cw_user_ticheng_test] where CREATEUSER='" + userid + "' and CORPID1='" + companyid + "'";
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sSql, null);
|
|
|
if (iState < 0)
|
|
|
{
|
|
|
result = -3;
|
|
|
sqlTran.Rollback();
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
result = 1;//状态为1表示删除成功
|
|
|
sqlTran.Commit();
|
|
|
}
|
|
|
catch (Exception execError)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -6;//插入异常,事务已回滚成功
|
|
|
throw execError;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
SqlHelper.CloseConnection();
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 插入临时表【cw_user_ticheng_test】
|
|
|
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
#region 插入临时表【cw_user_ticheng_test】
|
|
|
//GID,VKNO,VOUNO,ITEMNO,VOUDATE,EXPLAN,EXPLAN2,DC,DR,CR,BLC
|
|
|
string sSql = "insert into [cw_user_ticheng_test] select *,'" + userid + "' as CREATEUSER,'" + companyid + "' as CORPID1 from (" + strSql + ") as [lsTable]";
|
|
|
//([GID],[ORDNO],[VKNO],[VOUNO],ITEMNO,[VOUDATE],[EXPLAN],[EXPLAN2],[DC],[DR],[CR],[BLC],[CREATEUSER],[CORPID],[STARTGID]) "
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sSql, null);
|
|
|
if (iState < 0)
|
|
|
{
|
|
|
result = -4;
|
|
|
sqlTran.Rollback();
|
|
|
}
|
|
|
|
|
|
result = 1;//状态为1表示删除成功
|
|
|
sqlTran.Commit();
|
|
|
}
|
|
|
catch (Exception execError)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -6;//插入异常,事务已回滚成功
|
|
|
throw execError;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
SqlHelper.CloseConnection();
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 更新临时表【cw_user_ticheng_test】
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
using (SqlTransaction sqlTran1 = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
#region 插入合计到【cw_user_ticheng_test】表
|
|
|
string sSql = "select * from [cw_user_ticheng_test] where [CREATEUSER]='" + userid + "' and [CORPID1]='" + companyid + "' and charindex('合计',bsno)>0 order by SALE,BSNO,ETD desc";
|
|
|
DataSet dsTiCheng = T_ALL_DA.GetAllSQL(sSql);
|
|
|
if (dsTiCheng != null)
|
|
|
{
|
|
|
if (dsTiCheng.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
for (int i = 0; i < dsTiCheng.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
#region 更新合计【cw_user_ticheng_test】
|
|
|
if (dsTiCheng.Tables[0].Rows[i]["BSNO"].ToString().Trim().IndexOf("合计") > -1)
|
|
|
{
|
|
|
Decimal dlTiCheng = GetTiChengBiLi(Decimal.Parse(dsTiCheng.Tables[0].Rows[i]["TiChengJiShu"].ToString().Trim()), dsTiCheng.Tables[0].Rows[i]["SALE"].ToString().Trim());//提成//, dsTiCheng.Tables[0].Rows[i]["CORPID"].ToString().Trim()
|
|
|
|
|
|
sSql = "update [cw_user_ticheng_test] set TiCheng=" + dlTiCheng + " where BSNO='" + dsTiCheng.Tables[0].Rows[i]["BSNO"].ToString().Trim() + "' and [CREATEUSER]='" + userid + "' and [CORPID1]='" + companyid + "'";
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran1, CommandType.Text, sSql, null);
|
|
|
if (iState < 0)
|
|
|
{
|
|
|
result = -5;
|
|
|
sqlTran1.Rollback();
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
result = 1;//状态为1表示删除成功
|
|
|
sqlTran1.Commit();
|
|
|
}
|
|
|
catch (Exception execError)
|
|
|
{
|
|
|
sqlTran1.Rollback();
|
|
|
result = -6;//插入异常,事务已回滚成功
|
|
|
throw execError;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
SqlHelper.CloseConnection();
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 查询临时表【cw_user_ticheng_test】
|
|
|
var strSql2 = new StringBuilder();
|
|
|
strSql2.Append("SELECT * from [cw_user_ticheng_test] where CREATEUSER='" + userid + "' and CORPID1='" + companyid + "'");
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql2.Append(" order by SALE,BSNO," + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql2.Append(" order by SALE,BSNO,ETD desc");
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
return SetData(strSql2);
|
|
|
}
|
|
|
|
|
|
private static List<MsOpBillProfit> SetData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<MsOpBillProfit>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsOpBillProfit data = new MsOpBillProfit();
|
|
|
#region Set DB data to Object
|
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);//编号
|
|
|
data.ISSALEFEE = Convert.ToString(reader["ISSALEFEE"]);//提成发放
|
|
|
data.SALE = Convert.ToString(reader["SALE"]);//业务员
|
|
|
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);//委托单位
|
|
|
data.OPLBNAME = Convert.ToString(reader["OPLBNAME"]);//业务类型
|
|
|
data.OPTYPE = Convert.ToString(reader["OPTYPE"]);//更改单
|
|
|
data.FEESTATUSREF = Convert.ToString(reader["FEESTATUSREF"]);//费用锁定
|
|
|
data.CUSTNO = Convert.ToString(reader["CUSTNO"]);//委托编号
|
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);//主提单号
|
|
|
data.ETD = Convert.ToString(reader["ETD"]);//开船日期
|
|
|
data.ACCDATE = Convert.ToString(reader["ACCDATE"]);//会计期间
|
|
|
data.CORPID = Convert.ToString(reader["CORPID"]);//公司GID
|
|
|
data.RMBDR = (reader["RMBDR"] == null ? 0 : Convert.ToDecimal(reader["RMBDR"]));//RMB应收
|
|
|
data.RMBCR = (reader["RMBCR"] == null ? 0 : Convert.ToDecimal(reader["RMBCR"]));//RMB应付
|
|
|
data.USDDR = (reader["USDDR"] == null ? 0 : Convert.ToDecimal(reader["USDDR"]));//USD应收
|
|
|
data.USDCR = (reader["USDCR"] == null ? 0 : Convert.ToDecimal(reader["USDCR"]));//USD应付
|
|
|
data.OTDR = (reader["OTDR"] == null ? 0 : Convert.ToDecimal(reader["OTDR"]));//其他币别应收
|
|
|
data.OTCR = (reader["OTCR"] == null ? 0 : Convert.ToDecimal(reader["OTCR"]));//其他币别应付
|
|
|
data.TTLDR = (reader["TTLDR"] == null ? 0 : Convert.ToDecimal(reader["TTLDR"]));//合计应收
|
|
|
data.TTLCR = (reader["TTLCR"] == null ? 0 : Convert.ToDecimal(reader["TTLCR"]));//合计应付
|
|
|
data.OPFEE = (reader["OPFEE"] == null ? 0 : Convert.ToDecimal(reader["OPFEE"]));//实发提成
|
|
|
data.TTLPROFIT = (reader["TTLPROFIT"] == null ? 0 : Convert.ToDecimal(reader["TTLPROFIT"]));//合计毛利润
|
|
|
data.ShuiFei = (reader["ShuiFei"] == null ? 0 : Convert.ToDecimal(reader["ShuiFei"]));//税费
|
|
|
data.YeWuFeiYong = (reader["YeWuFeiYong"] == null ? 0 : Convert.ToDecimal(reader["YeWuFeiYong"]));//业务费用
|
|
|
data.JingLiRun = (reader["JingLiRun"] == null ? 0 : Convert.ToDecimal(reader["JingLiRun"]));//净利润
|
|
|
data.TiChengJiShu = (reader["TiChengJiShu"] == null ? 0 : Convert.ToDecimal(reader["TiChengJiShu"]));//提成基数
|
|
|
data.GeRenFeiYong = (reader["GeRenFeiYong"] == null ? 0 : Convert.ToDecimal(reader["GeRenFeiYong"]));//个人费用
|
|
|
data.TiChengBiLi = (reader["TiChengBiLi"] == null ? 0 : Convert.ToDecimal(reader["TiChengBiLi"]));//提成比例
|
|
|
data.TiCheng = (reader["TiCheng"] == null ? 0 : Convert.ToDecimal(reader["TiCheng"]));//提成
|
|
|
data.ShiFa = (reader["ShiFa"] == null ? 0 : Convert.ToDecimal(reader["ShiFa"]));//实发提成
|
|
|
data.ShiJieRiQi = Convert.ToString(reader["ShiJieRiQi"]).Replace(" 00:00:00", "");//实结日期
|
|
|
data.YingJieRiQi = Convert.ToString(reader["YingJieRiQi"]).Replace(" 00:00:00", "");//应结日期
|
|
|
if (data.BSNO.ToString().Trim().IndexOf("合计") > -1)
|
|
|
{
|
|
|
//data.TiCheng = GetTiChengBiLi(data.TiChengJiShu, data.SALE);//提成, data.CORPID
|
|
|
data.YingJieRiQi = "";//应结日期
|
|
|
data.ShiJieRiQi = "";//实结日期
|
|
|
}
|
|
|
//data.INTEREST = Getlx(data.ETD,data.BSNO,data.SALE);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
static public string GetDataListStr(string strCondition, string ShuiLv, string YeWuFeiYong, string GeRenFeiYong, string accDate, string userid, string usercode, string companyid, string sort = null)
|
|
|
{
|
|
|
var strSql2 = new StringBuilder();
|
|
|
strSql2.Append("SELECT * from [cw_user_ticheng_test] where CREATEUSER='" + userid + "' and CORPID1='" + companyid + "'");
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql2.Append(" order by SALE,BSNO," + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql2.Append(" order by SALE,BSNO,ETD desc");
|
|
|
}
|
|
|
return strSql2.ToString();
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算_提成比例
|
|
|
static public decimal GetTiChengBiLi(Decimal TiChengJiShu, string sale)//, string CORPID
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
decimal result = 0;
|
|
|
if (sale == "") return 0;// || CORPID == ""
|
|
|
//
|
|
|
if (TiChengJiShu == 0)
|
|
|
{
|
|
|
#region 提成基数=0
|
|
|
result = 0;
|
|
|
#endregion
|
|
|
}
|
|
|
else if (TiChengJiShu > 0)
|
|
|
{
|
|
|
#region 提成基数>0
|
|
|
string sSQL = "SELECT * from info_sale_profitShareDetail where PLANID=(SELECT top 1 PLANID from info_sale_profitShareSet where SALE='" + sale + "') ORDER BY PLANID,PROFITDOWN";// and COMPANYID='" + CORPID + "'
|
|
|
DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
if (ds != null)
|
|
|
{
|
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
Decimal dPROFITDOWN = Decimal.Parse(ds.Tables[0].Rows[i]["PROFITDOWN"].ToString());
|
|
|
Decimal dPROFITUP = Decimal.Parse(ds.Tables[0].Rows[i]["PROFITUP"].ToString());
|
|
|
Decimal dSHAREPR = Decimal.Parse(ds.Tables[0].Rows[i]["SHAREPR"].ToString());
|
|
|
if (dSHAREPR == 0)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
if (dPROFITUP <= 0)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (dPROFITDOWN <= 0)
|
|
|
{
|
|
|
dPROFITDOWN = 0;
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
if (TiChengJiShu > dPROFITDOWN)
|
|
|
{
|
|
|
if (TiChengJiShu >= dPROFITUP)
|
|
|
{
|
|
|
if (i == ds.Tables[0].Rows.Count - 1)
|
|
|
{
|
|
|
result += (TiChengJiShu - dPROFITDOWN) * dSHAREPR / 100;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result += (dPROFITUP - dPROFITDOWN) * dSHAREPR / 100;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result += (TiChengJiShu - dPROFITDOWN) * dSHAREPR / 100;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
else if (TiChengJiShu < 0)
|
|
|
{
|
|
|
#region 提成基数<0
|
|
|
string sSQL = "SELECT * from info_sale_profitShareDetail where PLANID=(SELECT top 1 PLANID from info_sale_profitShareSet where SALE='" + sale + "') ORDER BY PLANID,PROFITDOWN desc";// and COMPANYID='" + CORPID + "'
|
|
|
DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
|
|
|
if (ds != null)
|
|
|
{
|
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
Decimal dPROFITDOWN = Decimal.Parse(ds.Tables[0].Rows[i]["PROFITDOWN"].ToString());
|
|
|
Decimal dPROFITUP = Decimal.Parse(ds.Tables[0].Rows[i]["PROFITUP"].ToString());
|
|
|
Decimal dSHAREPR = Decimal.Parse(ds.Tables[0].Rows[i]["SHAREPR"].ToString());
|
|
|
if (dSHAREPR == 0)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
if (dPROFITDOWN >= 0)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (dPROFITUP >= 0)
|
|
|
{
|
|
|
dPROFITUP = 0;
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
if (TiChengJiShu < dPROFITUP)
|
|
|
{
|
|
|
if (TiChengJiShu <= dPROFITDOWN)
|
|
|
{
|
|
|
if (i == ds.Tables[0].Rows.Count - 1)
|
|
|
{
|
|
|
result += (TiChengJiShu - dPROFITUP) * dPROFITDOWN / 100;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result += (dPROFITDOWN - dPROFITUP) * dSHAREPR / 100;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result += (TiChengJiShu - dPROFITUP) * dSHAREPR / 100;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else result = 0;
|
|
|
}
|
|
|
else result = 0;
|
|
|
#endregion
|
|
|
}
|
|
|
return Math.Round(result, 2, MidpointRounding.AwayFromZero);
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算_发放提成
|
|
|
public static DBResult SetFee(List<MsOpBillProfit> boday, List<MsOpBillProfit> bodayHJ, string ShuiLv, string YeWuFeiYong, string GeRenFeiYong, string accDate, String USERID)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
var result = new DBResult();
|
|
|
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (boday != null && bodayHJ != null)
|
|
|
{
|
|
|
foreach (var enumValueHJ in bodayHJ)
|
|
|
{
|
|
|
string strSALEGID = T_ALL_DA.GetStrSQL("GID", "select top 1 GID from [user] where SHOWNAME='" + enumValueHJ.SALE + "'");// and gid in (select USERID from user_baseinfo where COMPANYNAME=(select top 1 [NAME] from company where gid='" + enumValueHJ.CORPID + "'))
|
|
|
string strGID = Guid.NewGuid().ToString();
|
|
|
//
|
|
|
string sSQL = "delete from cw_user_ticheng where USERGID='" + strSALEGID + "' and ACCDATE='" + accDate + "'";
|
|
|
//SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sSQL, null);
|
|
|
|
|
|
sSQL = "delete from cw_user_ticheng_detail where LINKGID not in (select GID from [cw_user_ticheng])";
|
|
|
//SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sSQL, null);
|
|
|
|
|
|
sSQL = "INSERT INTO [cw_user_ticheng]([GID],[USERGID],[ACCDATE],[TiCheng],[ShiFa],[KouFeiLv],[MODIFIEDUSER],[MODIFIEDTIME]) VALUES('" + strGID + "','" + strSALEGID + "','" + accDate + "','" + enumValueHJ.TiCheng + "','" + enumValueHJ.TiCheng + "','" + ShuiLv + "','" + USERID + "',getdate())";
|
|
|
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sSQL, null);
|
|
|
|
|
|
foreach (var enumValue in boday)
|
|
|
{
|
|
|
if (enumValueHJ.SALE == enumValue.SALE)
|
|
|
{
|
|
|
sSQL = "INSERT INTO [cw_user_ticheng_detail]([GID],[LINKGID],[BSNO],[MODIFIEDUSER],[MODIFIEDTIME]" +
|
|
|
",[MBLNO],[ACCDATE],[SALE],[CUSTNO],[CUSTOMERNAME],[ETD],[RMBDR],[RMBCR],[USDDR],[USDCR],[OTDR],[OTCR],[TTLDR],[TTLCR],[TTLPROFIT]" +
|
|
|
",[ShuiFei],[YeWuFeiYong],[JingLiRun],[TiChengJiShu],[GeRenFeiYong],[TiCheng],[ShiFa],[YingJieRiQi],[ShiJieRiQi]" +
|
|
|
") VALUES(newid(),'" + strGID + "','" + enumValue.BSNO + "','" + USERID + "',getdate()" +
|
|
|
",'" + enumValue.MBLNO + "','" + enumValue.ACCDATE + "','" + enumValue.SALE + "','" + enumValue.CUSTNO + "','" + enumValue.CUSTOMERNAME + "','" + enumValue.ETD + "'" +
|
|
|
","+ enumValue.RMBDR+ "," + enumValue.RMBCR + "," + enumValue.USDDR + "," + enumValue.USDCR + "," + enumValue.OTDR + "," + enumValue.OTCR + "" +
|
|
|
"," + enumValue.TTLDR + "," + enumValue.TTLCR + "," + enumValue.TTLPROFIT + "," + enumValue.ShuiFei + "," + enumValue.YeWuFeiYong + "," + enumValue.JingLiRun + "" +
|
|
|
"," + enumValue.TiChengJiShu + "," + enumValue.GeRenFeiYong + "," + enumValue.TiCheng + "," + enumValue.ShiFa + "" +
|
|
|
",'" + enumValue.YingJieRiQi + "','" + enumValue.ShiJieRiQi + "')";
|
|
|
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sSQL, null);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "操作出现错误,请重试!";
|
|
|
return result;
|
|
|
}
|
|
|
//事务提交
|
|
|
sqlTran.Commit();
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result.Success = false;
|
|
|
result.Message = "操作出现错误,请重试!";
|
|
|
return result;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
SqlHelper.CloseConnection();
|
|
|
sqlTran.Dispose();
|
|
|
}
|
|
|
}
|
|
|
result.Success = true;
|
|
|
result.Message = "操作完成";
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算_取消发放
|
|
|
public static DBResult CancelSetFee(List<MsOpBillProfit> boday, List<MsOpBillProfit> bodayHJ, string ShuiLv, string YeWuFeiYong, string GeRenFeiYong, string accDate, String USERID)
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
var result = new DBResult();
|
|
|
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (bodayHJ != null)
|
|
|
{
|
|
|
foreach (var enumValueHJ in bodayHJ)
|
|
|
{
|
|
|
string strSALEGID = T_ALL_DA.GetStrSQL("GID", "select top 1 GID from [user] where SHOWNAME='" + enumValueHJ.SALE + "'");// and gid in (select USERID from user_baseinfo where COMPANYNAME=(select top 1 [NAME] from company where gid='" + enumValueHJ.CORPID + "'))
|
|
|
//
|
|
|
string sSQL = "delete from cw_user_ticheng where USERGID='" + strSALEGID + "' and ACCDATE='" + accDate + "'";
|
|
|
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sSQL, null);
|
|
|
|
|
|
sSQL = "delete from cw_user_ticheng_detail where LINKGID not in (select GID from [cw_user_ticheng])";
|
|
|
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sSQL, null);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Success = false;
|
|
|
result.Message = "操作出现错误,请重试!";
|
|
|
return result;
|
|
|
}
|
|
|
//事务提交
|
|
|
sqlTran.Commit();
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result.Success = false;
|
|
|
result.Message = "操作出现错误,请重试!";
|
|
|
return result;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
SqlHelper.CloseConnection();
|
|
|
sqlTran.Dispose();
|
|
|
}
|
|
|
}
|
|
|
result.Success = true;
|
|
|
result.Message = "操作完成";
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算扣息
|
|
|
static public decimal Getlx(string etd, string bsno, string sale)
|
|
|
{
|
|
|
decimal result = 0;
|
|
|
if (etd == "" || sale == "") return 0;
|
|
|
var lxdataset = MsInfoSaleProfitShareSetDAL.GetSaleProfitLxDataList(" PLANID IN (SELECT TOP 1 PLANID FROM info_sale_profitShareSet WHERE SALE='" + sale + "') ");
|
|
|
if (lxdataset != null)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append(" SETTLETIME,SUM(ORIGAMOUNT*ORIGEXCHANGERATE) AS AMOUNT ");
|
|
|
strSql.Append(" from v_fee_do_settlement ");
|
|
|
strSql.Append(" where BSNO='" + bsno + "' AND FEETYPE=1 ");
|
|
|
strSql.Append(" group by SETTLETIME ");
|
|
|
|
|
|
decimal amount = 0;
|
|
|
decimal lxrate = 0;
|
|
|
DateTime stldate;
|
|
|
DateTime etddate = Convert.ToDateTime(etd);
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
amount = Convert.ToDecimal(reader["AMOUNT"]);
|
|
|
stldate = Convert.ToDateTime(reader["SETTLETIME"]);
|
|
|
int days = Math.Abs((stldate - etddate).Days);
|
|
|
foreach (var enumValue in lxdataset)
|
|
|
{
|
|
|
if (enumValue.DEDUCTIN == 0) { result = result + 0; }
|
|
|
else
|
|
|
{
|
|
|
if (days >= enumValue.BDAY && days <= enumValue.EDAY)
|
|
|
{
|
|
|
lxrate = enumValue.DEDUCTIN / 100;
|
|
|
result = result + (amount * lxrate * (days - enumValue.BDAY));
|
|
|
}
|
|
|
else if (days > enumValue.EDAY)
|
|
|
{
|
|
|
lxrate = enumValue.DEDUCTIN / 100;
|
|
|
result = result + (amount * lxrate * (enumValue.EDAY - enumValue.BDAY));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
}
|
|
|
else result = 0;
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 权限
|
|
|
public static string GetRangDAStr(string tb, string userid, string usercode, string companyid)
|
|
|
{
|
|
|
string str = "";
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT ");
|
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE ");
|
|
|
strSql.Append(" from VW_User_Authority ");
|
|
|
strSql.Append(" where [NAME]='modSaleProfitShare' and USERID='" + userid + "' and ISDELETE=0");
|
|
|
|
|
|
string visiblerange = "4";
|
|
|
string operaterange = "4";
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
|
|
|
operaterange = Convert.ToString(reader["OPERATERANGE"]);
|
|
|
break;
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
if (visiblerange == "4")
|
|
|
{
|
|
|
str = "1=2";
|
|
|
}
|
|
|
else if (visiblerange == "3")
|
|
|
{
|
|
|
|
|
|
str = " (B.OP='" + usercode + "' OR B.SALE='" + usercode + "')";
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "2")
|
|
|
{
|
|
|
if (tb == "index")
|
|
|
{
|
|
|
var rangeDa = new RangeDA();
|
|
|
var deptname = rangeDa.GetDEPTNAME(userid);
|
|
|
var userstr = new StringBuilder();
|
|
|
userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')");
|
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
|
{
|
|
|
str = "";
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
if (str == "")
|
|
|
{
|
|
|
str = " (B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = str + " or B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
|
|
|
};
|
|
|
}
|
|
|
str = str + ")";
|
|
|
reader.Close();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
str = " UPPER(B.Corpid)='" + companyid + "'";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else if (visiblerange == "1")
|
|
|
{
|
|
|
str = " UPPER(B.Corpid)='" + companyid + "'";
|
|
|
}
|
|
|
|
|
|
return str;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 维护页面查询
|
|
|
static public List<MsRptSaleLiRunTiCheng> GetCwUserTiChengList(string strCondition, string sSALE, string accDate, string userid, string usercode, string companyid, string sort = null)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("select t.*");
|
|
|
strSql.Append(",u.SHOWNAME as USERNAME");//提成发放
|
|
|
strSql.Append(" FROM cw_user_ticheng as t LEFT JOIN [user] as u on t.USERGID=u.GID where 1=1");
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(strCondition);
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(sSALE))
|
|
|
{
|
|
|
strSql.Append(" and u.SHOWNAME='" + sSALE + "'");
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(accDate))
|
|
|
{
|
|
|
strSql.Append(" and t.ACCDATE='" + accDate + "'");
|
|
|
}
|
|
|
//
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by u.SHOWNAME,t.ACCDATE");
|
|
|
}
|
|
|
return SetCwUserTiChengData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<MsRptSaleLiRunTiCheng> SetCwUserTiChengData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<MsRptSaleLiRunTiCheng>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsRptSaleLiRunTiCheng data = new MsRptSaleLiRunTiCheng();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//GID
|
|
|
data.USERGID = (reader["USERGID"] == null ? "" : Convert.ToString(reader["USERGID"]));//USERGID
|
|
|
data.ACCDATE = (reader["ACCDATE"] == null ? "" : Convert.ToString(reader["ACCDATE"]));//ACCDATE
|
|
|
data.TiCheng = (reader["TiCheng"] == null ? 0 : Convert.ToDecimal(reader["TiCheng"]));//TiCheng
|
|
|
data.ShiFa = (reader["ShiFa"] == null ? 0 : Convert.ToDecimal(reader["ShiFa"]));//ShiFa
|
|
|
data.KouFeiLv = (reader["KouFeiLv"] == null ? 0 : Convert.ToDecimal(reader["KouFeiLv"]));//KouFeiLv
|
|
|
data.REMARK = (reader["REMARK"] == null ? "" : Convert.ToString(reader["REMARK"]));//REMARK
|
|
|
data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//MODIFIEDUSER
|
|
|
if (reader["MODIFIEDTIME"] != null && reader["MODIFIEDTIME"].ToString().Trim().IndexOf("0001") < 0 && reader["MODIFIEDTIME"].ToString().Trim().IndexOf("1900") < 0 && reader["MODIFIEDTIME"].ToString().Trim() != "")
|
|
|
{
|
|
|
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);//最后一次更新操作时间
|
|
|
}
|
|
|
data.USERNAME = (reader["USERNAME"] == null ? "" : Convert.ToString(reader["USERNAME"]));//USERNAME
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
static public List<MsOpBillProfit> GetCwUserTiChengDetailList(string strCondition, string sort = null)
|
|
|
{
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT * FROM cw_user_ticheng_detail where 1=1 ");
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(strCondition);
|
|
|
}
|
|
|
//
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
|
{
|
|
|
strSql.Append(" order by " + sortstring);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append(" order by MODIFIEDTIME ");
|
|
|
}
|
|
|
|
|
|
return SetCwUserTiChengDetailData(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<MsOpBillProfit> SetCwUserTiChengDetailData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<MsOpBillProfit>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
MsOpBillProfit data = new MsOpBillProfit();
|
|
|
#region Set DB data to Object
|
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);//编号
|
|
|
data.SALE = Convert.ToString(reader["SALE"]);//业务员
|
|
|
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);//委托单位
|
|
|
data.CUSTNO = Convert.ToString(reader["CUSTNO"]);//委托编号
|
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);//主提单号
|
|
|
data.ETD = Convert.ToString(reader["ETD"]);//开船日期
|
|
|
data.ACCDATE = Convert.ToString(reader["ACCDATE"]);//会计期间
|
|
|
if (reader["RMBDR"] != DBNull.Value)
|
|
|
data.RMBDR = (reader["RMBDR"] == null ? 0 : Convert.ToDecimal(reader["RMBDR"]));//RMB应收
|
|
|
if (reader["RMBCR"] != DBNull.Value)
|
|
|
data.RMBCR = (reader["RMBCR"] == null ? 0 : Convert.ToDecimal(reader["RMBCR"]));//RMB应付
|
|
|
if (reader["USDDR"] != DBNull.Value)
|
|
|
data.USDDR = (reader["USDDR"] == null ? 0 : Convert.ToDecimal(reader["USDDR"]));//USD应收
|
|
|
if (reader["USDCR"] != DBNull.Value)
|
|
|
data.USDCR = (reader["USDCR"] == null ? 0 : Convert.ToDecimal(reader["USDCR"]));//USD应付
|
|
|
if (reader["OTDR"] != DBNull.Value)
|
|
|
data.OTDR = (reader["OTDR"] == null ? 0 : Convert.ToDecimal(reader["OTDR"]));//其他币别应收
|
|
|
if (reader["OTCR"] != DBNull.Value)
|
|
|
data.OTCR = (reader["OTCR"] == null ? 0 : Convert.ToDecimal(reader["OTCR"]));//其他币别应付
|
|
|
if (reader["TTLDR"] != DBNull.Value)
|
|
|
data.TTLDR = (reader["TTLDR"] == null ? 0 : Convert.ToDecimal(reader["TTLDR"]));//合计应收
|
|
|
if (reader["TTLCR"] != DBNull.Value)
|
|
|
data.TTLCR = (reader["TTLCR"] == null ? 0 : Convert.ToDecimal(reader["TTLCR"]));//合计应付
|
|
|
if (reader["TTLPROFIT"] != DBNull.Value)
|
|
|
data.TTLPROFIT = (reader["TTLPROFIT"] == null ? 0 : Convert.ToDecimal(reader["TTLPROFIT"]));//合计毛利润
|
|
|
if (reader["ShuiFei"] != DBNull.Value)
|
|
|
data.ShuiFei = (reader["ShuiFei"] == null ? 0 : Convert.ToDecimal(reader["ShuiFei"]));//税费
|
|
|
if (reader["YeWuFeiYong"] != DBNull.Value)
|
|
|
data.YeWuFeiYong = (reader["YeWuFeiYong"] == null ? 0 : Convert.ToDecimal(reader["YeWuFeiYong"]));//业务费用
|
|
|
if (reader["JingLiRun"] != DBNull.Value)
|
|
|
data.JingLiRun = (reader["JingLiRun"] == null ? 0 : Convert.ToDecimal(reader["JingLiRun"]));//净利润
|
|
|
if (reader["TiChengJiShu"] != DBNull.Value)
|
|
|
data.TiChengJiShu = (reader["TiChengJiShu"] == null ? 0 : Convert.ToDecimal(reader["TiChengJiShu"]));//提成基数
|
|
|
if (reader["GeRenFeiYong"] != DBNull.Value)
|
|
|
data.GeRenFeiYong = (reader["GeRenFeiYong"] == null ? 0 : Convert.ToDecimal(reader["GeRenFeiYong"]));//个人费用
|
|
|
// data.TiChengBiLi = (reader["TiChengBiLi"] == null ? 0 : Convert.ToDecimal(reader["TiChengBiLi"]));//提成比例
|
|
|
if (reader["TiCheng"] != DBNull.Value)
|
|
|
data.TiCheng = (reader["TiCheng"] == null ? 0 : Convert.ToDecimal(reader["TiCheng"]));//提成
|
|
|
if (reader["ShiFa"] != DBNull.Value)
|
|
|
data.ShiFa = (reader["ShiFa"] == null ? 0 : Convert.ToDecimal(reader["ShiFa"]));//实发提成
|
|
|
data.ShiJieRiQi = Convert.ToString(reader["ShiJieRiQi"]).Replace(" 00:00:00", "");//实结日期
|
|
|
data.YingJieRiQi = Convert.ToString(reader["YingJieRiQi"]).Replace(" 00:00:00", "");//应结日期
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
}
|
|
|
}
|