コード例 #1
0
        //导出
        protected void btnDaochu_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    if (string.IsNullOrEmpty(txtBeginDate.Value.Trim()) || string.IsNullOrEmpty(txtEndDate.Value.Trim()))
                    {
                        base.ShowMessage("请输入开始日期和结束日期!");
                        return;
                    }

                    if (!string.IsNullOrEmpty(txtBeginDate.Value.Trim()))
                    {
                        if (string.IsNullOrEmpty(txtEndDate.Value.Trim()))
                        {
                            base.ShowMessage("请输入结束日期!");
                            return;
                        }
                    }

                    if (!string.IsNullOrEmpty(txtEndDate.Value.Trim()))
                    {
                        if (string.IsNullOrEmpty(txtBeginDate.Value.Trim()))
                        {
                            base.ShowMessage("请输入开始日期!");
                            return;
                        }
                    }

                    if (!string.IsNullOrEmpty(txtBeginDate.Value.Trim()) &&
                        !string.IsNullOrEmpty(txtEndDate.Value.Trim()))
                    {
                        DateTime dt = new DateTime();
                        if (!DateTime.TryParse(txtBeginDate.Value.Trim(), out dt))
                        {
                            base.ShowMessage("开始日期输入错误!");
                            return;
                        }
                        if (!DateTime.TryParse(txtEndDate.Value.Trim(), out dt))
                        {
                            base.ShowMessage("结束日期输入错误!");
                            return;
                        }

                        if (DateTime.Parse(txtEndDate.Value.Trim()) < DateTime.Parse(txtBeginDate.Value.Trim()))
                        {
                            base.ShowMessage("结束日期不能小于开始日期!");
                            return;
                        }
                    }
                    var        PlatformId = int.Parse(this.ddlPlatform.SelectedValue);
                    var        NickId     = int.Parse(this.ddlNick.SelectedValue);
                    var        BeginDate  = this.txtBeginDate.Value;
                    var        EndDate    = this.txtEndDate.Value;
                    int        CustomerId = Convert.ToInt16(this.ddlCustomerService.SelectedValue);
                    int        GroupID    = Convert.ToInt16(this.ddlGroupID.SelectedValue);
                    var        xMNickList = base.XMNickService.GetXMProjectListSS(HozestERPContext.Current.User.CustomerID, 0);
                    List <int> a          = new List <int> {
                    };
                    if (NickId == -2 || NickId == -1)
                    {
                        foreach (var list in xMNickList)
                        {
                            a.Add(list.nick_id);
                        }
                    }
                    else
                    {
                        a.Add(NickId);
                    }
                    string DepCode = "QC1403-3,QC1403-4,QC1506-2,QC1403-1,QC1403-2,QC1506-1";
                    //根据条件查询客服信息
                    var xMCustomerList = base.CustomerInfoService.GetCustomerSaleAcount(GroupID, CustomerId, DepCode);
                    List <HozestERP.BusinessLogic.ManageCustomerService.XMCustomerSaleAcountAnalysis> info = new List <HozestERP.BusinessLogic.ManageCustomerService.XMCustomerSaleAcountAnalysis>();
                    if (xMCustomerList != null && xMCustomerList.Count > 0)
                    {
                        foreach (HozestERP.BusinessLogic.ManageCustomerService.XMCustomerSaleAcountAnalysis p in xMCustomerList)
                        {
                            if (p.CustomerID != null)
                            {
                                List <XMOrderInfo> List = base.XMOrderInfoService.GetCustomerSaleMoneyParm(p.CustomerID.Value, DateTime.Parse(BeginDate), DateTime.Parse(EndDate), PlatformId, a);
                                HozestERP.BusinessLogic.ManageCustomerService.XMCustomerSaleAcountAnalysis m = new BusinessLogic.ManageCustomerService.XMCustomerSaleAcountAnalysis();
                                m.Group = p.Group;
                                m.Name  = p.Name;
                                if (List != null && List.Count > 0)
                                {
                                    m.DealCount = List.Count();
                                    m.DealMoney = List.Sum(n => n.PayPrice);
                                }
                                else
                                {
                                    m.DealCount = 0;
                                    m.DealMoney = 0;
                                }
                                info.Add(m);
                            }
                        }
                    }

                    //导出存放路径
                    string fileName = string.Format("Exports_{0}_{1}.xls", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"), CommonHelper.GenerateRandomDigitCode(4));
                    string filePath = string.Format("{0}Upload\\CustomerSaleMoneyExport", HttpContext.Current.Request.PhysicalApplicationPath);
                    if (Directory.Exists(filePath) == false)//如果不存在就创建file文件夹
                    {
                        Directory.CreateDirectory(filePath);
                    }
                    filePath = filePath + "//" + fileName;

                    base.ExportManager.ExportCustomerSaleAnalysisToXls(filePath, info);
                    CommonHelper.WriteResponseXls(filePath, fileName);
                }


                catch (Exception exc)
                {
                    ProcessException(exc);
                }
            }
        }
コード例 #2
0
        public void BindGrid(int paramPageIndex, int paramPageSize, string sortExpression, string sortDirection)
        {
            var        PlatformId = int.Parse(this.ddlPlatform.SelectedValue);
            var        NickId     = int.Parse(this.ddlNick.SelectedValue);
            var        BeginDate  = this.txtBeginDate.Value;
            var        EndDate    = this.txtEndDate.Value;
            int        CustomerId = Convert.ToInt16(this.ddlCustomerService.SelectedValue);
            int        GroupID    = Convert.ToInt16(this.ddlGroupID.SelectedValue);
            var        xMNickList = base.XMNickService.GetXMProjectListSS(HozestERPContext.Current.User.CustomerID, 0);
            List <int> a          = new List <int> {
            };

            if (NickId == -2 || NickId == -1)
            {
                foreach (var list in xMNickList)
                {
                    a.Add(list.nick_id);
                }
            }
            else
            {
                a.Add(NickId);
            }
            string DepCode = "QC1403-3,QC1403-4,QC1506-2,QC1403-1,QC1403-2,QC1506-1";
            //根据条件查询客服信息
            var xMCustomerList = base.CustomerInfoService.GetCustomerSaleAcount(GroupID, CustomerId, DepCode);
            List <HozestERP.BusinessLogic.ManageCustomerService.XMCustomerSaleAcountAnalysis> info = new List <HozestERP.BusinessLogic.ManageCustomerService.XMCustomerSaleAcountAnalysis>();

            if (xMCustomerList != null && xMCustomerList.Count > 0)
            {
                foreach (HozestERP.BusinessLogic.ManageCustomerService.XMCustomerSaleAcountAnalysis p in xMCustomerList)
                {
                    if (p.CustomerID != null)
                    {
                        List <XMOrderInfo> List = base.XMOrderInfoService.GetCustomerSaleMoneyParm(p.CustomerID.Value, DateTime.Parse(BeginDate), DateTime.Parse(EndDate), PlatformId, a);
                        HozestERP.BusinessLogic.ManageCustomerService.XMCustomerSaleAcountAnalysis m = new BusinessLogic.ManageCustomerService.XMCustomerSaleAcountAnalysis();
                        m.Group = p.Group;
                        m.Name  = p.Name;
                        if (List != null && List.Count > 0)
                        {
                            m.DealCount = List.Count();
                            m.DealMoney = List.Sum(n => n.PayPrice);
                        }
                        else
                        {
                            m.DealCount = 0;
                            m.DealMoney = 0;
                        }
                        info.Add(m);
                    }
                }
            }

            var pageList = new PagedList <HozestERP.BusinessLogic.ManageCustomerService.XMCustomerSaleAcountAnalysis>(info, paramPageIndex, paramPageSize, this.Master.GridViewSortField, this.Master.GridViewSortDir.ToString());

            this.Master.BindData(this.grdvClients, pageList, paramPageSize + 1);
        }