public void Xoa(ChiTietHopDongEntity pb) { KetNoiCSDL.MoKetNoi(); string sql = @"DELETE tblPhongBan WHERE MaHD=@MaHD and MaNV=@MaNV"; SqlCommand cmd = new SqlCommand(sql, KetNoiCSDL.connect); cmd.Parameters.AddWithValue("@MaHD", pb.MaHD); cmd.Parameters.AddWithValue("@MaNV", pb.MaNV); cmd.ExecuteNonQuery(); KetNoiCSDL.DongKetNoi(); }
private void simpleButton1_Click(object sender, EventArgs e) { ChiTietHopDongEntity ct = new ChiTietHopDongEntity(); // ct.MaHD = MaHD; ct.MaNV = MaNV; ct.NgayBatDau = dtNgayBD.Value.ToString(); ct.NgayKetThuc = dtNgayKT.Value.ToString(); ct.GhiChu = txtGhiChu.Text; ChiTietHopDongBus cthd = new ChiTietHopDongBus(); cthd.Them(ct); }
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { ChiTietHopDongEntity ctp = new ChiTietHopDongEntity(); ctp.MaHD = MaHDong; ctp.MaNV = MaNVien; ct.Xoa(ctp); grdHopDong.DataSource = ct.HienThiTheoMaNV(MaNVien); } catch { MessageBox.Show("Mời bạn chọn hợp đồng cần xóa"); } }
public void Them(ChiTietHopDongEntity pb) { KetNoiCSDL.MoKetNoi(); string themhd = @"INSERT INTO tblChiTietHopDong(MaHD, MaNV,NgayBatDau,NgayKetThuc,GhiChu) VALUES(@MaPB,@TenPB,@DiaDiem,@SDT,@GhiChu)"; SqlCommand cdm = new SqlCommand(themhd, KetNoiCSDL.connect); // cdm.CommandType = CommandType.StoredProcedure; cdm.Parameters.AddWithValue("@MaPB", pb.MaHD); cdm.Parameters.AddWithValue("@TenPB", pb.MaNV); cdm.Parameters.AddWithValue("@DiaDiem", pb.NgayBatDau); cdm.Parameters.AddWithValue("@SDT", pb.NgayKetThuc); cdm.Parameters.AddWithValue("@GhiChu", pb.GhiChu); cdm.ExecuteNonQuery(); KetNoiCSDL.DongKetNoi(); }
public void Sua(ChiTietHopDongEntity pb) { KetNoiCSDL.MoKetNoi(); string themhd = @"UPDATE tblPhongBan SET NgayBatDau =@NgayBatDau, NgayKetThuc =@NgayKetThuc, GhiChu =@GhiChu Where MaHD=@MaHD and MaNV=@MaNV"; SqlCommand cdm = new SqlCommand(themhd, KetNoiCSDL.connect); // cdm.CommandType = CommandType.StoredProcedure; cdm.Parameters.AddWithValue("@NgayBatDau", pb.NgayBatDau); cdm.Parameters.AddWithValue("@NgayKetThuc", pb.NgayKetThuc); cdm.Parameters.AddWithValue("@GhiChu", pb.GhiChu); cdm.Parameters.AddWithValue("@MaHD", pb.MaHD); cdm.Parameters.AddWithValue("@MaNV", pb.MaNV); cdm.ExecuteNonQuery(); KetNoiCSDL.DongKetNoi(); }