Example #1
0
        //starts UI and populates it with current EmployeeID.  Default is 0 for none.
        public void Run()
        {
            InitializeComponent();
            var _context = new AdventureWorksLTContext();
            var query    = from c in _context.Employee where c.EmployeeID == EmployeeID select c;

            this.DataContext = query.FirstOrDefault();
        }
Example #2
0
        //starts UI and populates it with a selected EmployeeID.
        public void GetEmployeeByID(int id)
        {
            EmployeeID = id;
            InitializeComponent();
            var _context = new AdventureWorksLTContext();
            var query    = from c in _context.Employee where c.EmployeeID == id select c;

            this.DataContext = query.FirstOrDefault();
            Show();
        }
Example #3
0
 //creates new employee and saves it to databse from input from user.
 private void NewEmployee()
 {
     using (var _context = new AdventureWorksLTContext())
     {
         Employee employee = new Employee();
         employee.FirstName   = FirstNameTextBox.Text;
         employee.LastName    = LastNameTextBox.Text;
         employee.Prefix      = PrefixComboBox.Text;
         employee.HomePhone   = HomePhoneTextBox.Text;
         employee.MobilePhone = MobilePhoneTextBox.Text;
         employee.Skype       = SkypeTextBox.Text;
         employee.PhotoPath   = ImageTextBox.Text;
         employee.Address     = AddressTextBox.Text;
         _context.Employee.Add(employee);
         _context.SaveChanges();
     }
 }
Example #4
0
 //deletes selected employee from database
 private void DeleteEmployee(int id)
 {
     try
     {
         using (var _context = new AdventureWorksLTContext())
         {
             var employee = _context.Employee.Where(s => s.EmployeeID == id).First();
             _context.Employee.Remove(employee);
             _context.SaveChanges();
             Run();
         }
     }
     catch
     {
         MessageBox.Show("Please try again.");
     }
 }
Example #5
0
        //updates employee information in database on selected employee
        private void UpdateEmployeeById(int id)
        {
            using (var _context = new AdventureWorksLTContext())
            {
                Employee employee = _context.Employee.FirstOrDefault(c => c.EmployeeID == id);
                employee.FirstName   = FirstNameTextBox.Text;
                employee.LastName    = LastNameTextBox.Text;
                employee.Prefix      = PrefixComboBox.Text;
                employee.HomePhone   = HomePhoneTextBox.Text;
                employee.MobilePhone = MobilePhoneTextBox.Text;
                employee.Skype       = SkypeTextBox.Text;
                employee.PhotoPath   = ImageTextBox.Text;
                employee.Address     = AddressTextBox.Text;

                _context.SaveChanges();
            }
        }
 public CustomersController(AdventureWorksLTContext context)
 {
     _context = context;
 }
Example #7
0
 public ProductsController(AdventureWorksLTContext context)
 {
     _context = context;
 }
Example #8
0
 public ReportDataController(AdventureWorksLTContext adventureWorksLTContext)
 {
     _dbContext = adventureWorksLTContext;
 }
Example #9
0
 public CustomersController(ILogger <CustomersController> logger, TelemetryClient telemetry, AdventureWorksLTContext context)
 {
     _logger    = logger;
     _telemetry = telemetry;
     _context   = context;
 }