public int updateCongTac(CongTac_DTO ct) { String sql = "update CongTac set NoiCongTac=@NoiCongTac where manv=@MaNV and ngaycongtac=@NgayCongTac"; try { SqlConnection conn = getConnection(); if (conn.State == ConnectionState.Closed) { conn.Open(); } SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@MaNV", ct.MaNV); cmd.Parameters.AddWithValue("@NgayCongTac", ct.NgayCongTac); cmd.Parameters.AddWithValue("@NoiCongTac", ct.NoiCongTac); cmd.ExecuteNonQuery(); return(1); } catch (SqlException) { //MessageBox.Show(e.Message); //return 0; } return(0); }
public int insertCongTac(CongTac_DTO ct) { String sql = "insert into CongTac values(@MaNV,@NgayCongTac,@NoiCongTac)"; try { SqlConnection conn = getConnection(); if (conn.State == ConnectionState.Closed) { conn.Open(); } SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@MaNV", ct.MaNV); cmd.Parameters.AddWithValue("@NgayCongTac", ct.NgayCongTac); cmd.Parameters.AddWithValue("@NoiCongTac", ct.NoiCongTac); cmd.ExecuteNonQuery(); return(1); } catch (SqlException e) { MessageBox.Show(e.Message); //return 0; } return(0); }
private void btnTimKiem_Click(object sender, EventArgs e) { CongTac_DTO ct = new CongTac_DTO(); ct.MaNV = cbbmanv.SelectedValue.ToString(); ct.NgayCongTac = dtpngaycongtac.Text; ct.NoiCongTac = txtNoiCongTac.Text; DataTable dt = congTac_BUL.timkiemCongTac(ct); dtgCongTac.DataSource = dt; }
private void btnThem_Click(object sender, EventArgs e) { CongTac_DTO ct = new CongTac_DTO(); ct.MaNV = cbbmanv.Text; ct.NgayCongTac = dtpngaycongtac.Text; ct.NoiCongTac = txtNoiCongTac.Text; int kq = congTac_BUL.insertCongTac(ct); //if (kq == 1) //{ // MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); //} //else if (kq == 0) // MessageBox.Show("Thêm thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); HienThi(); LamSach(); }
private void btnSua_Click(object sender, EventArgs e) { CongTac_DTO ct = new CongTac_DTO(); ct.MaNV = cbbmanv.Text; ct.NgayCongTac = dtpngaycongtac.Text; ct.NoiCongTac = txtNoiCongTac.Text; int kq = congTac_BUL.updateCongTac(ct); if (kq == 1) { MessageBox.Show("Sửa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (kq == 0) { MessageBox.Show("Sửa thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } HienThi(); LamSach(); }
public DataTable timkiemCongTac(CongTac_DTO ct) { try { String sql = "select * from congtac where 1=1 and manv like '%" + ct.MaNV + "%' and ngaycongtac like '%" + ct.NgayCongTac + "%'"; SqlConnection conn = getConnection(); if (conn.State == ConnectionState.Closed) { conn.Open(); } SqlCommand cmd = new SqlCommand(sql, conn); SqlDataReader reader = cmd.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(reader); return(dt); } catch (SqlException) { //MessageBox.Show(e.Message); } return(null); }
public DataTable timkiemCongTac(CongTac_DTO ct) { return(congTac_DAL.timkiemCongTac(ct)); }
public int updateCongTac(CongTac_DTO ct) { return(congTac_DAL.updateCongTac(ct)); }
public int insertCongTac(CongTac_DTO ct) { return(congTac_DAL.insertCongTac(ct)); }