protected void DeleteUser(object sender, EventArgs e) { if (logged) { int count = dgvInfomations.Rows.Count; if (count > 0) { if (MessageBox.Show("Are you sure?", "Notification", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int id = Convert.ToInt32(dgvInfomations.SelectedCells[0].OwningRow.Cells[0].Value.ToString()); Infomations foundpr1 = mainList.Find((Infomations k) => { return(k.Id == id); }); mainList.Remove(foundpr1); updateDgv(); xoaTrang(); } } } else { MessageBox.Show("You must login again to delete users", "Login Validation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); LoginAgain loginAgain = new LoginAgain(); loginAgain.ShowDialog(); } }
protected void EditUser(object sender, EventArgs e) { if (MessageBox.Show("Are you sure?", "Notification", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int id = Convert.ToInt32(dgvInfomations.SelectedCells[0].OwningRow.Cells[0].Value.ToString()); Infomations foundpr1 = mainList.Find((Infomations k) => { return(k.Id == id); }); int index = mainList.IndexOf(foundpr1); mainList[index].Ten = infomationsControlMain.Ten; mainList[index].NgaySinh = infomationsControlMain.NgaySinh; mainList[index].GioiTinh = infomationsControlMain.GioiTinh; mainList[index].NgheNghiep = infomationsControlMain.NgheNghiep; mainList[index].DiaChi = infomationsControlMain.DiaChi; updateDgv(); xoaTrang(); } }
protected void AddUser(object sender, EventArgs e) { if (MessageBox.Show("Are you sure?", "Notification", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Infomations newInfo = new Infomations(); newInfo.Id = i++; newInfo.Ten = infomationsControlMain.Ten; newInfo.NgaySinh = infomationsControlMain.NgaySinh; newInfo.GioiTinh = infomationsControlMain.GioiTinh; newInfo.NgheNghiep = infomationsControlMain.NgheNghiep; newInfo.DiaChi = infomationsControlMain.DiaChi; mainList.Add(newInfo); updateDgv(); xoaTrang(); } }