/// <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();
        }
        /// <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();
        }
Exemplo n.º 3
0
        /// <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("", ""));
        }
        /// <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();
        }