コード例 #1
0
        public ActionResult AgencyList()
        {
            T_AgencyBll bll  = new T_AgencyBll();
            var         list = bll.GetList();

            return(View(list));
        }
コード例 #2
0
        public ActionResult AgencyAdd()
        {
            var model = new T_Agency();
            var bll   = new T_AgencyBll();

            if (Request.QueryString["AgencyId"] != null)
            {
                model = bll.GetModel(int.Parse(Request.QueryString["AgencyId"].ToString()));
            }
            else
            {
                model.IsShow = 1;
            }
            return(View(model));
        }
コード例 #3
0
        public Dictionary <string, object> IntoAgency()
        {
            T_AgencyBll bll      = new T_AgencyBll();
            string      url      = HttpContext.Current.Request.Form["url"].ToString();
            string      filename = HttpContext.Current.Request.Form["filename"].ToString();
            DataSet     ds       = ExportFile.ExcelSqlConnection(HttpContext.Current.Server.MapPath(url), "Info"); //调用自定义方法

            DataRow[] dr           = ds.Tables[0].Select();
            int       successcount = 0;
            int       failcount    = 0;

            for (int i = 0; i < dr.Length; i++)
            {
                try
                {
                    T_Agency model = new T_Agency();

                    model.AgencyName     = dr[i][0].ToString();
                    model.CreateUserId   = ManageProvider.Provider.Current().UserId;
                    model.CreateUserName = ManageProvider.Provider.Current().Account;
                    model.CreateTime     = DateTime.Now;
                    model.IsDelete       = 0;
                    model.IsShow         = 1;
                    model.SortCode       = 0;
                    if (bll.Add(model) > 0)
                    {
                        successcount++;
                    }
                    else
                    {
                        failcount++;
                    }
                }
                catch (Exception)
                {
                    failcount++;
                }
            }
            return(new Dictionary <string, object>
            {
                { "code", "1" },
                { "successcount", successcount },
                { "failcount", failcount },
                { "filename", filename },
                { "count", dr.Length }
            });
        }
コード例 #4
0
        //全国经销商活动场次统计
        public Dictionary <string, object> GetAgencyStatisticsList()
        {
            T_SaleActivityTypeBll typebll     = new T_SaleActivityTypeBll();
            T_AgencyBll           t_agencybll = new T_AgencyBll();
            T_ActivityAreaBll     areabll     = new T_ActivityAreaBll();
            var    arealist   = areabll.GetList();
            var    typelist   = typebll.GetList();
            var    agencylist = t_agencybll.GetList();
            string begintime  = HttpContext.Current.Request.Form["begintime"].ToString();
            string endtime    = HttpContext.Current.Request.Form["endtime"].ToString();
            string areaid     = HttpContext.Current.Request.Form["areaid"].ToString();
            string strwhere   = "IsDelete=0";

            if (!string.IsNullOrEmpty(begintime))
            {
                strwhere += " and ActivityDate>='" + begintime + "'";
            }
            if (!string.IsNullOrEmpty(endtime))
            {
                strwhere += " and ActivityDate<='" + endtime + "'";
            }
            if (!string.IsNullOrEmpty(areaid))
            {
                strwhere += " and saleactivitytypeid=" + areaid;
            }
            else
            {
                strwhere += " and saleactivitytypeid=" + arealist[0];
            }
            string date       = DateTime.Now.Year.ToString() + "-01-01";
            int    indexmonth = DateTime.Now.Month;
            var    listmonth  = new List <int>();

            for (int i = 1; i < indexmonth + 1; i++)
            {
                listmonth.Add(i);
            }
            var database = DataFactory.Database();

            var dsaverage = database.FindDataSetBySql("select DATEPART(month, ActivityDate) as nmonth,agencyid,saleactivitytypeid from T_SaleActivity   where datediff(year, ActivityDate, '" + date + "') = 0 group by AgencyId, DATEPART(month, ActivityDate),SaleActivityTypeId order by DATEPART(month, ActivityDate)");
            List <AgencyStatisticsViewModel> listview = new List <AgencyStatisticsViewModel>();

            foreach (var item in agencylist)
            {
                var model = new AgencyStatisticsViewModel();
                model.AgencyName = item.AgencyName;
                model.AgencyId   = item.AgencyId;
                List <Months> listmonthview = new List <Months>();
                foreach (var item1 in listmonth)
                {
                    var monthview = new Months();
                    monthview.Month = item1.ToString();
                    List <int> listid   = new List <int>();
                    var        dsselect = dsaverage.Tables[0].Select("nmonth=" + item1.ToString() + " and agencyid=" + item.AgencyId + "");
                    foreach (var item2 in dsselect)
                    {
                        if (!listid.Contains(int.Parse(item2["saleactivitytypeid"].ToString())))
                        {
                            listid.Add(int.Parse(item2["saleactivitytypeid"].ToString()));
                        }
                    }
                    monthview.SaleActivityTypeIdList = listid;
                    listmonthview.Add(monthview);
                }
                model.listmonth = listmonthview;


                listview.Add(model);
            }
            return(new Dictionary <string, object>
            {
                { "code", 1 },
                { "typelist", typelist.Select(a => new { saleactivitytypeid = a.SaleActivityTypeId, saleactivitytypename = a.SaleActivityTypeName }) },
                { "agencylist", agencylist.Select(a => new { agencyid = a.AgencyId, agencyname = a.AgencyName }) },
                { "list", listview },
                { "monthlist", listmonth },
                { "arealist", arealist }
            });
        }
コード例 #5
0
        // 经销商活动后续宣传发布统计
        public Dictionary <string, object> GetEveryMonthPublishWayStatistics()
        {
            T_AgencyBll t_agencybll = new T_AgencyBll();
            var         agencylist  = t_agencybll.GetList();
            string      date        = DateTime.Now.Year.ToString() + "-01-01";
            var         database    = DataFactory.Database();
            int         indexmonth  = DateTime.Now.Month;
            var         listmonth   = new List <int>();

            for (int i = 1; i < indexmonth + 1; i++)
            {
                listmonth.Add(i);
            }
            var pubishwaylist = new Utilities.PublishWay().ToSelectListItem();
            var listdic       = new Dictionary <int, object>();
            var dsaverage     = database.FindDataSetBySql("select  DATEPART(month,ActivityDate) as nmonth,PublishWay,AgencyId from T_SaleActivity   where datediff(year,ActivityDate,'" + date + "')=0 group by DATEPART(month,ActivityDate),PublishWay,AgencyId order by DATEPART(month,ActivityDate)");

            foreach (var item in agencylist)
            {
                List <PublishwayStatistics> listway = new List <PublishwayStatistics>();
                foreach (var item1 in listmonth)
                {
                    PublishwayStatistics model = new PublishwayStatistics();
                    var list = new List <int>();
                    model.Month = item1;

                    var result = dsaverage.Tables[0].Select($"AgencyId={item.AgencyId} and nmonth={item1}");
                    foreach (var item2 in result)
                    {
                        var PublishWay      = item2["PublishWay"].ToString();
                        var arraypublishway = PublishWay.Split(',');
                        if (list.Count == pubishwaylist.Count())
                        {
                            break;
                        }
                        else
                        {
                            foreach (var item4 in arraypublishway)
                            {
                                if (!list.Contains(int.Parse(item4)))
                                {
                                    list.Add(int.Parse(item4));
                                }
                            }
                        }
                    }

                    model.Publishwaylist = list;
                    listway.Add(model);
                    //if(result.Where(a=>a["PublishWay"])
                }

                listdic.Add(item.AgencyId, listway);
            }

            return(new Dictionary <string, object>
            {
                { "code", 1 },
                { "agencylist", agencylist.Select(a => new { agencyid = a.AgencyId, agencyname = a.AgencyName }) },
                { "averagelist", listdic },
                { "monthlist", listmonth },
                { "pubishwaylist", pubishwaylist.Select(a => new { pubishwayid = a.Value, pubishwayname = a.Text }) }
            });
        }