Пример #1
0
        public List<ReportCommonEntity> GetCustomerStageRate(string begintime, string endtime, string agentid, string clientid)
        {
            List<ReportCommonEntity> list = new List<ReportCommonEntity>();
            DataSet ds = CustomerRPTDAL.BaseProvider.GetCustomerStageRate(begintime, endtime, agentid, clientid);

            var stages = SystemBusiness.BaseBusiness.GetCustomStages(agentid, clientid);
            int total = 0, prev = 0;
            foreach (var stage in stages)
            {
                ReportCommonEntity model = new ReportCommonEntity();

                model.name = stage.StageName;
                model.iValue = 0;
                model.desc = "";

                foreach (DataRow dr in ds.Tables["Data"].Select("StageID='" + stage.StageID + "'"))
                {
                    model.desc += CommonBusiness.GetEnumDesc((EnumCustomStatus)Convert.ToInt32(dr["Status"])) + ":" + dr["Value"].ToString();

                    model.iValue += Convert.ToInt32(dr["Value"]);
                }
                total += model.iValue;

                list.Add(model);
            }


            if (total > 0)
            {
                for (int i = list.Count - 1; i >= 0; i--)
                {
                    list[i].iValue += prev;
                    prev = list[i].iValue;

                    list[i].value = (Convert.ToDecimal(list[i].iValue) / total * 100).ToString("f2");
                    list[i].name += list[i].iValue;
                    if (list[i].desc.Length > 0)
                    {
                        list[i].name += " (" + list[i].desc + ") ";
                    }
                }

               
            }
            return list;
        }
Пример #2
0
        public List<ReportCommonEntity> GetOpportunityStageRate(string begintime, string endtime, string UserID, string TeamID, string agentid, string clientid, out decimal forecast)
        {
            forecast = 0;

            List<ReportCommonEntity> list = new List<ReportCommonEntity>();
            DataSet ds = SalesRPTDAL.BaseProvider.GetOpportunityStageRate(begintime, endtime, UserID, TeamID, agentid, clientid);

            var stages = SystemBusiness.BaseBusiness.GetOrderStages("", agentid, clientid);
            decimal total = 0, prev = 0;
            foreach (var stage in stages)
            {
                ReportCommonEntity model = new ReportCommonEntity();

                model.name = stage.StageName;
                
                DataRow[] drs = ds.Tables["Data"].Select("StageID='" + stage.StageID + "'");
                if (drs.Count() > 0)
                {
                    model.dValue = Convert.ToDecimal(drs[0]["Value"]);
                }
                else
                {
                    model.dValue = 0;
                }
                model.desc = "当前:" + model.dValue.ToString("f2") + "*" + (stage.Probability * 100).ToString("f2") + "%";

                total += model.dValue;

                forecast += model.dValue * stage.Probability;

                list.Add(model);
            }


            if (total > 0)
            {
                for (int i = list.Count - 1; i >= 0; i--)
                {
                    list[i].dValue += prev;
                    prev = list[i].dValue;

                    list[i].value = (list[i].dValue / total * 100).ToString("f2");
                    list[i].name += list[i].dValue.ToString("f2");
                    list[i].name += " (" + list[i].desc + ") ";
                }
            }
            else 
            {
                return new List<ReportCommonEntity>();
            }
            return list;
        }