public void GetShifts() { try { lHRISShift = new List <HRISShift>(); using (var db = new LetranIntegratedSystemEntities()) { var shifts = db.HRISShifts.ToList(); foreach (var x in shifts) { HRISShift hsl = new HRISShift(); hsl.ShiftCode = x.ShiftCode; hsl.Description = x.Description; hsl.StartTime = x.StartTime; hsl.EndTime = x.EndTime; lHRISShift.Add(hsl); } dgShifts.ItemsSource = lHRISShift.OrderBy(m => m.ShiftCode); } } catch (Exception) { MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { try { using (var db = new LetranIntegratedSystemEntities()) { if (txtShiftCode.Text != null && startTimeComboBox.SelectedItem != null && endTimeComboBox.SelectedItem != null) { HRISShift hrisShift = new HRISShift(); hrisShift.ShiftCode = txtShiftCode.Text; hrisShift.Description = txtDescription.Text; hrisShift.StartTime = startTimeComboBox.Text; hrisShift.EndTime = endTimeComboBox.Text; db.HRISShifts.Add(hrisShift); db.SaveChanges(); GetShifts(); Clear(); } } } catch (Exception) { MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { try { using (var db = new LetranIntegratedSystemEntities()) { HRISShift hrisShfit = new HRISShift(); hrisShfit.Description = txtDescription.Text; hrisShfit.StartTime = startTimeComboBox.Text; hrisShfit.EndTime = endTimeComboBox.Text; hrisShfit.ShiftCode = txtShiftCode.Text; db.SaveChanges(); } } catch (Exception) { throw; } }
public void LoadComboBox() { try { using (var db = new LetranIntegratedSystemEntities()) { EList = new List <HRiSClass.EmpCombo>(); lShiftList = new List <HRISShift>(); var emp = db.Employees.Where(m => m.Archive == false && m.EmployeeScheduleId == null).ToList(); foreach (var i in emp) { HRiSClass.EmpCombo ec = new HRiSClass.EmpCombo(); ec.EmployeeID = i.EmployeeID; ec.EmployeeNumber = i.EmployeeNo; ec.EmployeeName = i.LastName.ToUpper() + ", " + i.FirstName.ToUpper(); EList.Add(ec); } cbEmployee.ItemsSource = EList.OrderBy(m => m.EmployeeName); cbEmployee.DisplayMemberPath = "EmployeeName"; cbEmployee.SelectedValuePath = "EmployeeID"; var shift = db.HRISShifts.ToList(); foreach (var x in shift) { HRISShift hrisShift = new HRISShift(); hrisShift.ShiftCode = x.ShiftCode; lShiftList.Add(hrisShift); } cbShiftCode.ItemsSource = lShiftList.OrderBy(m => m.ShiftCode); cbShiftCode.DisplayMemberPath = "ShiftCode"; cbShiftCode.SelectedValuePath = "ShiftCode"; } } catch (Exception) { MessageBox.Show("Something went wrong.", "System Error!", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void LoadComboBox() { try { using (var db = new LetranIntegratedSystemEntities()) { var shift = db.HRISShifts.ToList(); foreach (var x in shift) { HRISShift hrisShift = new HRISShift(); hrisShift.ShiftCode = x.ShiftCode; lShiftList.Add(hrisShift); } cbShiftCode.ItemsSource = lShiftList.OrderBy(m => m.ShiftCode); cbShiftCode.DisplayMemberPath = "ShiftCode"; cbShiftCode.SelectedValuePath = "ShiftCode"; } } catch (Exception) { throw; } }