Esempio n. 1
0
        public ActionResult StaffManagement()
        {
            IC_MotersEntities db = new IC_MotersEntities();

            #region SQO

            List <Models.StaffClass> staffList = db.People.Where(x => x.PersonTypeId != 4).Select(x => new StaffClass
            {
                StaffId   = x.PersonId,
                FirstName = x.FirstName,
                LastName  = x.LastName,
                Address1  = x.Address1,
                Address2  = x.Address2
            }).ToList();

            //-------------------------
            //var staffList = db.People.Where(x => x.PersonTypeId != 4).Select(x => new StaffClass
            //{ StaffId = x.PersonId, FirstName = x.FirstName,
            //    LastName = x.LastName, Address1 = x.Address1,
            //    Address2 = x.Address2
            //}).ToList();
            #endregion

            return(View(staffList));
        }
        public ActionResult CreateStaffMember(StaffClass viewModel)
        {
            IC_MotersEntities db = new IC_MotersEntities();

            if (!ModelState.IsValid)
            {
                viewModel.SuburbTypes = db.SuburbTypes;
                return(View(viewModel));
            }
            var staff = new Person
            {
                FirstName    = viewModel.FirstName,
                LastName     = viewModel.LastName,
                Salary       = viewModel.Salary,
                Address1     = viewModel.Address1,
                Address2     = viewModel.Address2,
                SuburbId     = viewModel.SuburbId,
                PhoneNumber  = viewModel.PhoneNumber,
                PersonTypeId = 3
            };

            db.People.Add(staff);
            db.SaveChanges();

            return(RedirectToAction("StaffManagement", "Home"));
        }
Esempio n. 3
0
        public ActionResult AllCustomerOrder()
        {
            IC_MotersEntities        db       = new IC_MotersEntities();
            List <Models.StaffClass> allOrder = new List <StaffClass>();
            var orders = (from pn in db.People
                          join so in db.SalesOrders on pn.PersonId equals so.PersonId
                          join od in db.SalesOrderDetails on so.SalesOrderId equals od.SalesOrderId
                          select new
            {
                StaffId = pn.PersonId,
                LastName = pn.LastName,
                SalesOrderId = so.SalesOrderId,
                OrderNumber = so.OrderNumber,
                OrderTime = so.OrderDate,
                ProductID = od.ProductId
            }).ToList();

            foreach (var item in orders)
            {
                allOrder.Add(new StaffClass()
                {
                    StaffId      = item.StaffId,
                    LastName     = item.LastName,
                    SalesOrderId = item.SalesOrderId,
                    OrderNumber  = item.OrderNumber,
                    OrderTime    = item.OrderTime,
                    ProductID    = item.ProductID
                });
            }

            return(View(allOrder));
        }
Esempio n. 4
0
        public ActionResult CustomerOrder(int staffId)
        {
            IC_MotersEntities db = new IC_MotersEntities();

            List <Models.StaffClass> orderList = new List <StaffClass>();


            var joinQuery = (from pn in db.People
                             join so in db.SalesOrders on pn.PersonId equals so.PersonId
                             //join od in db.SalesOrderDetails on so.SalesOrderId equals od.SalesOrderId
                             where pn.PersonId == staffId
                             select new
            {
                StaffId = pn.PersonId,
                LastName = pn.LastName,
                SalesOrderId = so.SalesOrderId,
                OrderNumber = so.OrderNumber,
                // ProductID=od.ProductId
            }).ToList();

            foreach (var item in joinQuery)
            {
                orderList.Add(new StaffClass()
                {
                    StaffId      = item.StaffId,
                    LastName     = item.LastName,
                    SalesOrderId = item.SalesOrderId,
                    OrderNumber  = item.OrderNumber,
                    // ProductID=item.ProductID
                });
            }
            return(View(orderList));
        }
Esempio n. 5
0
        public ActionResult EditStaffMember(int staffId)
        {
            IC_MotersEntities db = new IC_MotersEntities();

            var selectedStaff = db.People.Find(staffId);

            var staffToEdit = new StaffClass
            {
                FirstName    = selectedStaff.FirstName,
                LastName     = selectedStaff.LastName,
                StaffId      = selectedStaff.PersonId,
                Address1     = selectedStaff.Address1,
                Salary       = selectedStaff.Salary,
                PersonTypeId = selectedStaff.PersonTypeId
            };

            if (selectedStaff.PersonTypeId == 4)
            {
                staffToEdit.isStaff = false;
            }
            else
            {
                staffToEdit.isStaff = true;

                staffToEdit.StaffTypeList = db.PersonTypes.ToList().Select(x => new SelectListItem
                {
                    Text  = x.Name,
                    Value = x.PersonTypeId.ToString()
                }).ToList();
            }
            return(View(staffToEdit));
        }
Esempio n. 6
0
        public ActionResult AddStaff()
        {
            IC_MotersEntities db = new IC_MotersEntities();
            var addStaff         = new StaffClass();

            return(View(addStaff));
        }
Esempio n. 7
0
        public ActionResult AddCustomer()
        {
            IC_MotersEntities db = new IC_MotersEntities();
            var addCustomer      = new StaffClass();

            return(View(addCustomer));
        }
        public ActionResult GetStaffList()
        {
            IC_MotersEntities db = new IC_MotersEntities();
            var staffList        = db.People.Select(x => new StaffData {
                staffId = x.PersonId, firstName = x.FirstName.Trim(), lastName = x.LastName.Trim()
            }).ToList();

            return(View(staffList));
        }
        public ActionResult MyView()
        {
            IC_MotersEntities db = new IC_MotersEntities();
            var personList       = db.People.Select(x => new BobViewModel {
                FirstName = x.FirstName, LastName = x.LastName
            }).ToList();

            return(View(personList));
        }
Esempio n. 10
0
        public ActionResult StaffManagement()
        {
            IC_MotersEntities db = new IC_MotersEntities();
            var stafflist        = db.People.Where(x => x.PersonTypeId != 4).Select(x => new StaffClass {
                StaffId  = x.PersonId, FirstName = x.FirstName,
                LastName = x.LastName, Address1 = x.Address1
            }).ToList();

            return(View(stafflist));
        }
        public ActionResult CreateStaffMember()
        {
            IC_MotersEntities db = new IC_MotersEntities();
            var viewModel        = new StaffClass
            {
                SuburbTypes = db.SuburbTypes.ToList()
            };

            return(View(viewModel));
        }
Esempio n. 12
0
        public ActionResult EditStaffMember(StaffClass staffData)
        {
            IC_MotersEntities db = new IC_MotersEntities();
            var newStaff         = db.People.Find(staffData.StaffId);

            newStaff.PersonId  = staffData.StaffId;
            newStaff.FirstName = staffData.FirstName.Trim();
            newStaff.LastName  = staffData.LastName.Trim();
            newStaff.Address1  = staffData.Address1.Trim();
            newStaff.Salary    = staffData.Salary;
            db.SaveChanges();
            return(RedirectToAction("StaffManagement", "Home"));
        }
Esempio n. 13
0
        public ActionResult EditStaffMember(int staffId)
        {
            IC_MotersEntities db = new IC_MotersEntities();

            var bob         = db.People.Find(staffId);
            var staffToEdit = new StaffClass
            {
                FirstName = bob.FirstName,
                LastName  = bob.LastName,
                StaffId   = bob.PersonId,
                Address1  = bob.Address1,
                Salary    = bob.Salary
            };

            return(View(staffToEdit));
        }
Esempio n. 14
0
        public ActionResult AddCustomer(StaffClass staffData)
        {
            IC_MotersEntities db       = new IC_MotersEntities();
            Person            newStaff = new Person();

            newStaff.PersonId     = staffData.StaffId;
            newStaff.FirstName    = staffData.FirstName.Trim();
            newStaff.LastName     = staffData.LastName.Trim();
            newStaff.Address1     = staffData.Address1.Trim();
            newStaff.PersonTypeId = 4;
            newStaff.SuburbId     = 3;
            newStaff.PhoneNumber  = staffData.PhoneNumber.Trim();
            db.People.Add(newStaff);
            db.SaveChanges();
            return(RedirectToAction("CustomerManagement", "Home"));
        }
Esempio n. 15
0
        public ActionResult EditStaffMember(int staffId)
        {
            IC_MotersEntities db = new IC_MotersEntities();

            var selectedStaff = db.People.Find(staffId);
            var staffToEdit   = new StaffClass
            {
                FirstName = selectedStaff.FirstName,
                LastName  = selectedStaff.LastName,
                StaffId   = selectedStaff.PersonId,
                Address1  = selectedStaff.Address1,
                Address2  = selectedStaff.Address2,
                Salary    = selectedStaff.Salary
            };

            return(View(staffToEdit));
        }
Esempio n. 16
0
        public ActionResult SearchAct(string nameToFind)
        {
            ViewBag.SearchKey = nameToFind;

            IC_MotersEntities db = new IC_MotersEntities();

            var selectedStaff1 = db.People.Where(x => x.LastName == nameToFind).Select(x => new StaffClass
            {
                FirstName = x.FirstName,
                LastName  = x.LastName,
                StaffId   = x.PersonId,
                Address1  = x.Address1,
                Address2  = x.Address2,
                Salary    = x.Salary
            }).ToList();

            return(View(selectedStaff1));
        }
Esempio n. 17
0
        public ActionResult StaffManagement(bool isStaff = true)
        {
            IC_MotersEntities db = new IC_MotersEntities();

            if (isStaff)
            {
                var staffList = db.People.Where(x => x.PersonTypeId != 4).Select(x => new StaffClass
                {
                    StaffId   = x.PersonId,
                    FirstName = x.FirstName,
                    LastName  = x.LastName,
                    Address1  = x.Address1
                }).ToList();
                StaffViewList staffViewList = new StaffViewList()
                {
                    StaffList = staffList,
                    ViewTitle = "Staff Management"
                };
                return(View(staffViewList));
            }
            else
            {
                var staffList = db.People.Where(x => x.PersonTypeId == 4).Select(x => new StaffClass
                {
                    StaffId   = x.PersonId,
                    FirstName = x.FirstName,
                    LastName  = x.LastName,
                    Address1  = x.Address1
                }).ToList();
                StaffViewList staffViewList = new StaffViewList()
                {
                    StaffList = staffList,
                    ViewTitle = "Customer Management"
                };
                return(View(staffViewList));
            }
        }