Beispiel #1
0
        //Grid数据源
        protected void GridDataBind()
        {
            _reportPersonnelId = Personnel.PersonnelId;
            DateTime?startTime = null, endtime;
            int      reportKind = -1;
            string   reportState = string.Empty, reportNo = string.Empty, reportName = string.Empty;

            if (!string.IsNullOrEmpty(Request.QueryString["IsWarning"]))//预警
            {
                Hid_TimeType.Value = "1";
                endtime            = DateTime.Now.AddDays(-60);
                reportKind         = (int)CostReportKind.Before;
                reportState        = (int)CostReportState.NoAuditing + "," +
                                     (int)CostReportState.InvoiceNoPass + "," +
                                     (int)CostReportState.Auditing + "," +
                                     (int)CostReportState.AuditingNoPass + "," +
                                     (int)CostReportState.AlreadyAuditing + "," +
                                     (int)CostReportState.WaitVerify + "," +
                                     (int)CostReportState.WaitCheck + "," +
                                     (int)CostReportState.Pay;
            }
            else//不是预警,默认查最近一个月的数据
            {
                if (Hid_Search.Value.Equals("1"))//默认显示 申请时间从本月1号至今的数据
                {
                    startTime = endtime = null;
                }
                else
                {
                    startTime = string.IsNullOrEmpty(txt_DateTimeStart.Text) ? DateTime.MinValue : DateTime.Parse(txt_DateTimeStart.Text);
                    endtime   = string.IsNullOrEmpty(txt_DateTimeEnd.Text) ? DateTime.MinValue : DateTime.Parse(txt_DateTimeEnd.Text).AddDays(1);
                }

                if (!string.IsNullOrEmpty(ddl_ReportKind.SelectedValue))
                {
                    reportKind = int.Parse(ddl_ReportKind.SelectedValue);
                }

                #region 设置状态
                if (!string.IsNullOrEmpty(Hid_State.Value))
                {
                    reportState = Hid_State.Value;
                }
                #endregion
            }

            //如果登录人是财务部或者总裁办,则可以看到全部数据
            if (Personnel.BranchId.Equals(new Guid("89706D31-C526-47B8-ABDD-A8BA587D39B1")) || Personnel.BranchId.Equals(new Guid("C365D6E2-22EA-4295-9333-B2476351648A")))
            {
                _reportPersonnelId = Guid.Empty;
            }

            if (!_reportPersonnelId.Equals(Guid.Empty))
            {
                rcb_ReportPersonnel.EmptyMessage = Personnel.RealName;
                rcb_ReportPersonnel.Enabled      = false;
            }
            if (!string.IsNullOrEmpty(txt_ReportNo.Text))
            {
                reportNo = txt_ReportNo.Text.Trim();
            }
            if (!string.IsNullOrEmpty(txt_ReportName.Text))
            {
                reportName = txt_ReportName.Text.Trim();
            }

            var costReportList = _costReport.GetCostReportForWarningsInfos(reportKind, startTime, endtime, _reportPersonnelId, reportState, reportNo, reportName, Hid_TimeType.Value, ddl_BillState.SelectedValue);
            var query          = costReportList.AsQueryable();
            if (!string.IsNullOrEmpty(ddl_AssumeFiliale.SelectedValue))
            {
                query = query.Where(p => p.AssumeFilialeId.Equals(new Guid(ddl_AssumeFiliale.SelectedValue)));
            }
            if (!string.IsNullOrEmpty(rcb_PayBankAccount.SelectedValue))
            {
                query = query.Where(p => p.PayBankAccountId.Equals(new Guid(rcb_PayBankAccount.SelectedValue)));
            }
            if (!string.IsNullOrEmpty(ddl_InvoiceType.SelectedValue))
            {
                query = query.Where(p => p.InvoiceType.Equals(int.Parse(ddl_InvoiceType.SelectedValue)));
            }
            if (!string.IsNullOrEmpty(rcb_ReportPersonnel.SelectedValue) && !rcb_ReportPersonnel.SelectedValue.Equals(Guid.Empty.ToString()))
            {
                query = query.Where(p => p.ReportPersonnelId.Equals(new Guid(rcb_ReportPersonnel.SelectedValue)));
            }
            if (!string.IsNullOrEmpty(ddl_ReportCost.SelectedValue))
            {
                query = query.Where(p => p.ReportCost >= decimal.Parse(ddl_ReportCost.SelectedValue));
            }
            if (!string.IsNullOrEmpty(ddl_ReviewState.SelectedValue))
            {
                query = query.Where(p => p.ReviewState.Equals(int.Parse(ddl_ReviewState.SelectedValue)));
            }
            if (!string.IsNullOrEmpty(ddl_CompanyClass.SelectedValue))
            {
                query = query.Where(p => p.CompanyClassId.Equals(new Guid(ddl_CompanyClass.SelectedValue)));
            }
            if (!string.IsNullOrEmpty(ddl_FeeType.SelectedValue))
            {
                query = query.Where(p => p.CompanyId.Equals(new Guid(ddl_FeeType.SelectedValue)));
            }
            if (!string.IsNullOrEmpty(ddl_PayState.SelectedValue))
            {
                if (ddl_PayState.SelectedValue.Equals("0"))
                {
                    query = query.Where(p => p.PayCost == 0);
                }
                else if (ddl_PayState.SelectedValue.Equals("1"))
                {
                    query = query.Where(p => p.PayCost > 0);
                }
            }

            #region 合计
            var totalName    = RG_Report.MasterTableView.Columns.FindByUniqueName("TotalName");
            var reportCost   = RG_Report.MasterTableView.Columns.FindByUniqueName("ReportCost");
            var applyForCost = RG_Report.MasterTableView.Columns.FindByUniqueName("ApplyForCost");
            var payCost      = RG_Report.MasterTableView.Columns.FindByUniqueName("PayCost");
            if (query.Any())
            {
                var sumReportCost   = query.Sum(p => Math.Abs(p.ReportCost));
                var sumApplyForCost = query.Sum(p => Math.Abs(p.ApplyForCost));
                var sumPayCost      = query.Sum(p => Math.Abs(p.PayCost));
                totalName.FooterText    = "合计:";
                reportCost.FooterText   = string.Format("{0}", ERP.UI.Web.Common.WebControl.NumberSeparator(sumReportCost));
                applyForCost.FooterText = string.Format("{0}", ERP.UI.Web.Common.WebControl.NumberSeparator(sumApplyForCost));
                payCost.FooterText      = string.Format("{0}", ERP.UI.Web.Common.WebControl.NumberSeparator(sumPayCost));
            }
            else
            {
                totalName.FooterText    = string.Empty;
                reportCost.FooterText   = string.Empty;
                applyForCost.FooterText = string.Empty;
                payCost.FooterText      = string.Empty;
            }
            #endregion

            RG_Report.DataSource = query.ToList();
        }