public void Update_TypeLeave(int id, string _name, int _duration) { var result = 0; Type_Leave _type = new Type_Leave(); MyContext _context = new MyContext(); var get = _context.Type_Leaves.Find(id); if (get == null) { MessageBox.Show("Data not found!"); } else { get.Name = _name; get.Duration = _duration; result = _context.SaveChanges(); if (result > 0) { MessageBox.Show("Update Success!"); } else { MessageBox.Show("Update Failed!"); } } }
public void DeleteTypeLeave(int id) { var result = 0; Type_Leave _type = new Type_Leave(); MyContext _context = new MyContext(); var get = _context.Type_Leaves.Find(id); if (get == null) { MessageBox.Show("Sorry, your data is not found"); } else { get.isDeleted = true; result = _context.SaveChanges(); if (result > 0) { MessageBox.Show("Delete Successfully"); } else { MessageBox.Show("Delete Failed"); } } }
private void Type_Save(object sender, RoutedEventArgs e) { MyContext _context = new MyContext(); Type_Leave _type = new Type_Leave(); var result = 0; string name = txtTypeLeave.Text; int _duration = Convert.ToInt32(txtDuration.Text); _type.Name = name; _type.Duration = _duration; _type.isDeleted = false; _context.Type_Leaves.Add(_type); result = _context.SaveChanges(); if (result > 0) { MessageBox.Show("Berhasil"); var get = _context.Type_Leaves.Where(u => u.isDeleted != true).ToList(); DataGridTypeLeave.ItemsSource = get; } else { MessageBox.Show("Gagal!"); } }
private void Btn_Type_Leave_Click(object sender, RoutedEventArgs e) { hideHoliday(); hideLeaveStatus(); getTypeLeave(); Btn_Type_Leave.IsEnabled = false; Btn_Holiday.IsEnabled = true; Btn_Leave_Status.IsEnabled = true; Type_Leave types = new Type_Leave(); MyContext _context = new MyContext(); var get = _context.Type_Leaves.Where(u => u.isDeleted != true).ToList(); DataGridTypeLeave.ItemsSource = get; }
public Requester(string NIK) { InitializeComponent(); InitializeComponent(); setNIK(NIK); setName(NIK); getSisaCuti(NIK); _Txt_Name.Text = "" + G_Name + ""; Txt_Name.Text = "" + G_Name + ""; Txt_NIK.Text = "" + G_NIK + ""; Txt_LastYearCuti.Text = "" + G_lst_leave + ""; Txt_CurrentCuti.Text = "" + G_crnt_leave + ""; Type_Leave _leave = new Type_Leave(); MyContext _context = new MyContext(); //var get = _context.Type_Leaves.Where(u => u.isDeleted != true).ToList(); //comboBox.ItemsSource = get; }