public int Insert(CV_NewDTO record) { SqlConnection connect = new SqlConnection(SqlDataAccess.ConnectionString); connect.Open(); try { string strcmd = "insert into CV_NEW"+ "(IDNguoiTimViec,ID_CV_KinhNghiem,ID_CV_QuaTrinhHocTap,ID_CV_ThongTinBoSung,ID_CV_ThongTinUngDung,ID_CV_ViecLamMongMuon)" + " values(@IDNguoiTimViec,@ID_CV_KinhNghiem,@ID_CV_QuaTrinhHocTap,@ID_CV_ThongTinBoSung,@ID_CV_ThongTinUngDung,@ID_CV_ViecLamMongMuon)" +" SET @ID = SCOPE_IDENTITY()"; SqlCommand cmd = new SqlCommand(strcmd, connect); SqlParameter nguoitimviecParam = new SqlParameter("@IDNguoiTimViec", SqlDbType.Int); nguoitimviecParam.Value = record.IDNguoiTimViec; SqlParameter kinhnghiemParam = new SqlParameter("@ID_CV_KinhNghiem", SqlDbType.Int); kinhnghiemParam.Value = record.IDKinhNghiem; SqlParameter quatrinhParam = new SqlParameter("@ID_CV_QuaTrinhHocTap", SqlDbType.Int); quatrinhParam.Value = record.IDQuaTrinhHocTap; SqlParameter ttbosungParam = new SqlParameter("@ID_CV_ThongTinBoSung", SqlDbType.Int); ttbosungParam.Value = record.IDThongTinBoSung; SqlParameter ttungdungParam = new SqlParameter("@ID_CV_ThongTinUngDung", SqlDbType.Int); ttungdungParam.Value = record.IDThongTinUngDung; SqlParameter vievlammmParam = new SqlParameter("@ID_CV_ViecLamMongMuon", SqlDbType.Int); vievlammmParam.Value = record.IDViecLamMongMuon; SqlParameter IDParam = new SqlParameter("@ID", SqlDbType.Int); IDParam.Direction = ParameterDirection.Output; //MoTaParam.Value = record.MoTa; cmd.Parameters.Add(nguoitimviecParam); cmd.Parameters.Add(kinhnghiemParam); cmd.Parameters.Add(quatrinhParam); cmd.Parameters.Add(ttbosungParam); cmd.Parameters.Add(ttungdungParam); cmd.Parameters.Add(vievlammmParam); cmd.Parameters.Add(IDParam); cmd.ExecuteNonQuery(); int id = (int)IDParam.Value; return id; } catch (System.Exception ex) { return -1; throw ex; } finally { connect.Close(); } }
protected void butCV_Click(object sender, EventArgs e) { CV_KinhNghiemLamViecBUS busKNLV = new CV_KinhNghiemLamViecBUS(); CV_NewBUS busCV = new CV_NewBUS(); CV_QuaTrinhHocVanBUS busQTHV = new CV_QuaTrinhHocVanBUS(); CV_ThongTinBoSungBUS busTTBS = new CV_ThongTinBoSungBUS(); CV_ThongTinUngDungBUS busTTUD = new CV_ThongTinUngDungBUS(); CV_ViecLamMongMuonBUS busVLMM = new CV_ViecLamMongMuonBUS(); int idNTV = CurrentUser.ID; CV_ThongTinUngDungDTO dtoTTUD = new CV_ThongTinUngDungDTO(); dtoTTUD.KinhNghiem = cbxTTUngDung_KinhNghiem.Value; dtoTTUD.BangCap = cbxTTUngDung_BangCap.Value; dtoTTUD.CapBac = cbxTTUngDung_CapBac.Value; dtoTTUD.NgoaiNgu = cbxTTUngDung_LoaiNgoaiNgu.Value; if (rbTTUngDung_ChuyenCho_Option.Checked) { dtoTTUD.ChuyenChoO = "Tùy trường hợp"; } else if (rbTTUngDung_ChuyenCho_Yes.Checked) { dtoTTUD.ChuyenChoO = "Có"; } else if (rdTTUngDung_ChuyenCho_No.Checked) { dtoTTUD.ChuyenChoO = "Không"; } if (rdTTUngDung_CongTac_No.Checked) { dtoTTUD.DiCongtac = "Không"; } else if (rdTTUngDung_CongTac_Yes.Checked) { dtoTTUD.DiCongtac = "Có"; } else if (rdTTUngDung_CongTac_Option.Checked) { dtoTTUD.DiCongtac = "Tùy trường hợp"; } if (rdTTUngDung_LamNgoaiGio_No.Checked) { dtoTTUD.LamNgoaiGio = "Không"; } else if (rdTTUngDung_LamNgoaigio_Yes.Checked) { dtoTTUD.LamNgoaiGio = "Có"; } else if (rdTTUngDung_LamNgoaiGio_Option.Checked) { dtoTTUD.LamNgoaiGio = "Tùy trường hợp"; } int idTTUD = busTTUD.Insert(dtoTTUD); CV_ViecLamMongMuonDTO dtoVLMM = new CV_ViecLamMongMuonDTO(); dtoVLMM.MucLuong = cbxVLMongMuon_MucLuongDeNghi.Value; dtoVLMM.NoiLamViec = cbxVLMongMuon_NoiLamViec.Value; dtoVLMM.NganhNgheMongMuon = cbxVLMongMuon_NganhNghe.Value; dtoVLMM.ViTriMongMuon = tbxVLMongMuon_ViTri.Value; if (cbVLMongMuon_HinhThucCongViec_ChinhThuc.Checked) { dtoVLMM.HinhThucLamViec = "Nhân viên chính thức"; } else if (cbVLMongMuon_HinhThucCongViec_TuDo.Checked) { dtoVLMM.HinhThucLamViec = "Tự do"; } else if (cbVLMongMuon_HinhThucCongViec_ThoiVu.Checked) { dtoVLMM.HinhThucLamViec = "Nhân viên thời vụ"; } if (cbVLMongMuon_LaiCongViec_Parttime.Checked) { dtoVLMM.LoaiHinhCongViec = "Part-time"; } else if (cbVLMongMuon_LoaiCongViec_Fulltime.Checked) { dtoVLMM.LoaiHinhCongViec = "Full-time"; } int idVLMM = busVLMM.Insert(dtoVLMM); CV_QuaTrinhHocVanDTO dtoQTHV = new CV_QuaTrinhHocVanDTO(); dtoQTHV.TenTruong = tbxQuaTrinhHocTap_TenTruong.Value; dtoQTHV.ChuyenNganh = tbxQuaTrinhHocTap_ChuyenNganh.Value; dtoQTHV.BangCap = cbxQuaTrinhHocTap_BangCap.Value; dtoQTHV.NamTotNghiep = DateTime.Parse(tbxNgayTotNghiep.Text).Year; int idQTHV = busQTHV.Insert(dtoQTHV); CV_KinhNghiemLamViecDTO dtoKNLV = new CV_KinhNghiemLamViecDTO(); dtoKNLV.MoTa = tbxKNLV_MoTa.Value; dtoKNLV.TenCongTy = tbxKNLV_TenCongTy.Value; dtoKNLV.TinhTP = cbxKNLV_TinhTP.Value; dtoKNLV.ViTri = tbxKNLV_ViTriCongViec.Value; dtoKNLV.ThoiGianBatDau = new DateTime(int.Parse(cbxKNLV_Begin_Year.Value), int.Parse(cbxKNLV_Begin_Month.Value), 1); dtoKNLV.ThoiGianKetThuc = new DateTime(int.Parse(cbxKNLV_End_Year.Value), int.Parse(cbxKNLV_End_Month.Value), 1); int idKNLV = busKNLV.Insert(dtoKNLV); CV_ThongTinBoSungDTO dtoTTBS = new CV_ThongTinBoSungDTO(); dtoTTBS.KyNang = tbxKynang.Value; dtoTTBS.MucTieuNgheNghiep = tbxMucTieu.Value; dtoTTBS.NangKhieuSoThich = tbxNangKhieuSoThich.Value; dtoTTBS.UuDiemKhuyetDiem = tbxUuDiemNhuocDiem.Value; int idTTBS = busTTBS.Insert(dtoTTBS); CV_NewDTO newCV = new CV_NewDTO(); newCV.IDKinhNghiem = idKNLV; newCV.IDNguoiTimViec = CurrentUser.ID; newCV.IDQuaTrinhHocTap = idQTHV; newCV.IDThongTinBoSung = idTTBS; newCV.IDThongTinUngDung = idTTUD; newCV.IDViecLamMongMuon = idVLMM; int kq = busCV.Insert(newCV); }
public int Insert(CV_NewDTO record) { CV_NewDAO dao = new CV_NewDAO(); return dao.Insert(record); }