private void button1_Click(object sender, EventArgs e) { int currentRowIndex = dtgdanhsach.CurrentCellAddress.Y; HONNHAN_DTO newdt = new HONNHAN_DTO(dtgdanhsach.CurrentRow.Cells[0].Value.ToString(), txbTenVC.Text, int.Parse(txbDuoi15.Text), int.Parse(txbTren15.Text), int.Parse(txbTren60.Text)); if (-1 < currentRowIndex && currentRowIndex < dtgdanhsach.RowCount) { MessageBox.Show("Cập nhập Thành Công " + newdt.MaNV); HONNHAN_DAL.Instance.UpdateHonNhan(newdt); } loaddanhsach(); }
public List <HONNHAN_DTO> LoadListHonNhan() { List <HONNHAN_DTO> HonNhan = new List <HONNHAN_DTO>(); string query = "SELECT * FROM dbo.HONNHAN "; DataTable data = DataProvider.Instance.ExecuteQuery(query); foreach (DataRow item in data.Rows) { HONNHAN_DTO honnhan = new HONNHAN_DTO(item); HonNhan.Add(honnhan); } return(HonNhan); }
private void button1_Click(object sender, EventArgs e) { if (!checkInput()) { MessageBox.Show("Vui long nhập đầy đủ thông tin"); return; } HONNHAN_DTO newhonnhan = new HONNHAN_DTO(cbMaNhanVien.SelectedValue.ToString(), txbTenVC.Text, int.Parse(txbDuoi15.Text), int.Parse(txbTren15.Text), int.Parse(txbTren60.Text)); if (HONNHAN_DAL.Instance.checkIsExist(newhonnhan.MaNV)) { MessageBox.Show("Thông tin đã tồn tại, thêm thất bại"); } else { HONNHAN_DAL.Instance.addHonNhan(newhonnhan); MessageBox.Show("Thêm thành công "); } }
public void UpdateHonNhan(HONNHAN_DTO honnhan) { string query = string.Format("UPDATE dbo.HONNHAN SET TenVoChong = N'{0}', NTDuoi15 = {1}, NTTren15 = {2}, NTTren60 = {3} WHERE MaNV = N'{4}' ", honnhan.TenVoChong, honnhan.NTDuoi15, honnhan.NTTren15, honnhan.NTTren60, honnhan.MaNV); DataProvider.Instance.ExecuteNonQuery(query); }
public void addHonNhan(HONNHAN_DTO honnhan) { string query = string.Format("INSERT INTO dbo.HONNHAN (MaNV,TenVoChong,NTDuoi15,NTTren15,NTTren60) VALUES (N'{0}',N'{1}',{2},{3},{4})", honnhan.MaNV, honnhan.TenVoChong, honnhan.NTDuoi15, honnhan.NTTren15, honnhan.NTTren60); DataTable result = DataProvider.Instance.ExecuteQuery(query); }