Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!(Request.IsAuthenticated && EmployeeId.HasValue))
            {
                Response.Redirect("~/Account/Login", true);
            }
            //else if (!(User.IsInRole(Settings.DirectorRole) || User.IsInRole(Settings.OfficeManagerRole))){
            //    Response.Redirect("~/Subsystem/Purchasing/Default");
            //}


            var controller = new eRaceController();
            var employee   = controller.GetEmployeeName(EmployeeId);

            EmployeeUser.Text = $"Hello there! {employee.UserName} ({employee.EmployeeRole})";


            if (int.Parse(VendorDropDown.SelectedIndex.ToString()) == 0)
            {
                SaveOrder.Visible   = false;
                PlaceOrder.Visible  = false;
                DeleteOrder.Visible = false;
                Subtotal.Text       = "0";
                Tax.Text            = "0";
                Total.Text          = "0";
            }
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!(Request.IsAuthenticated && EmployeeId.HasValue))
            {
                Response.Redirect("~/Account/Login", true);
            }
            //else if (!User.IsInRole(Settings.ClerkRole))
            //{
            //    Response.Redirect("~/Account/Login", true);
            //}

            var controller2 = new eRaceController();
            var employee    = controller2.GetEmployeeName(EmployeeId);

            EmployeeUser.Text = $"Hello there! {employee.UserName} ({employee.EmployeeRole})";

            if (!IsPostBack)
            {
                var controller = new SalesController();
                var date       = controller.ListCategory();
                CategoryList.DataSource     = date;
                CategoryList.DataTextField  = nameof(CategoryInfo.CategoryName);
                CategoryList.DataValueField = nameof(CategoryInfo.ID);
                CategoryList.DataBind();
                CategoryList.Items.Insert(0, new ListItem("select a category", "0"));
            }
        }
        protected override void Seed(ApplicationDbContext context)
        {
            #region Seed Security Roles
            // Administrator Role
            var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));
            roleManager.Create(new IdentityRole(AdminRole));

            // Employee role
            var controller = new eRaceController();
            var userRoles  = controller.ListPositions();
            foreach (var user in userRoles)
            {
                roleManager.Create(new IdentityRole(user.Position));
            }



            #endregion

            #region Seed the users
            string adminUser     = ConfigurationManager.AppSettings["adminUserName"];
            string adminEmail    = ConfigurationManager.AppSettings["adminEmail"];
            string adminPassword = ConfigurationManager.AppSettings["adminPassword"];
            var    userManager   = new ApplicationUserManager(new UserStore <ApplicationUser>(context));
            var    result        = userManager.Create(new ApplicationUser
            {
                UserName       = adminUser,
                Email          = adminEmail,
                EmailConfirmed = true
            }, adminPassword);
            if (result.Succeeded)
            {
                userManager.AddToRole(userManager.FindByName(adminUser).Id, Settings.AdminRole);
            }

            //employee accounts
            string defaultPassword = ConfigurationManager.AppSettings["defaultPassword"];
            string emailDomain     = ConfigurationManager.AppSettings["companyDomain"];
            IEnumerable <EmployeePositions> employees = controller.ListEmployeeAndPosition(emailDomain);
            foreach (var person in employees)
            {
                result = userManager.Create(new ApplicationUser
                {
                    UserName       = person.UserName,
                    Email          = person.EmailAddress,
                    EmailConfirmed = true,
                    EmployeeId     = person.UserID,
                    Position       = person.Title
                }, defaultPassword);
                if (result.Succeeded)
                {
                    userManager.AddToRole(userManager.FindByName(person.UserName).Id, person.Title);
                }
            }
            #endregion


            base.Seed(context);
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!(Request.IsAuthenticated && EmployeeId.HasValue))
            {
                Response.Redirect("~/Account/Login", true);
            }
            //else if (! User.IsInRole(Settings.ClerkRole))
            //{
            //    Response.Redirect("~/Account/Login", true);
            //}

            var controller = new eRaceController();
            var employee   = controller.GetEmployeeName(EmployeeId);

            EmployeeUser.Text = $"Hello there! {employee.UserName} ({employee.EmployeeRole})";
        }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.IsInRole("Clerk"))
            {
                Response.Redirect("~", true);
            }

            var controller   = new eRaceController();
            var EmployeeName = controller.GetStoreEmployees(EmployeeId);

            EmployeeLabel.Text = EmployeeName.FullName;


            decimal amount = CalculateTotal();
            decimal tax    = amount * (decimal)0.05;
            decimal total  = amount + tax;

            Subtotal.Text = amount.ToString("C");
            GST.Text      = tax.ToString("C");
            Total.Text    = total.ToString("C");
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // user items
            if (!User.IsInRole("Clerk"))
            {
                Response.Redirect("~", true);
            }

            var controller   = new eRaceController();
            var EmployeeName = controller.GetStoreEmployees(EmployeeId);

            EmployeeLabel.Text = EmployeeName.FullName;

            //if employee cart has items
            var salesController        = new SalesController();
            List <CartItems> cartItems = salesController.ItemsInCart(EmployeeId);

            if (cartItems.Count > 0 && !IsPostBack)
            {
                Cart.DataSource = cartItems;
                Cart.DataBind();
            }
        }