/// <summary> /// 计算业务员的业绩数据 /// </summary> /// <param name="YearMonth">所在月度</param> /// <param name="salesId">业务员Id</param> /// <returns>当月业绩</returns> public Salestarget CalcCommission(DateTime YearMonth, int salesId) { //计算 提成,返回计算结果 Salestarget st = new Salestarget(); st.Load(YearMonth, salesId); //读取销售业绩 DataTable dt = GetSalesData(YearMonth, salesId).Tables[0]; //st.Target = st.Finish = CommenClass.MathTools.ToDouble(dt.Compute("Sum(SumMoney)", "true").ToString()); //总销售业绩 st.GrossProfit = CommenClass.MathTools.ToDouble(dt.Compute("Sum(GrossProfit)", "true").ToString()); //总销售毛利 st.NewCustomer = CommenClass.MathTools.ToDouble(dt.Compute("Sum(SumMoney)", "DiffMonth<=12 and IsSPAssess=0").ToString()); //新客户销售业绩 st.NewGrossProfit = CommenClass.MathTools.ToDouble(dt.Compute("Sum(GrossProfit)", "DiffMonth<=12 and IsSPAssess=0").ToString()); //新客户销售毛利 st.OldCustormer = CommenClass.MathTools.ToDouble(dt.Compute("Sum(SumMoney)", "DiffMonth>12 and IsSPAssess=0").ToString()); //老客户销售业绩 st.OldGrossProfit = CommenClass.MathTools.ToDouble(dt.Compute("Sum(GrossProfit)", "DiffMonth >12 and IsSPAssess=0").ToString()); //老客户销售毛利 SalesTargetFactor stf = new SalesTargetFactor(st); st.Finish = stf.Finish; st.FinishRatio = stf.FinishRatio; st.ProfitFactor = stf.ProfitFactor; st.ProfitRatio = stf.ProfitRatio; st.Commission = stf.Commission; return(st); }
} //当月应发提成(没有计算 应收账款系数) public SalesTargetFactor(Salestarget st) { this.target = st.Target; this.finish = st.Finish; this.grossProfit = st.GrossProfit; this.newCustomerSalesAmount = st.NewCustomer; this.oldCustomerSalesAmount = st.OldCustormer; this.newCustomerGrossProfit = st.NewGrossProfit; this.oldCustomerGrossProfit = st.OldGrossProfit; this.normalCost = st.NormalCost; this.dlhsCost = st.DLHSCost; }
/// <summary> /// 保存销售目标 /// </summary> /// <param name="targets"></param> /// <returns></returns> public int SaveSalesTarget(Salestarget[] targets) { int OK = 0; for (int i = 0; i < targets.Length; i++) { Salestarget st = new Salestarget(); st.Id = targets[i].Id; st.Load(); st.Target = targets[i].Target; st.Save(); OK += 1; } return(OK); }
/// <summary> /// 保存销售费用 /// </summary> /// <param name="targets"></param> /// <returns></returns> public int SaveSalesCost(Salestarget[] targets) { int OK = 0; for (int i = 0; i < targets.Length; i++) { Salestarget st = new Salestarget(); st.Id = targets[i].Id; st.Load(); st.NormalCost = targets[i].NormalCost; st.DLHSCost = targets[i].DLHSCost; st.SaleCost = targets[i].SaleCost; st.Save(); OK += 1; } return(OK); }
/// <summary> /// 为业务员初始化业绩数据 为0 /// </summary> /// <param name="salesId"></param> /// <returns></returns> public int InitSalesTarget(int Year, int salesId) { string s = new DateTime(Year, 1, 1).ToShortDateString(); string e = new DateTime(Year + 1, 1, 1).ToShortDateString(); string sql = string.Format(" delete from SalesTarget where SalesId={0} and YearMonth >='{1}' and YearMonth <'{2}' ", salesId, s, e); int OK = 0; if (m_dbo.ExecuteNonQuery(sql)) { for (int i = 1; i < 13; i++) { Salestarget st = new Salestarget(); st.SalesId = salesId; st.YearMonth = new DateTime(Year, i, 1); if (st.Save() > 0) { OK += 1; } } } return(OK); }