private void butXoa_Click(object sender, EventArgs e) { if (listStaff.SelectedItems.Count > 0) { using (MotelManagerEntities data = new MotelManagerEntities()) { DialogResult result = MessageBox.Show("Ban co chac xoa quan ly co ID = " + listStaff.FocusedItem.Text + " khong? (tat ca cac du lieu lien quan deu se bi xoa!)", "WARNING", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); switch (result) { case DialogResult.Cancel: return; case DialogResult.Yes: { STAFF temp = data.STAFFs.Find(listStaff.FocusedItem.Text); data.STAFFs.Remove(temp); data.SaveChanges(); listStaff.Clear(); loadData(); break; } case DialogResult.No: return; default: break; } } } else { MessageBox.Show("Hay chon quan ly can xoa tu danh sach!", "WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public void loadData(String a) { STAFF c = data.STAFFs.Find(a); textHoTen.Text = c.StaffName; textAddress.Text = c.Address; textSDT.Text = c.NumberPhone.ToString(); textUserName.Text = c.UserName.ToString(); comBoxSexual.Text = c.Sexual.ToString(); datePickerBirth.Value = c.DateOfBirth.GetValueOrDefault(); }
public void updateData() { STAFF temp = data.STAFFs.Find(textIDStaff.Text); temp.StaffName = textHoTen.Text; temp.DateOfBirth = datePickerBirth.Value; temp.Address = textAddress.Text; temp.NumberPhone = textSDT.Text; temp.UserName = textUserName.Text; temp.Sexual = comBoxSexual.Text; data.SaveChanges(); }
public passOpenForm(String a) { InitializeComponent(); STAFF temp = data.STAFFs.Find(a); textStaffName.Text = temp.StaffName; textUserName.Text = temp.UserName; USER user = data.USERs.Find(textUserName.Text); textOldPass.Text = user.Password; }
public void saveDate() { STAFF staff = new STAFF() { ID = textIDStaff.Text, StaffName = textHoTen.Text, DateOfBirth = datePickerBirth.Value, Address = textAddress.Text, NumberPhone = textSDT.Text, UserName = textUserName.Text, Sexual = comBoxSexual.Text }; data.STAFFs.Add(staff); data.SaveChanges(); USER user = new USER() { UserName = textUserName.Text, Password = "", IDRole = 2 }; data.USERs.Add(user); data.SaveChanges(); }