private void btnXoa_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có chắc muốn xóa!") == DialogResult.OK)
     {
         dto = new CALAMVIEC_DTO(int.Parse(dataGridView1[0, dataGridView1.CurrentRow.Index].Value.ToString()));
         bus.deleteCa(dto);
     }
     dateBD.Text              = DateTime.Now.TimeOfDay.ToString();
     dateKT.Text              = DateTime.Now.TimeOfDay.ToString();
     txtSoGio.Text            = "0";
     dataGridView1.DataSource = bus.hienthi();
 }
 public void xoaCa(CALAMVIEC_DTO dto)
 {
     try
     {
         sql = "DELETE FROM CALAMVIEC WHERE MACALAM = @ma";
         conn.Open();
         cmd = new SqlCommand(sql, conn);
         cmd.Parameters.AddWithValue("@ma", dto.Macalam);
         cmd.ExecuteNonQuery();
         conn.Close();
     }
     catch (Exception ex)
     {
     }
 }
 private void btnCapNhat_Click(object sender, EventArgs e)
 {
     try
     {
         dto = new CALAMVIEC_DTO(int.Parse(dataGridView1[0, dataGridView1.CurrentRow.Index].Value.ToString()), dateBD.Value, dateKT.Value, int.Parse(txtSoGio.Text));
         bus.updateCa(dto);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         dataGridView1.DataSource = bus.hienthi();
     }
 }
 public void themCa(CALAMVIEC_DTO dto)
 {
     try
     {
         sql = "INSERT INTO CALAMVIEC VALUES (@giobd, @giokt, @sogio)";
         conn.Open();
         cmd = new SqlCommand(sql, conn);
         cmd.Parameters.AddWithValue("@giobd", dto.GioBD);
         cmd.Parameters.AddWithValue("@giokt", dto.GioKT);
         cmd.Parameters.AddWithValue("@sogio", dto.Sogio);
         cmd.ExecuteNonQuery();
         conn.Close();
     }
     catch (Exception ex)
     {
     }
 }
 private void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         dto = new CALAMVIEC_DTO(dateBD.Value, dateKT.Value, int.Parse(txtSoGio.Text));
         bus.addCa(dto);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         MessageBox.Show("Thành công");
         dataGridView1.DataSource = bus.hienthi();
     }
 }
 public void capnhatCa(CALAMVIEC_DTO dto)
 {
     try
     {
         sql = "UPDATE CALAMVIEC SET GIOBD = @giobd, GIOKT = @giokt, SOGIO = @sogio WHERE MACALAM = @ma";
         conn.Open();
         cmd = new SqlCommand(sql, conn);
         cmd.Parameters.AddWithValue("@giobd", dto.GioBD);
         cmd.Parameters.AddWithValue("@giokt", dto.GioKT);
         cmd.Parameters.AddWithValue("@sogio", dto.Sogio);
         cmd.Parameters.AddWithValue("@ma", dto.Sogio);
         cmd.ExecuteNonQuery();
         conn.Close();
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #7
0
 public void deleteCa(CALAMVIEC_DTO dto)
 {
     dao.xoaCa(dto);
 }
Beispiel #8
0
 public void updateCa(CALAMVIEC_DTO dto)
 {
     dao.capnhatCa(dto);
 }
Beispiel #9
0
 public void addCa(CALAMVIEC_DTO dto)
 {
     dao.themCa(dto);
 }