Example #1
0
        private void LoadExcel()
        {
            try
            {
                string   path          = Properties.Settings.Default.loadPath;
                string   directoryName = string.Empty;
                var      dirDetails    = Directory.GetDirectories(path);
                string[] dirNames      = System.Enum.GetNames(typeof(DirectoryNames));

                foreach (string dir in dirDetails)
                {
                    if (dir.Contains(DirectoryNames.LookupModelExcel.ToString()))
                    {
                        directoryName = DirectoryNames.LookupModelExcel.ToString();
                        string[] files = Directory.GetFiles(dir);
                        foreach (string file in files)
                        {
                            string fileName = Path.GetFileName(file);
                            File.Move(dir + "\\" + fileName, Properties.Settings.Default.progressPath + directoryName + "\\" + fileName);
                            ls = new LookupServices();
                            FileDetails fd = new FileDetails();
                            fd.FileName      = fileName;
                            fd.DirectoryName = directoryName;
                            HttpResponseMessage res = ls.InsertLookupData(fd);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                WriteToFile(ex.Message);
            }
        }
        public ActionResult NewUser(UserModel user, UserFilterModel filter)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    EmployeeServices.CreateUser(user);
                    return(RedirectToAction("UserListing", filter.GenerateUserAccessRoute()));
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.ToString());
                ModelState.AddModelError(String.Empty, Constants.ServerError);
            }

            // Invalid - redisplay with errors
            var model = new UserDetailModel()
            {
                Action = "NewUser",
                User   = user,
                Filter = filter,
                Roles  = LookupServices.GetRoleOptions(user.RoleName)
            };

            ViewBag.Locations = LocationServices.GetLocationLookup(true, -1);
            return(View("UserDetail", model));
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id">POID</param>
        /// <returns></returns>
        public ActionResult Create()
        {
            /// Authorization Check
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }

            var allProducts = _productServices.GetAllValidProductMasters(CurrentTenantId).ToList();

            ViewBag.Products = new SelectList(allProducts, "ProductId", "NameWithCode");

            var products = new SelectList(allProducts, "ProductId", "NameWithCode").ToList();

            products.Insert(0, new SelectListItem()
            {
                Value = "0", Text = "Other / New Product"
            });

            ViewBag.Products = new SelectList(products);

            ViewBag.GlobalWarranties = new SelectList(LookupServices.GetAllTenantWarrenties(CurrentTenantId), "WarrantyID", "WarrantyName");
            var taxes = (from gtax in LookupServices.GetAllValidGlobalTaxes().Where(a => a.CountryID == CurrentTenant.CountryID)
                         select new
            {
                TaxId = gtax.TaxID,
                TaxName = gtax.TaxName + " - " + gtax.PercentageOfAmount + " %"
            }).ToList();

            ViewBag.GlobalTaxes = new SelectList(taxes, "TaxId", "TaxName");
            return(View());
        }
        public ActionResult Index(int id = 0)
        {
            if (id == 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ProductMaster productmaster = _productServices.GetProductMasterById(id);

            if (productmaster == null)
            {
                return(HttpNotFound());
            }

            var warehouses = LookupServices.GetAllWarehousesForTenant(CurrentTenantId);

            ViewBag.Warehouse = new SelectList(warehouses, "WarehouseId", "WarehouseName");

            try
            {
                ViewBag.Locations = new SelectList(warehouses.FirstOrDefault().Locations, "LocationId", "LocationCode");
            }
            catch (Exception ex)
            {
                throw new Exception("Exception while getting Product Locations - " + ex.Message.ToString(), ex.InnerException);
            }

            return(View(productmaster));
        }
Example #5
0
        private DirectSalesViewModel LoadLookups(DirectSalesViewModel model)
        {
            var allTaxes      = LookupServices.GetAllValidGlobalTaxes().ToList();
            var allWarranties = LookupServices.GetAllTenantWarrenties(CurrentTenantId).ToList();

            model.AllAccounts = AccountServices.GetAllValidAccounts(CurrentTenantId, EnumAccountType.Customer)
                                .Select(m => new SelectListItem {
                Text = m.CompanyName, Value = m.AccountID.ToString()
            }).ToList();
            //model.AllAccounts.Insert(0, new SelectListItem { Text = "None", Value = "0" });

            model.AllProducts = _productServices.GetAllValidProductMasters(CurrentTenantId)
                                .Select(m => new SelectListItem {
                Text = m.NameWithCode, Value = m.ProductId.ToString()
            }).ToList();
            model.AllTaxes = allTaxes.Select(m => new SelectListItem {
                Text = m.TaxName, Value = m.TaxID.ToString()
            })
                             .ToList();
            model.TaxDataHelper =
                Newtonsoft.Json.JsonConvert.SerializeObject(allTaxes.Select(m => new { m.TaxID, m.PercentageOfAmount }));
            model.AllWarranties = allWarranties
                                  .Select(m => new SelectListItem {
                Text = m.WarrantyName, Value = m.WarrantyID.ToString()
            }).ToList();
            model.WarrantyDataHelper =
                Newtonsoft.Json.JsonConvert.SerializeObject(
                    allWarranties.Select(m => new { m.WarrantyID, m.IsPercent, m.PercentageOfPrice, m.FixedPrice }));
            return(model);
        }
Example #6
0
        public ActionResult DepartmentsManagerPartialAddNew(TenantDepartments item)
        {
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _adminServices.SaveTenantDepartment(item, CurrentUserId);
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }

            var model = LookupServices.GetAllValidTenantDepartments(CurrentTenantId);

            return(PartialView("_DepartmentsManagerPartial", model.ToList()));
        }
        // GET: Appointments
        public ActionResult Index()
        {
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }

            var resources = _employeeServices.GetAllActiveAppointmentResourceses(CurrentTenantId).ToList().Select(x => new SelectListItem()
            {
                Text = x.Name, Value = x.ResourceId.ToString()
            }).ToList();

            resources.Insert(0, new SelectListItem()
            {
                Text = "All", Value = "0"
            });
            ViewBag.WorksResources = resources;

            var jobTypes = LookupServices.GetAllJobTypes(CurrentTenantId).Select(x => new SelectListItem()
            {
                Text = x.Name, Value = x.JobTypeId.ToString()
            }).ToList();

            jobTypes.Insert(0, new SelectListItem()
            {
                Text = "All", Value = "0"
            });
            ViewBag.ResourcejobTypes = jobTypes;

            return(View());
        }
        public ActionResult EditUser(int id, UserFilterModel filter, FormCollection collection)
        {
            var user = EmployeeServices.GetUser(id);

            try
            {
                UpdateModel(user, "User");
                EmployeeServices.UpdateUser(user);

                return(RedirectToAction("UserListing", filter.GenerateUserAccessRoute()));
            }
            catch (Exception ex)
            {
                // Invalid - redisplay with errors
                Logger.Error(ex.ToString());
                ModelState.AddModelError(String.Empty, Constants.ServerError);
                var model = new UserDetailModel()
                {
                    Action = "EditUser",
                    User   = user,
                    Filter = filter,
                    Roles  = LookupServices.GetRoleOptions(user.RoleName)
                };

                ViewBag.Locations = LocationServices.GetLocationLookup(true, model.User.LocationId);
                return(View("UserDetail", model));
            }
        }
Example #9
0
        public ActionResult Edit(TenantLocations tenantwarehouse)
        {
            if (ModelState.IsValid)
            {
                // get properties of tenant
                caTenant tenant = caCurrent.CurrentTenant();
                // get properties of user
                caUser user = caCurrent.CurrentUser();

                _tenantLocationServices.UpdateTenantLocation(tenantwarehouse, user.UserId, tenant.TenantId);

                return(RedirectToAction("Index"));
            }
            ViewBag.TenantLocations = LookupServices.GetAllWarehousesForTenant(CurrentTenantId, (int)tenantwarehouse.TenantId);

            ViewBag.AllTerminals = _terminalServices.GetAllTerminalsWithoutMobileLocationLinks(CurrentTenantId, tenantwarehouse.SalesTerminalId).Select(m => new SelectListItem()
            {
                Value = m.TerminalId.ToString(), Text = m.TerminalName + " " + m.TermainlSerial
            });
            ViewBag.AllDrivers = _employeeServices.GetAllEmployeesWithoutResourceLinks(CurrentTenantId, tenantwarehouse.SalesManUserId).Select(m => new SelectListItem()
            {
                Value = m.AuthUserId.ToString(), Text = m.SurName + " " + m.FirstName
            });

            return(View(tenantwarehouse));
        }
Example #10
0
        public ActionResult EditAccount(int id, AccountFilterModel filter, FormCollection collection)
        {
            var account = AccountServices.GetAccount(id);

            try
            {
                UpdateModel(account);
                AccountServices.UpdateAccount(account);

                return(RedirectToAction("AccountListing", filter.GenerateAccountListingRoute()));
            }
            catch (Exception ex)
            {
                // Invalid - redisplay with errors
                Logger.Error(ex.ToString());
                ModelState.AddModelError(String.Empty, Constants.ServerError);
                var model = new AccountDetailModel()
                {
                    Action  = "EditAccount",
                    Account = account,
                    Filter  = filter
                };

                ViewBag.AccountTypes = AccountTypeServices.GetAccountTypes(false, account.AccountTypeId);
                ViewBag.StateCodes   = LookupServices.GetStateOptions(account.StateCode);

                return(View("AccountDetail", model));
            }
        }
Example #11
0
        public void AccountAddressSessionInit()
        {
            Session["addresses"] = null;
            Session["contacts"]  = null;
            List <AccountAddresses> lstAddresses = new List <AccountAddresses>();

            Session["addresses"] = lstAddresses;
            List <AccountContacts> lstContacts = new List <AccountContacts>();

            Session["contacts"] = lstContacts;

            caUser user = caCurrent.CurrentUser();

            var cntries = (from cntry in LookupServices.GetAllGlobalCountries()
                           select new
            {
                CountryId = cntry.CountryID,
                CountryName = cntry.CountryName + "-" + cntry.CountryCode
            }).ToList();

            ViewBag.Countries     = new SelectList(cntries.OrderBy(o => o.CountryId), "CountryID", "CountryName");
            ViewBag.Currencies    = new MultiSelectList(LookupServices.GetAllGlobalCurrencies().OrderBy(o => o.CurrencyID), "CurrencyId", "CurrencyName");
            ViewBag.AccountStatus = new SelectList(LookupServices.GetAllAccountStatuses(), "AccountStatusID", "AccountStatus");
            ViewBag.PriceGroups   = new MultiSelectList(LookupServices.GetAllPriceGroups(CurrentTenantId), "PriceGroupID", "Name");
            ViewBag.OwnerUsers    = new SelectList(_userService.GetAllAuthUsers(CurrentTenantId), "UserId", "UserName");
            ViewBag.OwnerUserId   = user.UserId;
        }
Example #12
0
        private void SetDropdowns()
        {
            var tenant = caCurrent.CurrentTenant();

            ViewBag.LocationGroups = LookupServices.GetAllValidLocationGroups(CurrentTenantId)
                                     .Select(m => new
            {
                Id    = m.LocationGroupId,
                Group = m.Locdescription
            }).ToList();
            ViewBag.DimensionUOMs = (from duom in LookupServices.GetAllValidGlobalUoms(EnumUomType.Dimensions)
                                     select new
            {
                Id = duom.UOMId,
                DUOM = duom.UOM
            }).ToList();

            ViewBag.UOMs = (from duom in LookupServices.GetAllValidGlobalUoms(EnumUomType.Weight)
                            select new
            {
                Id = duom.UOMId,
                UOM = duom.UOM
            }).ToList();

            ViewBag.LocationTypes = LookupServices.GetAllValidLocationTypes(CurrentTenantId);
            ViewBag.Products      = _productServices.GetAllValidProductMasters(tenant.TenantId);
        }
Example #13
0
        public ActionResult _Products(int LocationId)
        {
            ViewBag.locationid = LocationId;
            var model = LookupServices.GetProductsByLocationId(LocationId, CurrentTenantId).ToList();

            return(PartialView(model));
        }
Example #14
0
        // GET: /Warehouse/Create
        public ActionResult Create()
        {
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }
            ViewBag.TenantLocations = LookupServices.GetAllWarehousesForTenant(CurrentTenantId).Select(m => new SelectListItem()
            {
                Value = m.WarehouseId.ToString(), Text = m.WarehouseName
            });

            ViewBag.AllTerminals = _terminalServices.GetAllTerminalsWithoutMobileLocationLinks(CurrentTenantId).Select(m => new SelectListItem()
            {
                Value = m.TerminalId.ToString(), Text = m.TerminalName + " " + m.TermainlSerial
            });
            ViewBag.AllDrivers = _employeeServices.GetAllEmployeesWithoutResourceLinks(CurrentTenantId).Select(m => new SelectListItem()
            {
                Value = m.AuthUserId.ToString(), Text = m.SurName + " " + m.FirstName
            });

            ViewBag.CountryId   = new SelectList(LookupServices.GetAllGlobalCountries(), "CountryId", "CountryName");
            ViewBag.AllVehicles = _marketServices.GetAllValidMarketVehicles(CurrentTenantId).MarketVehicles.Select(m => new SelectListItem()
            {
                Value = m.Id.ToString(), Text = m.Name
            });
            return(View());
        }
Example #15
0
        // GET: /Tenant/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }

            var tenant = _tenantServices.GetByClientId((int)id);

            if (tenant == null)
            {
                return(HttpNotFound());
            }
            var cntries = (from cntry in LookupServices.GetAllGlobalCountries()
                           select new
            {
                CountryId = cntry.CountryID,
                CountryName = cntry.CountryName + "-" + cntry.CountryCode
            }).ToList();

            ViewBag.Countries  = new SelectList(cntries.OrderBy(o => o.CountryId), "CountryID", "CountryName");
            ViewBag.Currencies = new MultiSelectList(LookupServices.GetAllGlobalCurrencies().OrderBy(o => o.CurrencyID), "CurrencyId", "CurrencyName");
            return(View(tenant));
        }
Example #16
0
        // GET: AppointmentResources/Create
        public ActionResult Create()
        {
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }

            // get properties of current tenant
            var tenant = caCurrent.CurrentTenant();

            // get properties of user
            caUser user = caCurrent.CurrentUser();

            var wareh = _activityServices.GetAllPermittedWarehousesForUser(user.UserId, user.TenantId, user.SuperUser == true, false);

            var jTypes = LookupServices.GetAllJobTypes(CurrentTenantId).Select(m => new { m.JobTypeId, m.Name }).ToList();

            ViewBag.JobTypes        = new MultiSelectList(jTypes, "JobTypeId", "Name");
            ViewBag.RolesList1      = new SelectList(_rolesServices.GetAllRoles(tenant.TenantId), "Id", "RoleName");
            ViewBag.GroupsList1     = new SelectList(_groupsServices.GetAllGroups(tenant.TenantId), "Id", "GroupName");
            ViewBag.Countries       = new SelectList(LookupServices.GetAllGlobalCountries(), "CountryID", "CountryName");
            ViewBag.TenantLocations = new MultiSelectList(_tenantLocationsServices.GetAllTenantLocations(tenant.TenantId).Where(x => wareh.Any(a => a.WId == x.WarehouseId)), "WarehouseId", "WarehouseName");
            ViewBag.Users           = new SelectList(_userService.GetAllAuthUsers(CurrentTenantId), "UserId", "UserName");
            return(View());
        }
        public ActionResult Create(InventoryTransaction model, string back)
        {
            try
            {
                int     transportType = model.InventoryTransactionTypeId;
                int     productId     = (int)Session["pId"];
                decimal qty           = model.Quantity;
                int     orderId       = model.OrderID ?? default(int);

                Inventory.StockTransaction(productId, transportType, qty, orderId);

                if (back == "1")
                {
                    return(Redirect(Url.Action("Edit", "Products", new { id = Session["pId"] }) + "#product-inventory"));
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception exp)
            {
                var orders = OrderService.GetAllOrders(CurrentTenantId).ToList();

                var inventoryTransactionTypes = LookupServices.GetAllInventoryTransactionTypes().ToList();

                ModelState.AddModelError("", exp.Message);
                ViewBag.OrderID = new SelectList(orders, "OrderId", "OrderNumber", orders.FirstOrDefault(a => a.OrderID == model.OrderID));
                ViewBag.InventoryTransactionTypeId = new SelectList(inventoryTransactionTypes, "InventoryTransactionTypeId", "InventoryTransactionTypeName", inventoryTransactionTypes.FirstOrDefault(a => a.InventoryTransactionTypeId == model.InventoryTransactionTypeId));
                return(View(model));
            }
        }
Example #18
0
 public ActionResult VanSalesCashReport()
 {
     ViewBag.MobileLocations = LookupServices.GetAllWarehousesForTenant(CurrentTenantId, null, true).Select(x => new SelectListItem()
     {
         Text = x.WarehouseName, Value = x.WarehouseId.ToString()
     }).ToList();
     return(View("VanSalesCashReport"));
 }
Example #19
0
        public async Task <ActionResult> GetPoliciesAjaxHandler(string filter, string accountId)
        {
            lookupServices = new LookupServices();
            List <PolicySimple> list = new List <PolicySimple>();

            list = lookupServices.GetPolicies(filter, accountId);
            return(Json(list, JsonRequestBehavior.AllowGet));
        }
Example #20
0
        public ActionResult _LocationsList()
        {
            ViewBag.settingsName = "Locations";
            ViewBag.routeValues  = new { Controller = "Locations", Action = "_LocationsList" };
            var locations = LookupServices.GetAllLocations(CurrentTenantId).ToList();

            return(PartialView("_Locations", locations));
        }
Example #21
0
 public ActionResult _AccountAddress()
 {
     ViewBag.GlobalCountries = LookupServices.GetAllGlobalCountries();
     return(PartialView("_AccountAddress", new AccountAddresses()
     {
         AddTypeDefault = true
     }));
 }
        public ActionResult ImportProductPriceCsv(int PriceGroupId)
        {
            var obj = LookupServices.GetAllPriceGroups(CurrentTenantId).Where(u => u.PriceGroupID == PriceGroupId)?.Select(u => u.Name).ToList();

            ViewBag.ProductGroup   = obj.FirstOrDefault();
            ViewBag.ProductGroupId = PriceGroupId;
            return(View());
        }
        public ActionResult _ProductSpecialPriceGroups()
        {
            var priceGroups = LookupServices.GetAllPriceGroups(CurrentTenantId).ToList();

            var model = priceGroups.Select(x => Mapper.Map <TenantPriceGroups, TenantPriceGroupViewModel>(x)).ToList();

            return(PartialView("_ProductGroupGridPartial", model));
        }
Example #24
0
        public ActionResult AccountCustomAjaxHandler(jQueryDataTableParamModel param, string accountType)
        {
            lookupServices = new LookupServices();
            List <AccountSimpleModel> objectList = new List <AccountSimpleModel>();

            if (!string.IsNullOrEmpty(accountType))
            {
                objectList = lookupServices.GetAccounts(param.sSearch, accountType);
            }

            IEnumerable <AccountSimpleModel> filteredRecords = objectList;

            var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
            Func <AccountSimpleModel, string> orderingFunction = (c => sortColumnIndex == 1 ? c.AccountId :
                                                                  sortColumnIndex == 2 ? c.AccountName :
                                                                  sortColumnIndex == 3 ? c.AccountType :
                                                                  sortColumnIndex == 4 ? c.AccountManager :
                                                                  c.AccountName);

            var sortDirection = Request["sSortDir_0"]; // asc or desc

            if (sortDirection == "asc")
            {
                filteredRecords = filteredRecords.OrderBy(orderingFunction);
            }
            else
            {
                filteredRecords = filteredRecords.OrderByDescending(orderingFunction);
            }

            if (!string.IsNullOrEmpty(param.sSearch))
            {
                filteredRecords = filteredRecords
                                  .Where(c => c.AccountName.ToUpper().Contains(param.sSearch.ToUpper()));
                //           ||
                //           c.Town.Contains(param.sSearch));
            }



            List <string[]> aData = new List <string[]>();

            foreach (AccountSimpleModel item in filteredRecords)
            {
                string[] arry = new string[] { item.AccountId, item.AccountName, item.AccountType, item.AccountManager, item.BillingMethod };
                aData.Add(arry);
            }

            return(Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = 97,
                iTotalDisplayRecords = 3,
                aaData = aData
            },

                        JsonRequestBehavior.AllowGet));
        }
Example #25
0
        public ActionResult OcNoAjaxHandler(jQueryDataTableParamModel param)
        {
            lookupServices = new LookupServices();
            List <CRMOCNumSimple> objectList = new List <CRMOCNumSimple>();

            if (!string.IsNullOrEmpty(param.sSearch))
            {
                objectList = lookupServices.GetOCNumLookupNew(param.sSearch);
            }

            IEnumerable <CRMOCNumSimple> filteredRecords = objectList;

            var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
            Func <CRMOCNumSimple, string> orderingFunction = (c => sortColumnIndex == 1 ? c.AccountId :
                                                              sortColumnIndex == 2 ? c.Account :
                                                              sortColumnIndex == 3 ? c.OCNum :
                                                              c.OCNum);

            var sortDirection = Request["sSortDir_0"]; // asc or desc

            if (sortDirection == "asc")
            {
                filteredRecords = filteredRecords.OrderBy(orderingFunction);
            }
            else
            {
                filteredRecords = filteredRecords.OrderByDescending(orderingFunction);
            }

            if (!string.IsNullOrEmpty(param.sSearch))
            {
                filteredRecords = filteredRecords
                                  .Where(c => c.OCNum.ToUpper().Contains(param.sSearch.ToUpper()));
                //           ||
                //           c.Town.Contains(param.sSearch));
            }



            List <string[]> aData = new List <string[]>();

            foreach (CRMOCNumSimple item in filteredRecords)
            {
                string[] arry = new string[] { item.AccountId, item.Account, item.OCNum };
                aData.Add(arry);
            }

            return(Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = 97,
                iTotalDisplayRecords = 3,
                aaData = aData
            },

                        JsonRequestBehavior.AllowGet));
        }
Example #26
0
 public ActionResult DeleteConfirmed(int id)
 {
     if (!caSession.AuthoriseSession())
     {
         return(Redirect((string)Session["ErrorUrl"]));
     }
     LookupServices.DeleteLocationById(id, CurrentTenantId, CurrentUserId);
     return(RedirectToAction("Index"));
 }
        // GET: JobTypes/Delete/5
        public ActionResult Delete(int id)
        {
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }

            return(View(LookupServices.GetJobTypeById(id, CurrentTenantId)));
        }
Example #28
0
        public ActionResult BulkCreate(Locations model, List <int> ProductIds, int?StartValue, int?EndValue)
        {
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }
            if (!(StartValue != null && EndValue != null))
            {
                ModelState.AddModelError("", "Start and End value must be provided");
                SetDropdowns();
                return(View(model));
            }
            var codes = new List <string>();
            var names = new List <string>();

            for (var ctr = StartValue; ctr <= EndValue; ctr++)
            {
                codes.Add(model.LocationCode + ctr);
                names.Add(model.LocationName + ctr);
            }

            var ccodes = LookupServices.GetAllLocations(CurrentTenantId).Where(a => codes.Contains(a.LocationCode)).Select(a => a.LocationCode).Distinct().ToList();
            var nnames = LookupServices.GetAllLocations(CurrentTenantId).Where(a => names.Contains(a.LocationName)).Select(a => a.LocationName).Distinct().ToList();

            string cmsg = null;
            string nmsg = null;

            if (ccodes.Count > 0 || nnames.Count > 0)
            {
                if (ccodes.Count > 0)
                {
                    cmsg = "Following codes already exists</br>" + Environment.NewLine;
                    foreach (var cc in ccodes)
                    {
                        cmsg += cc + "</br>";
                    }
                    ModelState.AddModelError("", cmsg);
                }
                if (nnames.Count > 0)
                {
                    nmsg = "Following names already exists</br>" + Environment.NewLine;
                    foreach (var nn in nnames)
                    {
                        nmsg += nn + "</br>";
                    }
                    ModelState.AddModelError("", nmsg);
                }

                SetDropdowns();
                return(View(model));
            }

            LookupServices.BulkCreateProductsLocation(model, ProductIds, StartValue, EndValue, CurrentTenantId, CurrentWarehouseId, CurrentUserId);

            return(RedirectToAction("Index"));
        }
Example #29
0
        public ActionResult StoreAjaxHandler(jQueryDataTableParamModel param, string AccountId)
        {
            lookupServices = new LookupServices();
            List <StoreSimple> objectList = new List <StoreSimple>();

            objectList =
                lookupServices.GetStores("", AccountId);
            Session[SessionHelper.StoreobjectList] = objectList;

            IEnumerable <StoreSimple> filteredRecords = objectList;

            var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
            Func <StoreSimple, string> orderingFunction = (c => sortColumnIndex == 1 ? c.StoreName :
                                                           sortColumnIndex == 2 ? c.Address :
                                                           c.StoreName);

            var sortDirection = Request["sSortDir_0"]; // asc or desc

            if (sortDirection == "asc")
            {
                filteredRecords = filteredRecords.OrderBy(orderingFunction);
            }
            else
            {
                filteredRecords = filteredRecords.OrderByDescending(orderingFunction);
            }

            if (!string.IsNullOrEmpty(param.sSearch))
            {
                filteredRecords = filteredRecords
                                  .Where(c => c.StoreName.ToUpper().Contains(param.sSearch.ToUpper())
                                         ||
                                         c.Address.ToUpper().Contains(param.sSearch.ToUpper()));
                //           ||
                //           c.Town.Contains(param.sSearch));
            }


            List <string[]> aData = new List <string[]>();

            foreach (StoreSimple item in filteredRecords)
            {
                string[] arry = new string[] { item.StoreName, item.Address, item.Region };
                aData.Add(arry);
            }

            return(Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = 97,
                iTotalDisplayRecords = 3,
                aaData = aData
            },

                        JsonRequestBehavior.AllowGet));
        }
Example #30
0
        public ActionResult Create()
        {
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }

            ViewBag.InventoryTransactionTypeId = new SelectList(LookupServices.GetAllInventoryTransactionTypes(), "InventoryTransactionTypeId", "OrderType", LookupServices.GetAllInventoryTransactionTypes().Select(x => x.OrderType).FirstOrDefault());

            return(View("Create", new TenantEmailTemplates()));
        }