Пример #1
0
        public void GetSetting()
        {
            CompanySettingModels cModel = new CompanySettingModels();
            var company = Entities.S_CompanySetting.ToList();

            foreach (var item in company)
            {
                cModel.CompanyID         = item.CompanyID;
                cModel.CompanyName       = item.CompanyName;
                cModel.IsBarcode         = item.IsBarcode;
                cModel.IsMultiBranch     = item.IsMultiBranch;
                cModel.IsMultiUnit       = item.IsMultiUnit;
                cModel.IsProductByBranch = item.IsDifProductByBranch;
                cModel.IsProductPhoto    = item.IsProductPhoto;
                cModel.IsProductVariant  = item.IsProductVariant;
            }
            ViewBag.isProductPhoto = cModel.IsProductPhoto;
            if (cModel.IsMultiBranch == true && cModel.IsProductByBranch == true)
            {
                ViewBag.isMultiBranchDifProductByBranch = true;
            }
            else
            {
                ViewBag.isMultiBranchDifProductByBranch = false;
            }
            ViewBag.isMultiUnit      = cModel.IsMultiUnit;
            ViewBag.isProductVariant = cModel.IsProductVariant;
        }
Пример #2
0
        public void GetCompanySetting()
        {
            CompanySettingModels cModel = new CompanySettingModels();
            var isProductPhoto          = Entities.S_CompanySetting.Select(company => company.IsProductPhoto);

            cModel.IsProductPhoto  = isProductPhoto.FirstOrDefault();
            ViewBag.isProductPhoto = cModel.IsProductPhoto;
        }
Пример #3
0
        public bool isMultiBranch()
        {
            CompanySettingModels cModel = new CompanySettingModels();
            var isMultiBranch           = Entities.S_CompanySetting.Select(company => company.IsMultiBranch);

            cModel.IsMultiBranch = isMultiBranch.FirstOrDefault();
            return(Convert.ToBoolean(cModel.IsMultiBranch));
        }
Пример #4
0
        public void GetisMultiBranch()
        {
            CompanySettingModels cModel = new CompanySettingModels();
            var isMultiBranch           = Entities.S_CompanySetting.Select(company => company.IsMultiBranch);

            cModel.IsMultiBranch  = isMultiBranch.FirstOrDefault();
            ViewBag.isMultiBranch = cModel.IsMultiBranch;
        }
Пример #5
0
        public bool isMultiUnit()
        {
            CompanySettingModels cModel = new CompanySettingModels();
            var company = Entities.S_CompanySetting.Select(c => c.IsMultiUnit);

            cModel.IsMultiUnit = company.FirstOrDefault();
            return(Convert.ToBoolean(cModel.IsMultiUnit));
        }
Пример #6
0
        public void GetisMultiUnit()
        {
            CompanySettingModels cModel = new CompanySettingModels();
            var isMultiUnit             = Entities.S_CompanySetting.Select(company => company.IsMultiUnit);

            cModel.IsMultiUnit  = isMultiUnit.FirstOrDefault();
            ViewBag.isMultiUnit = cModel.IsMultiUnit;
        }
Пример #7
0
        public ActionResult Login()
        {
            InventoryDBEntities entity = new InventoryDBEntities();

            UserModels.LoginUserModel model  = new UserModels.LoginUserModel();
            CompanySettingModels      cModel = new CompanySettingModels();

            var isMultiBranch = entity.S_CompanySetting.Select(c => c.IsMultiBranch);

            cModel.IsMultiBranch  = isMultiBranch.FirstOrDefault();
            ViewBag.IsMultiBranch = cModel.IsMultiBranch;

            int?firstBranchId = 0;

            if (cModel.IsMultiBranch == true)
            {
                foreach (var branch in entity.S_Branch)
                {
                    model.Branches.Add(new SelectListItem {
                        Text = branch.BranchName, Value = branch.BranchID.ToString()
                    });
                }
                for (int i = 0; i < model.Branches.Count(); i++)
                {
                    firstBranchId = Convert.ToInt32(model.Branches[i].Value);
                    break;
                }
                if (firstBranchId.HasValue)
                {
                    var users = (from user in entity.S_User where user.BranchID == firstBranchId.Value select user).ToList();
                    foreach (var user in users)
                    {
                        model.Users.Add(new SelectListItem {
                            Text = user.UserName, Value = user.UserID.ToString()
                        });
                    }
                }
            }
            else
            {
                var users = (from user in entity.S_User select user).ToList();
                foreach (var user in users)
                {
                    model.Users.Add(new SelectListItem {
                        Text = user.UserName, Value = user.UserID.ToString()
                    });
                }
            }
            return(View(model));
        }
Пример #8
0
        public ActionResult Login(int?branchId, int userId, string userPassword, string userName, string branchName, bool clickedLogin)
        {
            InventoryDBEntities entity = new InventoryDBEntities();

            UserModels.LoginUserModel model  = new UserModels.LoginUserModel();
            CompanySettingModels      cModel = new CompanySettingModels();

            var isMultiBranch = entity.S_CompanySetting.Select(c => c.IsMultiBranch);

            cModel.IsMultiBranch  = isMultiBranch.FirstOrDefault();
            ViewBag.IsMultiBranch = cModel.IsMultiBranch;

            if (clickedLogin)
            {
                int?result = Convert.ToInt32(entity.PrcValidateUser(userId, userPassword).FirstOrDefault());

                switch (result.Value)
                {
                case 1:
                    Session["LoginUserID"]     = userId;
                    Session["LoginUserName"]   = userName;
                    Session["LoginBranchID"]   = branchId;
                    Session["LoginBranchName"] = branchName;
                    return(RedirectToAction("Index", "Home"));

                case -1:
                    ViewBag.Message = "Password is incorrect.";
                    break;

                default: break;
                }
            }

            if (cModel.IsMultiBranch == true)
            {
                foreach (var branch in entity.S_Branch)
                {
                    model.Branches.Add(new SelectListItem {
                        Text = branch.BranchName, Value = branch.BranchID.ToString()
                    });
                }
                if (branchId.HasValue)
                {
                    var users = (from user in entity.S_User where user.BranchID == branchId.Value select user).ToList();
                    foreach (var user in users)
                    {
                        model.Users.Add(new SelectListItem {
                            Text = user.UserName, Value = user.UserID.ToString()
                        });
                    }
                }
            }
            else
            {
                var users = (from user in entity.S_User select user).ToList();
                foreach (var user in users)
                {
                    model.Users.Add(new SelectListItem {
                        Text = user.UserName, Value = user.UserID.ToString()
                    });
                }
            }

            return(View(model));
        }