/// <summary>
        /// 统计需调拨订单
        /// </summary>
        /// <param name="pmId"></param>
        /// <param name="starttime"></param>
        /// <param name="endtime"></param>
        /// <param name="warehouseId"></param>
        /// <returns></returns>
        public IList <GoodsOrderInfo> GetAllocationOrdersList(Guid pmId, DateTime starttime, DateTime endtime, Guid warehouseId)
        {
            IList <GoodsOrderInfo> goodsOrderInfos = new List <GoodsOrderInfo>();
            var orderNeedeGoods = _goodsOrderDetail.GetNeedPurchasingGoodses(warehouseId, pmId, starttime, endtime, new List <int> {
                (int)Enum.OrderState.RequirePurchase
            });

            if (orderNeedeGoods.Count > 0)
            {
                var orderBaseList = _goodsOrderDetail.GetGoodsQuantityDics(warehouseId, starttime, endtime, pmId);
                // 获取商品的可用库存
                Dictionary <Guid, int>     stockQuantitys = WMSSao.GetLackQuantity(warehouseId, orderNeedeGoods.Select(ent => ent.RealGoodsId).Distinct());
                List <NeedPurchasingGoods> details        = GetList(orderNeedeGoods, stockQuantitys);
                var orderNos    = details.Select(ent => ent.OrderNo).Distinct();
                var filialeDics = MISService.GetAllFiliales().ToDictionary(k => k.ID, v => v.Name);
                foreach (var order in orderBaseList.Where(ent => orderNos.Contains(ent.OrderNo)))
                {
                    if (goodsOrderInfos.Any(ent => ent.OrderNo == order.OrderNo))
                    {
                        continue;
                    }
                    goodsOrderInfos.Add(new GoodsOrderInfo
                    {
                        OrderNo       = order.OrderNo,
                        Consignee     = order.Consignee,
                        EffectiveTime = order.EffectiveTime,
                        Memo          = filialeDics.ContainsKey(order.SaleFilialeId) ? filialeDics[order.SaleFilialeId] : "",
                        SaleFilialeId = order.SaleFilialeId
                    });
                }
            }
            return(goodsOrderInfos);
        }
        /// <summary>入库仓Changed事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DDLWaerhouse_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            Guid warehouseId = string.IsNullOrEmpty(DDL_Waerhouse.SelectedValue)
               ? Guid.Empty
               : new Guid(DDL_Waerhouse.SelectedValue);

            //绑定入库储
            var list  = new List <StorageAuth>();
            var wlist = CurrentSession.Personnel.WarehouseList;

            if (wlist != null && wlist.Count > 0)
            {
                var warehouse = wlist.FirstOrDefault(act => act.WarehouseId == warehouseId);
                if (warehouse != null && warehouse.Storages != null)
                {
                    list = warehouse.Storages;
                }
            }

            DDL_StorageAuth.DataSource     = list;
            DDL_StorageAuth.DataTextField  = "StorageTypeName";
            DDL_StorageAuth.DataValueField = "StorageType";
            DDL_StorageAuth.DataBind();
            DDL_StorageAuth.Items.Insert(0, new ListItem("请选择", "0"));


            if (list.Count == 1)
            {
                var storage = list.First();
                DDL_StorageAuth.SelectedValue = storage.StorageType.ToString();
                var saleAndHostingFilialeList = MISService.GetAllSaleAndHostingFilialeList();
                DDL_HostingFilialeAuth.DataSource     = saleAndHostingFilialeList;
                DDL_HostingFilialeAuth.DataTextField  = "Name";
                DDL_HostingFilialeAuth.DataValueField = "Id";
                DDL_HostingFilialeAuth.DataBind();
                DDL_HostingFilialeAuth.Items.Insert(0, new ListItem("全部", Guid.Empty.ToString()));

                if (saleAndHostingFilialeList.Count == 1)
                {
                    DDL_HostingFilialeAuth.SelectedValue = saleAndHostingFilialeList.First().ID.ToString();
                    DdlHostingFilialeAuthChanged(MISService.GetAllFiliales().Where(ent => ent.ParentId == saleAndHostingFilialeList.First().ID));
                }
                else
                {
                    DdlHostingFilialeAuthChanged(new List <FilialeInfo>());
                    DDL_HostingFilialeAuth.SelectedValue = Guid.Empty.ToString();
                }
            }
            else
            {
                DDL_StorageAuth.SelectedValue = "0";

                DDL_HostingFilialeAuth.DataSource = new List <HostingFilialeAuth>();
                DDL_HostingFilialeAuth.DataBind();

                DdlHostingFilialeAuthChanged(new List <FilialeInfo>());
            }

            RG_StorageRecord.Rebind();
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         FilialeDic = MISService.GetAllFiliales().Where(act => act.IsActive && (act.FilialeTypes.Contains((int)FilialeType.LogisticsCompany))).ToList();
     }
     RAM.ResponseScripts.Add("removeClass();");
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         var filialeList = MISService.GetAllFiliales();
         ShopList = filialeList.Where(w => w.FilialeTypes.Contains((int)FilialeType.EntityShop) && w.IsActive).ToList();
         BindShopType();
         BindShopList(RcbSaleFiliale, null);
     }
 }
        /// <summary>物流配送公司Changed事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DDLHostingFilialeAuth_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            Guid hostingFilialeId = string.IsNullOrEmpty(DDL_HostingFilialeAuth.SelectedValue)
                  ? Guid.Empty
                  : new Guid(DDL_HostingFilialeAuth.SelectedValue);
            var filialeList = MISService.GetAllFiliales().ToList();

            DdlHostingFilialeAuthChanged(hostingFilialeId != Guid.Empty ? filialeList.Where(act => act.ParentId == hostingFilialeId) : new List <FilialeInfo>());
            RG_StorageRecord.Rebind();
        }
        private void RecursivelyFiliale(RadTreeNode node)
        {
            var filialeList = MISService.GetAllFiliales().Where(act => act.IsActive && act.ID != new Guid(DdlSaleFiliale.SelectedItem.Value) && (act.FilialeTypes.Contains((int)FilialeType.SaleCompany) || act.FilialeTypes.Contains((int)FilialeType.LogisticsCompany))).ToList();

            foreach (FilialeInfo info in filialeList)
            {
                RadTreeNode childNode = CreateNode(info.Name, "HostingCompany", false, info.ID.ToString());
                childNode.PostBack = true;
                node.Nodes.Add(childNode);
            }
        }
        /// <summary>入库储Changed事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DDLStorageAuth_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            //仓库id
            Guid warehouseId = string.IsNullOrEmpty(DDL_Waerhouse.SelectedValue)
                ? Guid.Empty
                : new Guid(DDL_Waerhouse.SelectedValue);
            //储位id
            byte storageType = string.IsNullOrEmpty(DDL_StorageAuth.SelectedValue)
                ? default(byte)
                : byte.Parse(DDL_StorageAuth.SelectedValue);

            //绑定物流配送公司
            var list  = new List <HostingFilialeAuth>();
            var wlist = CurrentSession.Personnel.WarehouseList;

            if (wlist != null && wlist.Count > 0)
            {
                var warehouse = wlist.FirstOrDefault(act => act.WarehouseId == warehouseId);
                if (warehouse != null && warehouse.Storages != null)
                {
                    var storageTypeAuth = warehouse.Storages.FirstOrDefault(p => p.StorageType == storageType);
                    if (storageTypeAuth != null && storageTypeAuth.Filiales != null)
                    {
                        list.AddRange(storageTypeAuth.Filiales);
                    }
                }
            }

            var saleAndHostingFilialeList = MISService.GetAllSaleAndHostingFilialeList();

            DDL_HostingFilialeAuth.DataSource     = saleAndHostingFilialeList;
            DDL_HostingFilialeAuth.DataTextField  = "Name";
            DDL_HostingFilialeAuth.DataValueField = "Id";
            DDL_HostingFilialeAuth.DataBind();
            DDL_HostingFilialeAuth.Items.Insert(0, new ListItem("全部", Guid.Empty.ToString()));
            DDL_HostingFilialeAuth.SelectedValue = Guid.Empty.ToString();

            var filialeList = MISService.GetAllFiliales().ToList();
            var dataFiliale = new List <FilialeInfo>();

            foreach (var filialeId in list)
            {
                dataFiliale.AddRange(filialeList.Where(w => w.ParentId == filialeId.HostingFilialeId));
            }

            DdlHostingFilialeAuthChanged(dataFiliale);

            RG_StorageRecord.Rebind();
        }
        /// <summary>
        /// 物流配送公司
        /// </summary>
        private void HostingFiliale()
        {
            var filiales = MISService.GetAllFiliales().Where(act => act.IsActive && (act.FilialeTypes.Contains((int)FilialeType.LogisticsCompany)) || act.FilialeTypes.Contains((int)FilialeType.SaleCompany)).ToList();
            var list     = filiales.Select(filiale => new HostingFilialeAuth
            {
                HostingFilialeId   = filiale.ID,
                HostingFilialeName = filiale.Name
            }).ToList();

            DDL_HostingFilialeAuth.DataSource     = list;
            DDL_HostingFilialeAuth.DataTextField  = "HostingFilialeName";
            DDL_HostingFilialeAuth.DataValueField = "HostingFilialeId";
            DDL_HostingFilialeAuth.DataBind();
            DDL_HostingFilialeAuth.Items.Insert(0, new ListItem("", ""));
        }
Beispiel #9
0
        /// <summary>
        /// 获取公司名称
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        protected string GetCompanyName(string id)
        {
            var companyInfo = CompanyList.FirstOrDefault(c => c.CompanyId == new Guid(id));

            if (companyInfo != null)
            {
                return(companyInfo.CompanyName);
            }
            var filialeInfo = MISService.GetAllFiliales().FirstOrDefault(act => act.ID == new Guid(id));

            if (filialeInfo != null)
            {
                return(filialeInfo.Name);
            }
            return(string.Empty);
        }
        /// <summary>
        /// 绑定入库仓储
        /// </summary>
        private void BindWarehouse()
        {
            var wList = CurrentSession.Personnel.WarehouseList;

            DDL_Waerhouse.DataSource     = wList;
            DDL_Waerhouse.DataTextField  = "WarehouseName";
            DDL_Waerhouse.DataValueField = "WarehouseId";
            DDL_Waerhouse.DataBind();
            DDL_Waerhouse.Items.Insert(0, new ListItem("请选择", Guid.Empty.ToString()));
            Guid selectWarehouseId = Guid.Empty;

            if (wList.Count == 1)
            {
                var warehouse = wList.First();
                selectWarehouseId = warehouse.WarehouseId;

                if (warehouse.Storages.Count == 1)
                {
                    var storage = warehouse.Storages.First();
                    DDL_StorageAuth.DataSource     = warehouse.Storages;
                    DDL_StorageAuth.DataTextField  = "StorageTypeName";
                    DDL_StorageAuth.DataValueField = "StorageType";
                    DDL_StorageAuth.DataBind();
                    DDL_StorageAuth.Items.Insert(0, new ListItem("请选择", "0"));
                    DDL_StorageAuth.SelectedValue = storage.StorageType.ToString();

                    var saleAndHostingFilialeList = MISService.GetAllSaleAndHostingFilialeList();
                    DDL_HostingFilialeAuth.DataSource     = saleAndHostingFilialeList;
                    DDL_HostingFilialeAuth.DataTextField  = "Name";
                    DDL_HostingFilialeAuth.DataValueField = "Id";
                    DDL_HostingFilialeAuth.DataBind();
                    DDL_HostingFilialeAuth.Items.Insert(0, new ListItem("全部", Guid.Empty.ToString()));
                    DDL_HostingFilialeAuth.SelectedValue = saleAndHostingFilialeList.Count == 1 ? saleAndHostingFilialeList.First().ID.ToString() : Guid.Empty.ToString();

                    if (saleAndHostingFilialeList.Count == 1)
                    {
                        var filiales = MISService.GetAllFiliales()
                                       .Where(ent => ent.ParentId == saleAndHostingFilialeList.First().ID);
                        DdlHostingFilialeAuthChanged(filiales);
                    }
                }
            }

            DDL_Waerhouse.SelectedValue = selectWarehouseId.ToString();
        }
        //Grid数据源
        protected void GridDataBind()
        {
            var states = new List <int>();

            switch (ddl_State.SelectedValue)
            {
            case "0":     //已处理
                states.Add((int)CostReportState.AlreadyAuditing);
                states.Add((int)CostReportState.WaitVerify);
                states.Add((int)CostReportState.NoAuditing);
                break;

            case "1":     //未处理
                states.Add((int)CostReportState.Auditing);
                break;
            }

            var costReportList = _costReport.GetReportList(states);
            var query          = costReportList.AsQueryable();

            #region 查询条件
            if (!string.IsNullOrEmpty(txt_ReportNo.Text))
            {
                query = query.Where(p => p.ReportNo.Equals(txt_ReportNo.Text.Trim()));
            }

            if (Hid_TimeType.Value.Equals("1"))
            {
                if (!string.IsNullOrEmpty(txt_DateTimeStart.Text))
                {
                    var startTime = DateTime.Parse(txt_DateTimeStart.Text);
                    query = query.Where(p => p.ReportDate >= startTime);
                }
                if (!string.IsNullOrEmpty(txt_DateTimeEnd.Text))
                {
                    var endtime = DateTime.Parse(txt_DateTimeEnd.Text);
                    query = query.Where(p => p.ReportDate < endtime.AddDays(1));
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(txt_DateTimeStart.Text))
                {
                    var startTime = DateTime.Parse(txt_DateTimeStart.Text);
                    query = query.Where(p => p.AuditingDate >= startTime);
                }
                if (!string.IsNullOrEmpty(txt_DateTimeEnd.Text))
                {
                    var endtime = DateTime.Parse(txt_DateTimeEnd.Text);
                    query = query.Where(p => p.AuditingDate < endtime.AddDays(1));
                }
            }
            if (!string.IsNullOrEmpty(txt_ReportName.Text))
            {
                query = query.Where(p => p.ReportName.Contains(txt_ReportName.Text.Trim()));
            }
            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(txt_ReportCostStart.Text))
            {
                query = query.Where(p => p.ReportCost >= decimal.Parse(txt_ReportCostStart.Text));
            }
            if (!string.IsNullOrEmpty(txt_ReportCostEnd.Text))
            {
                query = query.Where(p => p.ReportCost <= decimal.Parse(txt_ReportCostEnd.Text));
            }
            if (!string.IsNullOrEmpty(ddl_AssumeFiliale.SelectedValue))
            {
                query = query.Where(p => p.AssumeFilialeId.Equals(new Guid(ddl_AssumeFiliale.SelectedValue)));
            }
            query = query.Where(p => p.UrgentOrDefer.Equals(int.Parse(rbl_UrgentOrDefer.SelectedValue)));
            #endregion

            #region 获取权限数据集

            #region 获取数据集中所有申报人的部门集合
            var reportPersonnelIdList = query.Select(act => act.ReportPersonnelId).Distinct().ToList();
            var branchIds             = MISService.GetBranchIdsByPersonnelIds(reportPersonnelIdList);
            #endregion

            #region 费用申报审批权限
            var costReportAuditingList = _costReportAuditingPower.GetCanAuditingInfo(Personnel.FilialeId, Personnel.BranchId, Personnel.PositionId).Where(p => p.Kind == (int)CostReportAuditingType.Auditing);
            #endregion

            foreach (CostReportAuditingInfo info in costReportAuditingList)
            {
                //筛选该部门中在相应“审批金额范围”内的数据
                var branchAuditingList = query.Where(p => info.MinAmount <= p.ReportCost + p.PayCost && p.ReportCost + p.PayCost <= info.MaxAmount).ToList();
                foreach (var item in branchAuditingList)
                {
                    //此筛选条件没有放到where中的原因:因为有些用户缺少部门信息,所以有些“ReportPersonnelId”在branchIds中不存在,如果放到where中筛选会报错
                    if (branchIds.ContainsKey(item.ReportPersonnelId) && info.ReportBranchId.Contains(branchIds[item.ReportPersonnelId].ToString()))
                    {
                        if (ReportList.Count(p => p.ReportId.Equals(item.ReportId)).Equals(0))
                        {
                            ReportList.Add(item);
                        }
                    }
                }
            }
            #endregion

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

            RG_Report.DataSource = query.OrderByDescending(r => r.ReportDate).ToList();
        }
Beispiel #12
0
 /// <summary>
 /// 获取所有公司
 /// </summary>
 /// <returns></returns>
 public static IList <FilialeInfo> GetList()
 {
     //公司信息不缓存
     //return CacheHelper.Get(Key.FilialeList, MISService.GetAllFiliales).ToList();
     return(MISService.GetAllFiliales().Where(ent => ent.IsActive).ToList());
 }
Beispiel #13
0
 /// <summary>
 /// 获取所有部门
 /// </summary>
 /// <returns></returns>
 public static IList <BranchInfo> GetList()
 {
     //return CacheHelper.Get(Key.BranchList, MISService.GetAllBranch).ToList();
     return(MISService.GetAllBranch().ToList());
 }
Beispiel #14
0
 /// <summary>
 /// 获取所有销售平台
 /// </summary>
 /// <returns></returns>
 public static IList <SalePlatformInfo> GetList()
 {
     //return CacheHelper.Get(Key.SalePlatformList, MISService.GetAllSalePlatform).ToList();
     return(MISService.GetAllSalePlatform().ToList());
 }
Beispiel #15
0
        /// <summary>
        /// 往来收付款 ItemDataBound 事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void RG_ReceiptGridList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                var griditem = e.Item as GridDataItem;
                var info     = e.Item.DataItem as CompanyFundReceiptInfo;
                if (info == null)
                {
                    return;
                }
                var imgBtnCancel = griditem.FindControl("ImgBtn_LoseReceipt") as ImageButton;
                if (imgBtnCancel == null)
                {
                    return;
                }
                var btnEdit = griditem.FindControl("btn_Edit") as Button;
                var btnLook = griditem.FindControl("btn_Look") as Button;
                if (btnEdit == null)
                {
                    return;
                }
                if (btnLook == null)
                {
                    return;
                }
                if (info.ReceiptStatus == (int)CompanyFundReceiptState.WaitAuditing || info.ReceiptStatus == (int)CompanyFundReceiptState.NoAuditing || info.ReceiptStatus == (int)CompanyFundReceiptState.NoAuditingPass)
                {
                    if (info.ReceiptType == (int)CompanyFundReceiptType.Receive && (info.ReceiptStatus == (int)CompanyFundReceiptState.NoAuditing || info.ReceiptStatus == (int)CompanyFundReceiptState.NoAuditingPass))
                    {
                        btnEdit.Visible = false;
                    }
                    else
                    {
                        btnEdit.Visible = true;
                    }
                    imgBtnCancel.Visible = true;
                    btnLook.Visible      = false;
                }
                else
                {
                    imgBtnCancel.Visible = false;
                    btnEdit.Visible      = false;
                    btnLook.Visible      = true;

                    if (info.ReceiptType == (int)CompanyFundReceiptType.Receive)
                    {
                        if (info.HasInvoice && info.ReceiptStatus == (int)CompanyFundReceiptState.WaitInvoice)
                        {
                            imgBtnCancel.Visible = true;
                            btnEdit.Visible      = true;
                            btnLook.Visible      = false;
                        }
                        else if (!info.HasInvoice && info.ReceiptStatus == (int)CompanyFundReceiptState.Audited)
                        {
                            imgBtnCancel.Visible = true;
                            btnEdit.Visible      = true;
                            btnLook.Visible      = false;
                        }
                    }
                }
                if (MISService.GetAllFiliales().Any(act => act.ID == info.CompanyID && act.FilialeTypes.Contains((int)FilialeType.EntityShop)))
                {
                    imgBtnCancel.Visible = false;
                    btnEdit.Visible      = false;
                    btnLook.Visible      = true;
                }
            }
        }
        //Grid数据源
        protected void GridDataBind()
        {
            var states = new List <int>();

            switch (ddl_State.SelectedValue)
            {
            case "0":     //已处理
                states.Add((int)CostReportState.AlreadyAuditing);
                states.Add((int)CostReportState.CompletedMayApply);
                //states.Add((int)CostReportState.Auditing);
                states.Add((int)CostReportState.WaitVerify);
                states.Add((int)CostReportState.Complete);
                break;

            case "1":     //未处理
                states.Add((int)CostReportState.NoAuditing);
                break;
            }
            var costReportList = _costReport.GetReportList(states);
            var query          = costReportList.AsQueryable();

            #region 查询条件
            if (!string.IsNullOrEmpty(txt_ReportNo.Text))
            {
                query = query.Where(p => p.ReportNo.Equals(txt_ReportNo.Text.Trim()));
            }
            if (Hid_TimeType.Value.Equals("1"))
            {
                if (!string.IsNullOrEmpty(txt_DateTimeStart.Text))
                {
                    var startTime = DateTime.Parse(txt_DateTimeStart.Text);
                    query = query.Where(p => p.ReportDate >= startTime);
                }
                if (!string.IsNullOrEmpty(txt_DateTimeEnd.Text))
                {
                    var endtime = DateTime.Parse(txt_DateTimeEnd.Text);
                    query = query.Where(p => p.ReportDate < endtime.AddDays(1));
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(txt_DateTimeStart.Text))
                {
                    var startTime = DateTime.Parse(txt_DateTimeStart.Text);
                    query = query.Where(p => p.AcceptDate >= startTime);
                }
                if (!string.IsNullOrEmpty(txt_DateTimeEnd.Text))
                {
                    var endtime = DateTime.Parse(txt_DateTimeEnd.Text);
                    query = query.Where(p => p.AcceptDate < endtime.AddDays(1));
                }
            }
            if (!string.IsNullOrEmpty(txt_ReportName.Text))
            {
                query = query.Where(p => p.ReportName.Contains(txt_ReportName.Text.Trim()));
            }
            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(txt_InvoiceAndReceiptNo.Text))
            {
                query = query.Where(p => p.InvoiceNo.Equals(txt_InvoiceAndReceiptNo.Text) || p.ReceiptNo.Equals(txt_InvoiceAndReceiptNo.Text));
            }
            if (!string.IsNullOrEmpty(ddl_AssumeFiliale.SelectedValue))
            {
                query = query.Where(p => p.AssumeFilialeId.Equals(new Guid(ddl_AssumeFiliale.SelectedValue)));
            }
            if (!string.IsNullOrEmpty(ddl_ReportKind.SelectedValue))
            {
                query = query.Where(p => p.ReportKind.Equals(int.Parse(ddl_ReportKind.SelectedValue)));
            }
            query = query.Where(p => p.InvoiceType.Equals((int)CostReportInvoiceType.Invoice) || p.InvoiceType.Equals((int)CostReportInvoiceType.VatInvoice) || p.InvoiceType.Equals((int)CostReportInvoiceType.Voucher));
            #endregion

            #region 获取权限数据集

            #region 获取数据集中所有申报人的部门集合
            var reportPersonnelIdList = query.Select(act => act.ReportPersonnelId).Distinct().ToList();
            var branchIds             = MISService.GetBranchIdsByPersonnelIds(reportPersonnelIdList);
            #endregion

            #region 费用申报受理权限
            var costReportAuditingList = _costReportAuditingPower.GetCanAuditingInfo(Personnel.FilialeId, Personnel.BranchId, Personnel.PositionId).Where(p => p.Kind == (int)CostReportAuditingType.Invoice);
            #endregion

            foreach (CostReportAuditingInfo info in costReportAuditingList)
            {
                foreach (var item in query)
                {
                    if (branchIds.ContainsKey(item.ReportPersonnelId) && info.ReportBranchId.Contains(branchIds[item.ReportPersonnelId].ToString()))
                    {
                        if (ReportList.Count(p => p.ReportId.Equals(item.ReportId)).Equals(0))
                        {
                            ReportList.Add(item);
                        }
                    }
                }
            }
            #endregion

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

            RG_Report.DataSource = query.OrderByDescending(r => r.ReportDate).ToList();
        }