Esempio n. 1
0
        public IEnumerable <Store> GetStoreFilter(StoreFilter storeFilter)
        {
            var storeName = "Proc_GetStoreFilter";
            var stores    = dbConnection.Query <Store>(storeName, storeFilter, commandType: CommandType.StoredProcedure);

            return(stores);
        }
Esempio n. 2
0
        private static Expression <Func <Store, bool> > Filter(StoreFilter filter)
        {
            var query = PredicateBuilder.True <Store>();

            if (filter != null)
            {
                if (!String.IsNullOrWhiteSpace(filter.NamePrefix))
                {
                    query = PredicateBuilder.And(query, v => v.Name.StartsWith(filter.NamePrefix));
                }

                if (filter.Status != null)
                {
                    query = PredicateBuilder.And(query, v => v.Status == filter.Status.Value);
                }
                else
                {
                    query = PredicateBuilder.And(query, v => v.Status > 0);
                }

                if (filter.DataStoreIds != null)
                {
                    query = PredicateBuilder.And(query, v => filter.DataStoreIds.Contains(v.Id));
                }
            }

            return(query);
        }
Esempio n. 3
0
        public ServiceResult GetStorePaging(int pageSize, int pageIndex, StoreFilter storeFilter)
        {
            serviceResult.isSuccess = true;
            var stores = _storeRepository.GetStorePaging(pageSize, pageIndex, storeFilter);

            serviceResult.data = stores;
            return(serviceResult);
        }
Esempio n. 4
0
        private void BindFilter()
        {
            DropDownListFilter.DataSource     = StoreFilter.GetStoreFilterList(this.companyId);
            DropDownListFilter.DataTextField  = "Filter";
            DropDownListFilter.DataValueField = "Filter";
            DropDownListFilter.DataBind();

            DropDownListFilter.Items.Insert(0, new ListItem("All", "All"));
        }
Esempio n. 5
0
        public async Task <List <Store_StoreDTO> > SingleListStore([FromBody] Store_StoreFilterDTO Store_StoreFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            StoreFilter StoreFilter = new StoreFilter();

            StoreFilter.Skip              = 0;
            StoreFilter.Take              = 20;
            StoreFilter.OrderBy           = StoreOrder.Id;
            StoreFilter.OrderType         = OrderType.ASC;
            StoreFilter.Selects           = StoreSelect.ALL;
            StoreFilter.Id                = Store_StoreFilterDTO.Id;
            StoreFilter.Code              = Store_StoreFilterDTO.Code;
            StoreFilter.CodeDraft         = Store_StoreFilterDTO.CodeDraft;
            StoreFilter.Name              = Store_StoreFilterDTO.Name;
            StoreFilter.UnsignName        = Store_StoreFilterDTO.UnsignName;
            StoreFilter.ParentStoreId     = Store_StoreFilterDTO.ParentStoreId;
            StoreFilter.OrganizationId    = Store_StoreFilterDTO.OrganizationId;
            StoreFilter.StoreTypeId       = Store_StoreFilterDTO.StoreTypeId;
            StoreFilter.StoreGroupingId   = Store_StoreFilterDTO.StoreGroupingId;
            StoreFilter.Telephone         = Store_StoreFilterDTO.Telephone;
            StoreFilter.ProvinceId        = Store_StoreFilterDTO.ProvinceId;
            StoreFilter.DistrictId        = Store_StoreFilterDTO.DistrictId;
            StoreFilter.WardId            = Store_StoreFilterDTO.WardId;
            StoreFilter.Address           = Store_StoreFilterDTO.Address;
            StoreFilter.UnsignAddress     = Store_StoreFilterDTO.UnsignAddress;
            StoreFilter.DeliveryAddress   = Store_StoreFilterDTO.DeliveryAddress;
            StoreFilter.Latitude          = Store_StoreFilterDTO.Latitude;
            StoreFilter.Longitude         = Store_StoreFilterDTO.Longitude;
            StoreFilter.DeliveryLatitude  = Store_StoreFilterDTO.DeliveryLatitude;
            StoreFilter.DeliveryLongitude = Store_StoreFilterDTO.DeliveryLongitude;
            StoreFilter.OwnerName         = Store_StoreFilterDTO.OwnerName;
            StoreFilter.OwnerPhone        = Store_StoreFilterDTO.OwnerPhone;
            StoreFilter.OwnerEmail        = Store_StoreFilterDTO.OwnerEmail;
            StoreFilter.TaxCode           = Store_StoreFilterDTO.TaxCode;
            StoreFilter.LegalEntity       = Store_StoreFilterDTO.LegalEntity;
            StoreFilter.AppUserId         = Store_StoreFilterDTO.AppUserId;
            StoreFilter.StatusId          = Store_StoreFilterDTO.StatusId;
            StoreFilter.StoreStatusId     = Store_StoreFilterDTO.StoreStatusId;
            StoreFilter.CustomerId        = Store_StoreFilterDTO.CustomerId;

            if (StoreFilter.Id == null)
            {
                StoreFilter.Id = new IdFilter();
            }
            StoreFilter.Id.In = await FilterStore(StoreService, OrganizationService, CurrentContext);

            List <Store> Stores = await StoreService.List(StoreFilter);

            List <Store_StoreDTO> Store_StoreDTOs = Stores
                                                    .Select(x => new Store_StoreDTO(x)).ToList();

            return(Store_StoreDTOs);
        }
Esempio n. 6
0
        public async Task <ActionResult <List <Customer_StoreDTO> > > ListStore([FromBody] Customer_StoreFilterDTO Customer_StoreFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            StoreFilter StoreFilter = new StoreFilter();

            StoreFilter.Skip              = Customer_StoreFilterDTO.Skip;
            StoreFilter.Take              = Customer_StoreFilterDTO.Take;
            StoreFilter.OrderBy           = StoreOrder.Id;
            StoreFilter.OrderType         = OrderType.ASC;
            StoreFilter.Selects           = StoreSelect.ALL;
            StoreFilter.Id                = Customer_StoreFilterDTO.Id;
            StoreFilter.Code              = Customer_StoreFilterDTO.Code;
            StoreFilter.CodeDraft         = Customer_StoreFilterDTO.CodeDraft;
            StoreFilter.Name              = Customer_StoreFilterDTO.Name;
            StoreFilter.UnsignName        = Customer_StoreFilterDTO.UnsignName;
            StoreFilter.ParentStoreId     = Customer_StoreFilterDTO.ParentStoreId;
            StoreFilter.OrganizationId    = Customer_StoreFilterDTO.OrganizationId;
            StoreFilter.StoreTypeId       = Customer_StoreFilterDTO.StoreTypeId;
            StoreFilter.StoreGroupingId   = Customer_StoreFilterDTO.StoreGroupingId;
            StoreFilter.Telephone         = Customer_StoreFilterDTO.Telephone;
            StoreFilter.ProvinceId        = Customer_StoreFilterDTO.ProvinceId;
            StoreFilter.DistrictId        = Customer_StoreFilterDTO.DistrictId;
            StoreFilter.WardId            = Customer_StoreFilterDTO.WardId;
            StoreFilter.Address           = Customer_StoreFilterDTO.Address;
            StoreFilter.UnsignAddress     = Customer_StoreFilterDTO.UnsignAddress;
            StoreFilter.DeliveryAddress   = Customer_StoreFilterDTO.DeliveryAddress;
            StoreFilter.Latitude          = Customer_StoreFilterDTO.Latitude;
            StoreFilter.Longitude         = Customer_StoreFilterDTO.Longitude;
            StoreFilter.DeliveryLatitude  = Customer_StoreFilterDTO.DeliveryLatitude;
            StoreFilter.DeliveryLongitude = Customer_StoreFilterDTO.DeliveryLongitude;
            StoreFilter.OwnerName         = Customer_StoreFilterDTO.OwnerName;
            StoreFilter.OwnerPhone        = Customer_StoreFilterDTO.OwnerPhone;
            StoreFilter.OwnerEmail        = Customer_StoreFilterDTO.OwnerEmail;
            StoreFilter.TaxCode           = Customer_StoreFilterDTO.TaxCode;
            StoreFilter.LegalEntity       = Customer_StoreFilterDTO.LegalEntity;
            StoreFilter.AppUserId         = Customer_StoreFilterDTO.AppUserId;
            StoreFilter.StatusId          = Customer_StoreFilterDTO.StatusId;
            StoreFilter.StoreStatusId     = Customer_StoreFilterDTO.StoreStatusId;
            StoreFilter.CustomerId        = Customer_StoreFilterDTO.CustomerId;
            StoreFilter.isSelected        = Customer_StoreFilterDTO.isSelected;

            List <Store> Stores = await StoreService.List(StoreFilter);

            List <Customer_StoreDTO> Customer_StoreDTOs = Stores
                                                          .Select(x => new Customer_StoreDTO(x)).ToList();

            return(Customer_StoreDTOs);
        }
Esempio n. 7
0
        public async Task <ActionResult <List <DirectSalesOrder_StoreDTO> > > FilterListStore([FromBody] DirectSalesOrder_StoreFilterDTO DirectSalesOrder_StoreFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            StoreFilter StoreFilter = new StoreFilter();

            StoreFilter.Skip              = 0;
            StoreFilter.Take              = 20;
            StoreFilter.OrderBy           = StoreOrder.Id;
            StoreFilter.OrderType         = OrderType.ASC;
            StoreFilter.Selects           = StoreSelect.ALL;
            StoreFilter.Id                = DirectSalesOrder_StoreFilterDTO.Id;
            StoreFilter.Code              = DirectSalesOrder_StoreFilterDTO.Code;
            StoreFilter.CodeDraft         = DirectSalesOrder_StoreFilterDTO.CodeDraft;
            StoreFilter.Name              = DirectSalesOrder_StoreFilterDTO.Name;
            StoreFilter.ParentStoreId     = DirectSalesOrder_StoreFilterDTO.ParentStoreId;
            StoreFilter.OrganizationId    = DirectSalesOrder_StoreFilterDTO.OrganizationId;
            StoreFilter.StoreTypeId       = DirectSalesOrder_StoreFilterDTO.StoreTypeId;
            StoreFilter.StoreGroupingId   = DirectSalesOrder_StoreFilterDTO.StoreGroupingId;
            StoreFilter.Telephone         = DirectSalesOrder_StoreFilterDTO.Telephone;
            StoreFilter.ProvinceId        = DirectSalesOrder_StoreFilterDTO.ProvinceId;
            StoreFilter.DistrictId        = DirectSalesOrder_StoreFilterDTO.DistrictId;
            StoreFilter.WardId            = DirectSalesOrder_StoreFilterDTO.WardId;
            StoreFilter.Address           = DirectSalesOrder_StoreFilterDTO.Address;
            StoreFilter.DeliveryAddress   = DirectSalesOrder_StoreFilterDTO.DeliveryAddress;
            StoreFilter.Latitude          = DirectSalesOrder_StoreFilterDTO.Latitude;
            StoreFilter.Longitude         = DirectSalesOrder_StoreFilterDTO.Longitude;
            StoreFilter.DeliveryLatitude  = DirectSalesOrder_StoreFilterDTO.DeliveryLatitude;
            StoreFilter.DeliveryLongitude = DirectSalesOrder_StoreFilterDTO.DeliveryLongitude;
            StoreFilter.OwnerName         = DirectSalesOrder_StoreFilterDTO.OwnerName;
            StoreFilter.OwnerPhone        = DirectSalesOrder_StoreFilterDTO.OwnerPhone;
            StoreFilter.OwnerEmail        = DirectSalesOrder_StoreFilterDTO.OwnerEmail;
            StoreFilter.StatusId          = DirectSalesOrder_StoreFilterDTO.StatusId;

            if (StoreFilter.Id == null)
            {
                StoreFilter.Id = new IdFilter();
            }
            StoreFilter.Id.In = await FilterStore(StoreService, OrganizationService, CurrentContext);

            List <Store> Stores = await StoreService.List(StoreFilter);

            List <DirectSalesOrder_StoreDTO> DirectSalesOrder_StoreDTOs = Stores
                                                                          .Select(x => new DirectSalesOrder_StoreDTO(x)).ToList();

            return(DirectSalesOrder_StoreDTOs);
        }
Esempio n. 8
0
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                LabelError.Text = "";

                try
                {
                    //Maintain Rules - upload or capture
                    if (this.storeFilterId > 0)
                    {
                        StoreFilter.DeleteStoreFilterByStoreFilterId(this.storeFilterId);
                    }

                    StoreFilter storeFilter = new StoreFilter();
                    storeFilter.Filter = TextBoxFilter.Text;
                    storeFilter.FileStoreDescription = TextBoxStore.Text;
                    storeFilter.FileSPARStoreId      = TextBoxInsightCode.Text;
                    storeFilter.FileDivision         = (TextBoxDivision.Text.Length == 0) ? "" : TextBoxDivision.Text;
                    storeFilter.FileRegion           = (TextBoxRegion.Text.Length == 0) ? "" : TextBoxRegion.Text;
                    storeFilter.FileZone             = (TextBoxZone.Text.Length == 0) ? "" : TextBoxZone.Text;
                    storeFilter.FilePCRegion         = (TextBoxPCRegion.Text.Length == 0) ? "" : TextBoxPCRegion.Text;
                    storeFilter.FilePCZone           = (TextBoxPCZone.Text.Length == 0) ? "" : TextBoxPCZone.Text;
                    storeFilter.AS400        = (TextBoxAS400.Text.Length == 0) ? "" : TextBoxAS400.Text;
                    storeFilter.InternalCode = (TextBoxInternalCode.Text.Length == 0) ? "" : TextBoxInternalCode.Text;
                    storeFilter.FileGuid     = "";
                    storeFilter.CompanyId    = Account.GetAccountByUserName(Page.User.Identity.Name.ToString()).CompanyId;
                    storeFilter.ModifiedUser = this.Master.LoggedOnAccount;

                    storeFilter.InsertStoreFilterMessage();

                    Button clickedButton = (Button)sender;
                    switch (clickedButton.ID)
                    {
                    case "ButtonSaveList":
                        Response.Redirect("StoreFilterList.aspx");
                        break;

                    case "ButtonSaveNew":
                        Response.Redirect("StoreFilterAdd.aspx");
                        break;
                    }
                }
                catch (System.Data.SqlClient.SqlException sqlEx)
                {
                    LabelError.Text = "";
                    for (int i = 0; i < sqlEx.Errors.Count; i++)
                    {
                        LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                    }
                    PanelError.Visible = true;
                }
            }
        }
Esempio n. 9
0
        public List <Store> GetPagedList(PagerRequest request, out int totalCount, StoreFilter filter)
        {
            var query = Filter(filter);
            var order = OrderBy(filter.SortOrder ?? StoreSortOrder.Default);

            using (var db = new YintaiHZhouContext())
            {
                int t;
                var rst = EFHelper.GetPaged(db, query, out t, request.PageIndex, request.PageSize, order).ToList();
                totalCount = t;
                return(rst);
            }
        }
Esempio n. 10
0
        public async Task <ActionResult <int> > Count([FromBody] Store_StoreFilterDTO Store_StoreFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            StoreFilter StoreFilter = ConvertFilterDTOToFilterEntity(Store_StoreFilterDTO);

            StoreFilter = StoreService.ToFilter(StoreFilter);
            int count = await StoreService.Count(StoreFilter);

            return(count);
        }
Esempio n. 11
0
        private void BindStoreFilter()
        {
            StoreFilter storeFilter = StoreFilter.GetStoreFilterByStoreFilterId(this.storeFilterId);

            TextBoxFilter.Text       = storeFilter.Filter;
            TextBoxStore.Text        = storeFilter.FileStoreDescription;
            TextBoxInsightCode.Text  = storeFilter.FileSPARStoreId;
            TextBoxDivision.Text     = storeFilter.FileDivision;
            TextBoxRegion.Text       = storeFilter.FileRegion;
            TextBoxZone.Text         = storeFilter.FileZone;
            TextBoxPCRegion.Text     = storeFilter.FilePCRegion;
            TextBoxPCZone.Text       = storeFilter.FilePCZone;
            TextBoxAS400.Text        = storeFilter.AS400;
            TextBoxInternalCode.Text = storeFilter.InternalCode;
        }
Esempio n. 12
0
        public IActionResult List(StoreFilter gridFilter)

        {
            var myCart  = Context.MyCart.Where(w => w.UserId == UserManager.GetUserId(User)).Select(s => s.ItemId).ToList() ?? new List <long>();
            var isAdmin = User.IsInRole("Administrator");
            var items   = Context.Item
                          .Include(i => i.Size)
                          .Include(i => i.Category)
                          .Include(i => i.SubCategory)
                          .Include(i => i.UnitOfMeasure)
                          .Include(i => i.Images)
                          .Where(w =>
                                 !w.Removed && !w.NotForSale &&
                                 (!w.IsPrivate || isAdmin) &&
                                 (w.CategoryId == gridFilter.Category || gridFilter.Category == 0) &&
                                 (w.SubCategoryId == gridFilter.SubCategory || gridFilter.SubCategory == 0)
                                 &&
                                 (
                                     string.IsNullOrEmpty(gridFilter.Filter) ||
                                     w.Barcode.Contains(gridFilter.Filter) ||
                                     w.Name.Contains(gridFilter.Filter) ||
                                     w.Description.Contains(gridFilter.Filter) ||
                                     w.StockNo.Contains(gridFilter.Filter) ||
                                     w.PartNo.Contains(gridFilter.Filter) ||
                                     w.UnitOfMeasure.Name.Contains(gridFilter.Filter)
                                 )
                                 )
                          .Select(s => new
            {
                s.Id,
                s.Barcode,
                s.Name,
                s.Description,
                s.Price,
                priceString = s.Price.ToString("N2"),
                s.Qty,
                size     = s.Size.Name,
                uom      = s.UnitOfMeasure.Name,
                category = s.Category.Name,
                s.Images,
                IsAdded = myCart.Contains(s.Id),
                s.PurPro
            })
                          .OrderBy(o => o.Name)
                          .ToResponse(gridFilter);

            return(Json(items));
        }
Esempio n. 13
0
        public ServiceResult GetStoreFilter(StoreFilter storeFilter)
        {
            serviceResult.isSuccess = true;
            var stores = _storeRepository.GetStoreFilter(storeFilter);

            //Nếu không tồn tại bản ghi nào
            if (stores.Count() == 0)
            {
                serviceResult.devMsg    = Properties.Resources.Msg_NoContent;
                serviceResult.isSuccess = false;
                serviceResult.userMsg   = Properties.Resources.Msg_NoContent;
                return(serviceResult);
            }

            serviceResult.data = stores;
            return(serviceResult);
        }
Esempio n. 14
0
        public async Task <ActionResult <List <Store_StoreDTO> > > List([FromBody] Store_StoreFilterDTO Store_StoreFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            StoreFilter StoreFilter = ConvertFilterDTOToFilterEntity(Store_StoreFilterDTO);

            StoreFilter = StoreService.ToFilter(StoreFilter);
            List <Store> Stores = await StoreService.List(StoreFilter);

            List <Store_StoreDTO> Store_StoreDTOs = Stores
                                                    .Select(c => new Store_StoreDTO(c)).ToList();

            return(Store_StoreDTOs);
        }
Esempio n. 15
0
        public async Task <ActionResult <long> > CountStore([FromBody] Customer_StoreFilterDTO Customer_StoreFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            StoreFilter StoreFilter = new StoreFilter();

            StoreFilter.Id                = Customer_StoreFilterDTO.Id;
            StoreFilter.Code              = Customer_StoreFilterDTO.Code;
            StoreFilter.CodeDraft         = Customer_StoreFilterDTO.CodeDraft;
            StoreFilter.Name              = Customer_StoreFilterDTO.Name;
            StoreFilter.UnsignName        = Customer_StoreFilterDTO.UnsignName;
            StoreFilter.ParentStoreId     = Customer_StoreFilterDTO.ParentStoreId;
            StoreFilter.OrganizationId    = Customer_StoreFilterDTO.OrganizationId;
            StoreFilter.StoreTypeId       = Customer_StoreFilterDTO.StoreTypeId;
            StoreFilter.StoreGroupingId   = Customer_StoreFilterDTO.StoreGroupingId;
            StoreFilter.Telephone         = Customer_StoreFilterDTO.Telephone;
            StoreFilter.ProvinceId        = Customer_StoreFilterDTO.ProvinceId;
            StoreFilter.DistrictId        = Customer_StoreFilterDTO.DistrictId;
            StoreFilter.WardId            = Customer_StoreFilterDTO.WardId;
            StoreFilter.Address           = Customer_StoreFilterDTO.Address;
            StoreFilter.UnsignAddress     = Customer_StoreFilterDTO.UnsignAddress;
            StoreFilter.DeliveryAddress   = Customer_StoreFilterDTO.DeliveryAddress;
            StoreFilter.Latitude          = Customer_StoreFilterDTO.Latitude;
            StoreFilter.Longitude         = Customer_StoreFilterDTO.Longitude;
            StoreFilter.DeliveryLatitude  = Customer_StoreFilterDTO.DeliveryLatitude;
            StoreFilter.DeliveryLongitude = Customer_StoreFilterDTO.DeliveryLongitude;
            StoreFilter.OwnerName         = Customer_StoreFilterDTO.OwnerName;
            StoreFilter.OwnerPhone        = Customer_StoreFilterDTO.OwnerPhone;
            StoreFilter.OwnerEmail        = Customer_StoreFilterDTO.OwnerEmail;
            StoreFilter.TaxCode           = Customer_StoreFilterDTO.TaxCode;
            StoreFilter.LegalEntity       = Customer_StoreFilterDTO.LegalEntity;
            StoreFilter.AppUserId         = Customer_StoreFilterDTO.AppUserId;
            StoreFilter.StatusId          = Customer_StoreFilterDTO.StatusId;
            StoreFilter.StoreStatusId     = Customer_StoreFilterDTO.StoreStatusId;
            StoreFilter.CustomerId        = Customer_StoreFilterDTO.CustomerId;
            StoreFilter.isSelected        = Customer_StoreFilterDTO.isSelected;

            return(await StoreService.Count(StoreFilter));
        }
Esempio n. 16
0
        public IEnumerable <Server.Model.Store.Store> Get(StoreFilter filter)
        {
            try
            {
                var query = Db.Set <Server.Model.Store.Store>().Where(it => !filter.IsOnlyActive || it.IsActive);
                query = filter.Sord.Equals("desc", StringComparison.OrdinalIgnoreCase)
                    ? query.OrderByDescending(filter.Sidx)
                    : query.OrderBy(filter.Sidx);

                return(query.Skip(filter.Rows * (filter.Page - 1)).Take(filter.Rows).Distinct());
            }
            catch (Exception ex)
            {
                LogEventManager.Logger.Error(ex.Message, ex);
                throw;
            }
        }
Esempio n. 17
0
        protected void ButtonUpdateFilter_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    LabelError.Text = "";
                    if (TextBoxFilter.Text.Length == 0)
                    {
                        LabelError.Text = " Filter is required.";
                        return;
                    }

                    bool hasError = false;

                    foreach (GridViewRow gridViewRow in GridViewResult.Rows)
                    {
                        HiddenField hiddenField         = (HiddenField)gridViewRow.Cells[0].FindControl("HiddenFieldStoreFilterId");
                        CheckBox    checkBoxStoreFilter = (CheckBox)gridViewRow.Cells[1].FindControl("CheckBoxStoreFilter");

                        if (checkBoxStoreFilter.Checked)
                        {
                            StoreFilter.UpdateStoreFilterByStoreFilterId(Convert.ToInt32(hiddenField.Value), TextBoxFilter.Text, this.Master.LoggedOnAccount);
                        }
                    }

                    TextBoxFilter.Text = "";
                    LabelError.Text    = " Update Successful.";

                    //BindFilter();

                    GridViewResult.DataSource = StoreFilter.GetStoreFilterListByFilter(DropDownListFilter.SelectedValue, this.companyId);
                    GridViewResult.DataBind();
                }
                catch (System.Data.SqlClient.SqlException sqlEx)
                {
                    LabelError.Text = "";
                    for (int i = 0; i < sqlEx.Errors.Count; i++)
                    {
                        LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                    }
                }
            }
        }
Esempio n. 18
0
        private StoreFilter ConvertFilterDTOToFilterEntity(Store_StoreFilterDTO Store_StoreFilterDTO)
        {
            StoreFilter StoreFilter = new StoreFilter();

            StoreFilter.Selects   = StoreSelect.ALL;
            StoreFilter.Skip      = Store_StoreFilterDTO.Skip;
            StoreFilter.Take      = Store_StoreFilterDTO.Take;
            StoreFilter.OrderBy   = Store_StoreFilterDTO.OrderBy;
            StoreFilter.OrderType = Store_StoreFilterDTO.OrderType;

            StoreFilter.Id                = Store_StoreFilterDTO.Id;
            StoreFilter.Code              = Store_StoreFilterDTO.Code;
            StoreFilter.CodeDraft         = Store_StoreFilterDTO.CodeDraft;
            StoreFilter.Name              = Store_StoreFilterDTO.Name;
            StoreFilter.UnsignName        = Store_StoreFilterDTO.UnsignName;
            StoreFilter.ParentStoreId     = Store_StoreFilterDTO.ParentStoreId;
            StoreFilter.OrganizationId    = Store_StoreFilterDTO.OrganizationId;
            StoreFilter.StoreTypeId       = Store_StoreFilterDTO.StoreTypeId;
            StoreFilter.StoreGroupingId   = Store_StoreFilterDTO.StoreGroupingId;
            StoreFilter.Telephone         = Store_StoreFilterDTO.Telephone;
            StoreFilter.ProvinceId        = Store_StoreFilterDTO.ProvinceId;
            StoreFilter.DistrictId        = Store_StoreFilterDTO.DistrictId;
            StoreFilter.WardId            = Store_StoreFilterDTO.WardId;
            StoreFilter.Address           = Store_StoreFilterDTO.Address;
            StoreFilter.UnsignAddress     = Store_StoreFilterDTO.UnsignAddress;
            StoreFilter.DeliveryAddress   = Store_StoreFilterDTO.DeliveryAddress;
            StoreFilter.Latitude          = Store_StoreFilterDTO.Latitude;
            StoreFilter.Longitude         = Store_StoreFilterDTO.Longitude;
            StoreFilter.DeliveryLatitude  = Store_StoreFilterDTO.DeliveryLatitude;
            StoreFilter.DeliveryLongitude = Store_StoreFilterDTO.DeliveryLongitude;
            StoreFilter.OwnerName         = Store_StoreFilterDTO.OwnerName;
            StoreFilter.OwnerPhone        = Store_StoreFilterDTO.OwnerPhone;
            StoreFilter.OwnerEmail        = Store_StoreFilterDTO.OwnerEmail;
            StoreFilter.TaxCode           = Store_StoreFilterDTO.TaxCode;
            StoreFilter.LegalEntity       = Store_StoreFilterDTO.LegalEntity;
            StoreFilter.AppUserId         = Store_StoreFilterDTO.AppUserId;
            StoreFilter.StatusId          = Store_StoreFilterDTO.StatusId;
            StoreFilter.StoreStatusId     = Store_StoreFilterDTO.StoreStatusId;
            StoreFilter.CustomerId        = Store_StoreFilterDTO.CustomerId;
            StoreFilter.CreatedAt         = Store_StoreFilterDTO.CreatedAt;
            StoreFilter.UpdatedAt         = Store_StoreFilterDTO.UpdatedAt;
            return(StoreFilter);
        }
Esempio n. 19
0
        public async Task <bool> ValidateId(Store Store)
        {
            StoreFilter StoreFilter = new StoreFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = Store.Id
                },
                Selects = StoreSelect.Id
            };

            int count = await UOW.StoreRepository.Count(StoreFilter);

            if (count == 0)
            {
                Store.AddError(nameof(StoreValidator), nameof(Store.Id), ErrorCode.IdNotExisted);
            }
            return(count == 1);
        }
Esempio n. 20
0
        public IActionResult GetStorePaging(int pageSize, int pageIndex, String storeCode, String storeName, String address, String phoneNumber, int status)
        {
            var storeFilter = new StoreFilter();

            storeFilter.StoreCode   = storeCode;
            storeFilter.StoreName   = storeName;
            storeFilter.Address     = address;
            storeFilter.PhoneNumber = phoneNumber;
            storeFilter.Status      = status;
            ServiceResult res = _storeService.GetStorePaging(pageSize, pageIndex, storeFilter);

            if (res.isSuccess)
            {
                return(Ok(res.data));
            }
            else
            {
                return(StatusCode(204, res));
            }
        }
Esempio n. 21
0
        //#region Validate StoreExtend

        //#region Số điện thoại khác/zalo
        //public async Task<bool> ValidatePhoneNumber(Store Store)
        //{
        //    if (string.IsNullOrWhiteSpace(Store.StoreExtend.PhoneOther))
        //    {
        //        Store.StoreExtend.AddError(nameof(StoreValidator), nameof(Store.StoreExtend.PhoneOther), ErrorCode.PhoneNumberEmpty);
        //    }
        //    else if (Store.StoreExtend.PhoneOther.Length > 20)
        //    {
        //        Store.StoreExtend.AddError(nameof(StoreValidator), nameof(Store.StoreExtend.PhoneOther), ErrorCode.PhoneNumberOverLength);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Tên khách hàng/Công ty
        //public async Task<bool> ValidateCompanyName(Store Store)
        //{
        //    if (string.IsNullOrWhiteSpace(Store.StoreExtend.CompanyName))
        //    {
        //        Store.StoreExtend.AddError(nameof(StoreValidator), nameof(Store.StoreExtend.CompanyName), ErrorCode.CompanyNameEmpty);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Vốn kinh doanh
        //public async Task<bool> ValidateBusinessCapital(Store Store)
        //{
        //    if (Store.StoreExtend.BusinessCapital == null)
        //    {
        //        Store.StoreExtend.AddError(nameof(StoreValidator), nameof(Store.StoreExtend.BusinessCapital), ErrorCode.BusinessCapitalEmpty);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Loại hình doanh nghiệp
        //public async Task<bool> ValidateBusinessType(Store Store)
        //{
        //    if (Store.StoreExtend.BusinessTypeId == null || Store.StoreExtend.BusinessTypeId == 0)
        //    {
        //        Store.StoreExtend.AddError(nameof(StoreValidator), nameof(Store.StoreExtend.BusinessType), ErrorCode.BusinessTypeEmpty);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Số tài khoản
        //public async Task<bool> ValidateATM(Store Store)
        //{
        //    if (string.IsNullOrWhiteSpace(Store.StoreExtend.BankAccountNumber))
        //    {
        //        Store.StoreExtend.AddError(nameof(StoreValidator), nameof(Store.StoreExtend.BankAccountNumber), ErrorCode.ATMEmpty);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Giấy phép kinh doanh
        //public async Task<bool> ValidateBusinessLicense(Store Store)
        //{
        //    if (string.IsNullOrWhiteSpace(Store.StoreExtend.BusinessLicense))
        //    {
        //        Store.StoreExtend.AddError(nameof(StoreValidator), nameof(Store.StoreExtend.BusinessLicense), ErrorCode.BusinessLicenseEmpty);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Ngân hàng
        //public async Task<bool> ValidateBankName(Store Store)
        //{
        //    if (string.IsNullOrWhiteSpace(Store.StoreExtend.BankName))
        //    {
        //        Store.StoreExtend.AddError(nameof(StoreValidator), nameof(Store.StoreExtend.BankName), ErrorCode.BankNameEmpty);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Hợp đồng đại lý
        //public async Task<bool> ValidateAgentContractNumber(Store Store)
        //{
        //    if (string.IsNullOrWhiteSpace(Store.StoreExtend.AgentContractNumber))
        //    {
        //        Store.StoreExtend.AddError(nameof(StoreValidator), nameof(Store.StoreExtend.AgentContractNumber), ErrorCode.AgentContractNumberEmpty);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Người đại diện
        //private async Task<bool> ValidateRepresent(Store Store)
        //{
        //    bool flag = false;
        //    if (Store.StoreRepresents != null)
        //    {
        //        foreach (var represent in Store.StoreRepresents)
        //        {
        //            if (represent.Name != null
        //                || represent.DateOfBirth != null
        //                || represent.Phone != null
        //                || represent.PositionId != null
        //                )
        //                flag = true;
        //        }
        //    }
        //    if (!flag) Store.AddError(nameof(StoreValidator), nameof(Store.StoreRepresents), ErrorCode.RepresentCannotBeNull);
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Khu vực phân phối
        //public async Task<bool> ValidateDistributionArea(Store Store)
        //{
        //    if (string.IsNullOrWhiteSpace(Store.StoreExtend.DistributionArea))
        //    {
        //        Store.StoreExtend.AddError(nameof(StoreValidator), nameof(Store.StoreExtend.DistributionArea), ErrorCode.DistributionAreaEmpty);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Dân số khu vực
        //public async Task<bool> ValidateRegionalPopulation(Store Store)
        //{
        //    if (Store.StoreExtend.RegionalPopulation == null)
        //    {
        //        Store.StoreExtend.AddError(nameof(StoreValidator), nameof(Store.StoreExtend.RegionalPopulation), ErrorCode.RegionalPopulationEmpty);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Diện tích khu vực
        //public async Task<bool> ValidateDistributionAcreage(Store Store)
        //{
        //    if (Store.StoreExtend.DistributionAcreage == null)
        //    {
        //        Store.StoreExtend.AddError(nameof(StoreValidator), nameof(Store.StoreExtend.DistributionAcreage), ErrorCode.DistributionAcreageEmpty);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Mức đô thị hóa
        //public async Task<bool> ValidateUrbanizationLevel(Store Store)
        //{
        //    if (string.IsNullOrWhiteSpace(Store.StoreExtend.UrbanizationLevel))
        //    {
        //        Store.StoreExtend.AddError(nameof(StoreValidator), nameof(Store.StoreExtend.UrbanizationLevel), ErrorCode.UrbanizationLevelEmpty);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Số lượng điểm bán
        //public async Task<bool> ValidateNumberOfPointsOfSale(Store Store)
        //{
        //    if (Store.StoreExtend.NumberOfPointsOfSale == null)
        //    {
        //        Store.StoreExtend.AddError(nameof(StoreValidator), nameof(Store.StoreExtend.NumberOfPointsOfSale), ErrorCode.NumberOfPointsOfSaleEmpty);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Số lượng khách hàng trọng điểm
        //public async Task<bool> ValidateNumberOfKeyCustomer(Store Store)
        //{
        //    if (Store.StoreExtend.NumberOfKeyCustomer == null)
        //    {
        //        Store.StoreExtend.AddError(nameof(StoreValidator), nameof(Store.StoreExtend.NumberOfKeyCustomer), ErrorCode.NumberOfKeyCustomerEmpty);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Đặc điểm thị trường
        //public async Task<bool> ValidateMarketCharacteristics(Store Store)
        //{
        //    if (string.IsNullOrWhiteSpace(Store.StoreExtend.MarketCharacteristics))
        //    {
        //        Store.StoreExtend.AddError(nameof(StoreValidator), nameof(Store.StoreExtend.MarketCharacteristics), ErrorCode.MarketCharacteristicsEmpty);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Diện tích cửa hàng
        //public async Task<bool> ValidateStoreAcreage(Store Store)
        //{
        //    if (Store.StoreExtend.StoreAcreage == null)
        //    {
        //        Store.StoreExtend.AddError(nameof(StoreValidator), nameof(Store.StoreExtend.StoreAcreage), ErrorCode.StoreAcreageEmpty);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Khả năng thanh toán đúng hạn
        //public async Task<bool> ValidateAbilityToPay(Store Store)
        //{
        //    if (string.IsNullOrWhiteSpace(Store.StoreExtend.AbilityToPay))
        //    {
        //        Store.StoreExtend.AddError(nameof(StoreValidator), nameof(Store.StoreExtend.AbilityToPay), ErrorCode.AbilityToPayEmpty);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Nhân sự
        //private async Task<bool> ValidatePersonnel(Store Store)
        //{
        //    bool flag = false;
        //    if (Store.StorePersonnels != null)
        //    {
        //        foreach (var represent in Store.StorePersonnels)
        //        {
        //            if (represent.Name != null
        //                || represent.Quantity != null
        //                )
        //                flag = true;
        //        }
        //    }
        //    if (!flag) Store.AddError(nameof(StoreValidator), nameof(Store.StorePersonnels), ErrorCode.PersonnelCannotBeNull);
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Phương tiện giao hàng
        //private async Task<bool> ValidateStoreMeansOfDelivery(Store Store)
        //{
        //    bool flag = false;
        //    if (Store.StoreMeansOfDeliveries != null)
        //    {
        //        foreach (var represent in Store.StoreMeansOfDeliveries)
        //        {
        //            if (represent.Name != null
        //                || represent.Quantity != null
        //                || represent.Owned != null
        //                || represent.Rent != null
        //                || represent.StoreId != null
        //                )
        //                flag = true;
        //        }
        //    }
        //    if (!flag) Store.AddError(nameof(StoreValidator), nameof(Store.StoreMeansOfDeliveries), ErrorCode.StoreMeansOfDeliveryCannotBeNull);
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Tài sản
        //private async Task<bool> ValidateStoreAssets(Store Store)
        //{
        //    bool flag = false;
        //    if (Store.StoreAssetses != null)
        //    {
        //        foreach (var item in Store.StoreAssetses)
        //        {
        //            if (item.Name != null
        //                || item.Quantity != null
        //                || item.Owned != null
        //                || item.Rent != null
        //                || item.StoreId != null
        //                )
        //                flag = true;
        //        }
        //    }
        //    if (!flag) Store.AddError(nameof(StoreValidator), nameof(Store.StoreAssetses), ErrorCode.StoreAssetsCannotBeNull);
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Thời gian giao hàng
        //private async Task<bool> ValidateDeliveryTime(Store Store)
        //{
        //    if (Store.StoreDeliveryTimeMappings == null || !Store.StoreDeliveryTimeMappings.Any())
        //    {
        //        Store.AddError(nameof(StoreValidator), nameof(Store.StoreDeliveryTimeMappings), ErrorCode.DeliveryTimeCannotBeNull);
        //    }

        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Mối quan hệ khách hàng
        //private async Task<bool> ValidateRelationshipCustomerType(Store Store)
        //{
        //    if (Store.StoreRelationshipCustomerMappings == null || !Store.StoreRelationshipCustomerMappings.Any())
        //    {
        //        Store.AddError(nameof(StoreValidator), nameof(Store.StoreRelationshipCustomerMappings), ErrorCode.RelationshipCustomerTypeCannotBeNull);
        //    }

        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Mức độ ảnh hưởng
        //private async Task<bool> ValidateInfulenceLevelMarket(Store Store)
        //{
        //    if (Store.StoreInfulenceLevelMarketMappings == null || !Store.StoreInfulenceLevelMarketMappings.Any())
        //    {
        //        Store.AddError(nameof(StoreValidator), nameof(Store.StoreInfulenceLevelMarketMappings), ErrorCode.InfulenceLevelMarketCannotBeNull);
        //    }

        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Giá bán thị trường
        //private async Task<bool> ValidateMarketPrice(Store Store)
        //{
        //    if (Store.StoreMarketPriceMappings == null || !Store.StoreMarketPriceMappings.Any())
        //    {
        //        Store.AddError(nameof(StoreValidator), nameof(Store.StoreMarketPriceMappings), ErrorCode.MarketPriceCannotBeNull);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Dịch vụ bảo hành
        //private async Task<bool> ValidateWarrantyService(Store Store)
        //{
        //    bool flag = false;
        //    if (Store.StoreWarrantyServices != null)
        //    {
        //        foreach (var item in Store.StoreWarrantyServices)
        //        {
        //            if (item.Name != null
        //                || item.Detail != null
        //                )
        //                flag = true;
        //        }
        //    }
        //    if (!flag) Store.AddError(nameof(StoreValidator), nameof(Store.StoreWarrantyServices), ErrorCode.WarrantyServiceCannotBeNull);
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Khả năng bao phủ thị trường
        //private async Task<bool> ValidateStoreCoverageCapacity(Store Store)
        //{
        //    bool flag = false;
        //    if (Store.StoreCoverageCapacities != null)
        //    {
        //        foreach (var item in Store.StoreCoverageCapacities)
        //        {
        //            if (item.Name != null
        //                || item.Detail != null
        //                )
        //                flag = true;
        //        }
        //    }
        //    if (!flag) Store.AddError(nameof(StoreValidator), nameof(Store.StoreCoverageCapacities), ErrorCode.CoverageCapacityCannotBeNull);
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Khả năng tư vấn dịch vụ
        //private async Task<bool> ValidateStoreConsultingService(Store Store)
        //{
        //    if (Store.StoreConsultingServiceMappings == null || !Store.StoreConsultingServiceMappings.Any())
        //    {
        //        Store.AddError(nameof(StoreValidator), nameof(Store.StoreConsultingServiceMappings), ErrorCode.StoreConsultingServiceCannotBeNull);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Điểm mạnh khác
        //public async Task<bool> ValidateAnotherStrongPoint(Store Store)
        //{
        //    if (string.IsNullOrWhiteSpace(Store.StoreExtend.AnotherStrongPoint))
        //    {
        //        Store.StoreExtend.AddError(nameof(StoreValidator), nameof(Store.StoreExtend.AnotherStrongPoint), ErrorCode.AnotherStrongPointEmpty);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Thái độ hợp tác
        //private async Task<bool> ValidateCooperativeAttitude(Store Store)
        //{
        //    if (Store.StoreCooperativeAttitudeMappings == null || !Store.StoreCooperativeAttitudeMappings.Any())
        //    {
        //        Store.AddError(nameof(StoreValidator), nameof(Store.StoreCooperativeAttitudeMappings), ErrorCode.CooperativeAttitudeCannotBeNull);
        //    }
        //    return Store.IsValidated;
        //}
        //#endregion

        //#region Nâng cao chất lượng dịch vụ
        //private async Task<bool> ValidateImproveQualityServing(Store Store)
        //{
        //    bool flag = false;
        //    if (Store.ImproveQualityServings != null)
        //    {
        //        foreach (var item in Store.ImproveQualityServings)
        //        {
        //            if (item.Name != null
        //                || item.Detail != null
        //                )
        //                flag = true;
        //        }
        //    }
        //    if (!flag) Store.AddError(nameof(StoreValidator), nameof(Store.ImproveQualityServings), ErrorCode.ImproveQualityServingCannotBeNull);
        //    return Store.IsValidated;
        //}
        //#endregion


        //#endregion


        public async Task <bool> AddToCustomer(List <Store> Stores)
        {
            var CustomerId = Stores.Select(x => x.CustomerId).FirstOrDefault();

            if (CustomerId == 0)
            {
                return(false);
            }
            var         Ids         = Stores.Select(x => x.Id).ToList();
            StoreFilter StoreFilter = new StoreFilter
            {
                Skip    = 0,
                Take    = int.MaxValue,
                Selects = StoreSelect.Id | StoreSelect.Customer,
                Id      = new IdFilter {
                    In = Ids
                }
            };
            var oldDatas = await UOW.StoreRepository.List(StoreFilter);

            Dictionary <long, Store> dict = oldDatas.ToDictionary(x => x.Id, y => y);

            foreach (var Store in Stores)
            {
                var old = dict[Store.Id];
                if (old == null)
                {
                    Store.AddError(nameof(StoreValidator), nameof(Store.Id), ErrorCode.IdNotExisted);
                }
                else
                {
                    if (old.CustomerId.HasValue)
                    {
                        Store.AddError(nameof(StoreValidator), nameof(Store.Id), ErrorCode.StoreUsed);
                    }
                }
            }
            return(true);
        }
Esempio n. 22
0
        private async Task <bool> HasPermission(long Id)
        {
            StoreFilter StoreFilter = new StoreFilter();

            StoreFilter = StoreService.ToFilter(StoreFilter);
            if (Id == 0)
            {
            }
            else
            {
                StoreFilter.Id = new IdFilter {
                    Equal = Id
                };
                int count = await StoreService.Count(StoreFilter);

                if (count == 0)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 23
0
        public StorePaging GetStorePaging(int pageSize, int pageIndex, StoreFilter storeFilter)
        {
            var storeName  = "Proc_GetStorePaging";
            var parameters = new DynamicParameters();

            parameters.Add($"@PageSize", pageSize);
            parameters.Add($"@PageIndex", pageIndex);
            parameters.Add($"@TotalRecord", dbType: System.Data.DbType.Int32, direction: System.Data.ParameterDirection.Output);
            parameters.Add($"@TotalPage", dbType: System.Data.DbType.Int32, direction: System.Data.ParameterDirection.Output);
            parameters.Add($"@StoreCode", storeFilter.StoreCode, DbType.String);
            parameters.Add($"@StoreName", storeFilter.StoreName, DbType.String);
            parameters.Add($"@Address", storeFilter.Address, DbType.String);
            parameters.Add($"@PhoneNumber", storeFilter.PhoneNumber, DbType.String);
            parameters.Add($"@Status", storeFilter.Status, DbType.String);
            var storePaging = new StorePaging();
            var store       = dbConnection.Query <Store>(storeName, parameters, commandType: CommandType.StoredProcedure);

            storePaging.Data        = store.ToList();
            storePaging.TotalPage   = parameters.Get <int>("@TotalPage");
            storePaging.TotalRecord = parameters.Get <int>("@TotalRecord");
            return(storePaging);
        }
Esempio n. 24
0
        public void Get()
        {
            try
            {
                var options = CreateNewContextOptions(); using (var db = new StoreContext(options))
                {
                    var repository = new StoreRepository(db);
                    StoreTestHelper.PopulateDefaultStoreDataCtx(db);
                    var item = GenerateModel();
                    IEnumerable <StoreM> result = null;
                    Assert.DoesNotThrow(() => repository.Save(item));

                    var filter = new StoreFilter();
                    Assert.DoesNotThrow(() => result = repository.Get(filter));
                    Assert.True(result != null && result.Any());
                }
            }
            catch (Exception ex)
            {
                LogEventManager.Logger.Error(ex);
                throw;
            }
        }
Esempio n. 25
0
        public async Task <int> Count(StoreFilter StoreFilter)
        {
            try
            {
                int result = await UOW.StoreRepository.Count(StoreFilter);

                return(result);
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    await Logging.CreateSystemLog(ex, nameof(StoreService));

                    throw new MessageException(ex);
                }
                else
                {
                    await Logging.CreateSystemLog(ex.InnerException, nameof(StoreService));

                    throw new MessageException(ex.InnerException);
                }
            }
        }
Esempio n. 26
0
        public async Task <List <Store> > List(StoreFilter StoreFilter)
        {
            try
            {
                List <Store> Stores = await UOW.StoreRepository.List(StoreFilter);

                return(Stores);
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    await Logging.CreateSystemLog(ex, nameof(StoreService));

                    throw new MessageException(ex);
                }
                else
                {
                    await Logging.CreateSystemLog(ex.InnerException, nameof(StoreService));

                    throw new MessageException(ex.InnerException);
                }
            }
        }
Esempio n. 27
0
        protected void resultFilter(string SearchFor, string locale)
        {
            if (SearchFor.Length == 0)
            {
                SearchFor = txtSearch.Text.Trim();
            }
            if (locale.Length == 0)
            {
                if (!AppLogic.m_ProductIsML() || AppLogic.ProductIsMLX() || AppLogic.ProductIsMLExpress())
                {
                    locale = Localization.GetDefaultLocale();
                }
                else
                {
                    if (ddLocales.Items.Count < 3)
                    {
                        locale = Localization.GetDefaultLocale();
                    }
                    else
                    {
                        locale = ddLocales.SelectedValue;
                    }
                }
            }

            String sql         = selectSQL + " with (NOLOCK) ";
            String WhereClause = String.Empty;

            //search filter
            if (SearchFor.Length != 0)
            {
                if (WhereClause.Length != 0)
                {
                    WhereClause += " and ";
                }
                WhereClause += " (Name like " + DB.SQuote("%" + SearchFor + "%") + " or ConfigValue like " + DB.SQuote("%" + SearchFor + "%") + ")";
            }

            //locale filter
            if ((locale.Length != 0) && (!locale.Equals("Reset")))
            {
                if (WhereClause.Length != 0)
                {
                    WhereClause += " and ";
                }
                WhereClause += " LocaleSetting like " + DB.SQuote(locale);
            }

            if (StoreFilter != NO_STORE_FILTERING_FILTER)
            {
                if (WhereClause.Length != 0)
                {
                    WhereClause += " and ";
                }
                WhereClause += " StoreId = " + StoreFilter.ToString();
            }

            //starts with filter
            string Index = "";

            for (int i = 0; i < treeMain.Nodes.Count; i++)
            {
                if (treeMain.Nodes[i].Selected)
                {
                    Index = treeMain.Nodes[i].Value;
                    break;
                }
            }
            if (Index.Length > 0)
            {
                if (!Index.Equals("All"))
                {
                    if (WhereClause.Length != 0)
                    {
                        WhereClause += " and ";
                    }
                    WhereClause += " Name like " + DB.SQuote(Index + "%");
                }
                if (Index.Equals("#"))
                {
                    if (WhereClause.Length != 0)
                    {
                        WhereClause += " and ";
                    }
                    WhereClause += " Name like (" + DB.SQuote("0%") + ")";
                    WhereClause += " OR Name like (" + DB.SQuote("1%") + ")";
                    WhereClause += " OR Name like (" + DB.SQuote("2%") + ")";
                    WhereClause += " OR Name like (" + DB.SQuote("3%") + ")";
                    WhereClause += " OR Name like (" + DB.SQuote("4%") + ")";
                    WhereClause += " OR Name like (" + DB.SQuote("5%") + ")";
                    WhereClause += " OR Name like (" + DB.SQuote("6%") + ")";
                    WhereClause += " OR Name like (" + DB.SQuote("7%") + ")";
                    WhereClause += " OR Name like (" + DB.SQuote("8%") + ")";
                    WhereClause += " OR Name like (" + DB.SQuote("9%") + ")";
                    WhereClause += " OR Name like (" + DB.SQuote("10%") + ")";
                }
            }

            //Super admin filter
            if (!cust.IsAdminSuperUser)
            {
                if (WhereClause.Length != 0)
                {
                    WhereClause += " and ";
                }
                WhereClause += " UPPER(Name) <> 'ADMIN_SUPERUSER' ";
            }
            if (WhereClause.Length != 0)
            {
                sql += " where " + WhereClause;
            }

            ViewState["SQLString"] = sql.ToString();
            sql += " order by " + ViewState["Sort"].ToString() + " " + ViewState["SortOrder"].ToString();

            buildGridData(sql);

            txtSearch.Text          = SearchFor;
            ddLocales.SelectedIndex = -1;
            if (ddLocales.Items.Count > 2)
            {
                ddLocales.Items.FindByValue(locale).Selected = true;
            }
        }
Esempio n. 28
0
        private void LoadFile()
        {
            LabelError.Text = "";
            string       fileExtension = "";
            string       fullFileName  = "";
            string       fileName      = "";
            string       errorMessage  = "";
            Guid         myGuid        = Guid.NewGuid();
            FileStream   fileStream    = null;
            StreamReader streamReader  = null;
            int          headerRow     = (CheckBoxHeaderRow.Checked) ? 1 : 0;
            string       line          = "";
            DataSet      ds            = new DataSet();

            if (FileUploadDocument.HasFile)
            {
                Boolean fileOK = false;

                fileExtension = Path.GetExtension(FileUploadDocument.FileName).ToLower();
                String[] allowedExtensions = ConfigurationManager.AppSettings["documentAllowedExtension"].ToString().Split(',');

                for (int i = 0; i < allowedExtensions.Length; i++)
                {
                    if (fileExtension == allowedExtensions[i].Trim())
                    {
                        fileOK = true;
                    }
                }
                if (fileOK)
                {
                    fileExtension = Path.GetExtension(FileUploadDocument.FileName).ToLower();

                    if (fileExtension == ".xls" || fileExtension == ".xlsx")
                    {
                        fileName     = String.Format("{0}{1}", myGuid.ToString(), fileExtension);
                        fullFileName = Path.Combine(ConfigurationManager.AppSettings["documentFolderUpload"].ToString(), fileName);
                        FileUploadDocument.PostedFile.SaveAs(fullFileName);


                        string excelConnectionString = string.Empty;
                        if (fileExtension == ".xls")
                        {
                            excelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
                                                    fullFileName + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
                        }
                        //connection String for xlsx file format.
                        else if (fileExtension == ".xlsx")
                        {
                            excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
                                                    fullFileName + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
                        }
                        //Create Connection to Excel work book and add oledb namespace
                        OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
                        excelConnection.Open();
                        DataTable dt = new DataTable();

                        dt = excelConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                        if (dt == null)
                        {
                            return;
                        }

                        String[] excelSheets = new String[dt.Rows.Count];
                        int      t           = 0;
                        //excel data saves in temp file here.
                        foreach (DataRow row in dt.Rows)
                        {
                            excelSheets[t] = row["TABLE_NAME"].ToString();
                            t++;
                        }
                        OleDbConnection excelConnection1 = new OleDbConnection(excelConnectionString);


                        string query = string.Format("Select * from [{0}]", excelSheets[0]);
                        using (OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, excelConnection1))
                        {
                            dataAdapter.Fill(ds);
                        }
                    }
                    int companyId = Account.GetAccountByUserName(Page.User.Identity.Name.ToString()).CompanyId;
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        StoreFilter storeFilter = new StoreFilter();
                        storeFilter.Filter = TextBoxFilter.Text;
                        storeFilter.FileStoreDescription = ds.Tables[0].Rows[i][0].ToString().Trim();
                        storeFilter.FileSPARStoreId      = ds.Tables[0].Rows[i][1].ToString().Trim();
                        storeFilter.FileDivision         = ds.Tables[0].Rows[i][2].ToString().Trim();
                        storeFilter.FileRegion           = ds.Tables[0].Rows[i][3].ToString().Trim();
                        storeFilter.FileZone             = ds.Tables[0].Rows[i][4].ToString().Trim();
                        storeFilter.FilePCRegion         = ds.Tables[0].Rows[i][5].ToString().Trim();
                        storeFilter.FilePCZone           = ds.Tables[0].Rows[i][6].ToString().Trim();
                        storeFilter.AS400        = ds.Tables[0].Rows[i][7].ToString().Trim();
                        storeFilter.InternalCode = ds.Tables[0].Rows[i][8].ToString().Trim();
                        storeFilter.CompanyId    = companyId;
                        storeFilter.ModifiedUser = this.Master.LoggedOnAccount;
                        storeFilter.FileGuid     = myGuid.ToString();

                        if (!storeFilter.InsertStoreFilterMessage())
                        {
                            foreach (string errorDescription in storeFilter.ErrorMessageList)
                            {
                                errorMessage += errorDescription;
                            }
                        }
                    }
                }
                else
                {
                    LabelError.Text = "Cannot accept files of this type.\n";
                }
            }
            else
            {
                fileName        = "";
                LabelError.Text = "No File Selected.";
            }

            if (errorMessage.Length > 0)
            {
                LabelError.Text = errorMessage;
            }

            if (LabelError.Text.Length == 0)
            {
                TextBoxFilter.Text = "";
                LabelError.Text    = "Upload Successful.";
            }

            //File.Delete(fullFileName);
            PanelError.Visible = true;
        }
Esempio n. 29
0
 protected void ButtonSearch_Click(object sender, EventArgs e)
 {
     LabelError.Text           = "";
     GridViewResult.DataSource = StoreFilter.GetStoreFilterListByFilter(DropDownListFilter.SelectedValue, this.companyId);
     GridViewResult.DataBind();
 }
Esempio n. 30
0
        public StoreFilter ToFilter(StoreFilter filter)
        {
            if (filter.OrFilter == null)
            {
                filter.OrFilter = new List <StoreFilter>();
            }
            if (CurrentContext.Filters == null || CurrentContext.Filters.Count == 0)
            {
                return(filter);
            }
            foreach (var currentFilter in CurrentContext.Filters)
            {
                StoreFilter subFilter = new StoreFilter();
                filter.OrFilter.Add(subFilter);
                List <FilterPermissionDefinition> FilterPermissionDefinitions = currentFilter.Value;
                foreach (FilterPermissionDefinition FilterPermissionDefinition in FilterPermissionDefinitions)
                {
                    if (FilterPermissionDefinition.Name == nameof(subFilter.Id))
                    {
                        subFilter.Id = FilterPermissionDefinition.IdFilter;
                    }
                    if (FilterPermissionDefinition.Name == nameof(subFilter.Code))
                    {
                        subFilter.Code = FilterPermissionDefinition.StringFilter;
                    }

                    if (FilterPermissionDefinition.Name == nameof(subFilter.CodeDraft))
                    {
                        subFilter.CodeDraft = FilterPermissionDefinition.StringFilter;
                    }

                    if (FilterPermissionDefinition.Name == nameof(subFilter.Name))
                    {
                        subFilter.Name = FilterPermissionDefinition.StringFilter;
                    }

                    if (FilterPermissionDefinition.Name == nameof(subFilter.UnsignName))
                    {
                        subFilter.UnsignName = FilterPermissionDefinition.StringFilter;
                    }

                    if (FilterPermissionDefinition.Name == nameof(subFilter.ParentStoreId))
                    {
                        subFilter.ParentStoreId = FilterPermissionDefinition.IdFilter;
                    }
                    if (FilterPermissionDefinition.Name == nameof(subFilter.OrganizationId))
                    {
                        subFilter.OrganizationId = FilterPermissionDefinition.IdFilter;
                    }
                    if (FilterPermissionDefinition.Name == nameof(subFilter.StoreTypeId))
                    {
                        subFilter.StoreTypeId = FilterPermissionDefinition.IdFilter;
                    }
                    if (FilterPermissionDefinition.Name == nameof(subFilter.StoreGroupingId))
                    {
                        subFilter.StoreGroupingId = FilterPermissionDefinition.IdFilter;
                    }
                    if (FilterPermissionDefinition.Name == nameof(subFilter.Telephone))
                    {
                        subFilter.Telephone = FilterPermissionDefinition.StringFilter;
                    }

                    if (FilterPermissionDefinition.Name == nameof(subFilter.ProvinceId))
                    {
                        subFilter.ProvinceId = FilterPermissionDefinition.IdFilter;
                    }
                    if (FilterPermissionDefinition.Name == nameof(subFilter.DistrictId))
                    {
                        subFilter.DistrictId = FilterPermissionDefinition.IdFilter;
                    }
                    if (FilterPermissionDefinition.Name == nameof(subFilter.WardId))
                    {
                        subFilter.WardId = FilterPermissionDefinition.IdFilter;
                    }
                    if (FilterPermissionDefinition.Name == nameof(subFilter.Address))
                    {
                        subFilter.Address = FilterPermissionDefinition.StringFilter;
                    }

                    if (FilterPermissionDefinition.Name == nameof(subFilter.UnsignAddress))
                    {
                        subFilter.UnsignAddress = FilterPermissionDefinition.StringFilter;
                    }

                    if (FilterPermissionDefinition.Name == nameof(subFilter.DeliveryAddress))
                    {
                        subFilter.DeliveryAddress = FilterPermissionDefinition.StringFilter;
                    }

                    if (FilterPermissionDefinition.Name == nameof(subFilter.Latitude))
                    {
                        subFilter.Latitude = FilterPermissionDefinition.DecimalFilter;
                    }



                    if (FilterPermissionDefinition.Name == nameof(subFilter.Longitude))
                    {
                        subFilter.Longitude = FilterPermissionDefinition.DecimalFilter;
                    }



                    if (FilterPermissionDefinition.Name == nameof(subFilter.DeliveryLatitude))
                    {
                        subFilter.DeliveryLatitude = FilterPermissionDefinition.DecimalFilter;
                    }



                    if (FilterPermissionDefinition.Name == nameof(subFilter.DeliveryLongitude))
                    {
                        subFilter.DeliveryLongitude = FilterPermissionDefinition.DecimalFilter;
                    }



                    if (FilterPermissionDefinition.Name == nameof(subFilter.OwnerName))
                    {
                        subFilter.OwnerName = FilterPermissionDefinition.StringFilter;
                    }

                    if (FilterPermissionDefinition.Name == nameof(subFilter.OwnerPhone))
                    {
                        subFilter.OwnerPhone = FilterPermissionDefinition.StringFilter;
                    }

                    if (FilterPermissionDefinition.Name == nameof(subFilter.OwnerEmail))
                    {
                        subFilter.OwnerEmail = FilterPermissionDefinition.StringFilter;
                    }

                    if (FilterPermissionDefinition.Name == nameof(subFilter.TaxCode))
                    {
                        subFilter.TaxCode = FilterPermissionDefinition.StringFilter;
                    }

                    if (FilterPermissionDefinition.Name == nameof(subFilter.LegalEntity))
                    {
                        subFilter.LegalEntity = FilterPermissionDefinition.StringFilter;
                    }

                    if (FilterPermissionDefinition.Name == nameof(subFilter.AppUserId))
                    {
                        subFilter.AppUserId = FilterPermissionDefinition.IdFilter;
                    }
                    if (FilterPermissionDefinition.Name == nameof(subFilter.StatusId))
                    {
                        subFilter.StatusId = FilterPermissionDefinition.IdFilter;
                    }
                    if (FilterPermissionDefinition.Name == nameof(subFilter.StoreStatusId))
                    {
                        subFilter.StoreStatusId = FilterPermissionDefinition.IdFilter;
                    }
                }
            }
            return(filter);
        }