public NV_KeHoachTuBo_ChiTiet GetById(int id) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_KeHoachTuBo_getByID", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pID = new SqlParameter("@id", SqlDbType.Int); pID.Value = id; myCommand.Parameters.Add(pID); DataTable dt; NV_KeHoachTuBo_ChiTiet model = new NV_KeHoachTuBo_ChiTiet(); myConnection.Open(); using (SqlDataAdapter mData = new SqlDataAdapter(myCommand)) { dt = new DataTable(); mData.Fill(dt); } if (dt != null && dt.Rows.Count > 0) { model = new NV_KeHoachTuBo_ChiTiet(dt.Rows[0]); } return(model); } } }
public bool update(NV_KeHoachTuBo_ChiTiet model) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_KeHoachTuBo_update", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pID = new SqlParameter("@KeHoachID", SqlDbType.Int); pID.Value = model.KeHoachID; myCommand.Parameters.Add(pID); SqlParameter pTenDuAn = new SqlParameter("@TenDuAn", SqlDbType.NVarChar, 200); pTenDuAn.Value = model.TenDuAn; myCommand.Parameters.Add(pTenDuAn); SqlParameter pDiaDiem = new SqlParameter("@DiaDiem", SqlDbType.NVarChar, 250); pDiaDiem.Value = model.DiaDiem; myCommand.Parameters.Add(pDiaDiem); SqlParameter pDonViGiamSat = new SqlParameter("@DonViGiamSat", SqlDbType.Int); pDonViGiamSat.Value = model.DonViGiamSat.DonViID; myCommand.Parameters.Add(pDonViGiamSat); SqlParameter pDonViThiCong = new SqlParameter("@DonViThiCong", SqlDbType.Int); pDonViThiCong.Value = model.DonViThiCong.DonViID; myCommand.Parameters.Add(pDonViThiCong); SqlParameter pDonViThietKe = new SqlParameter("@DonViThietKe", SqlDbType.Int); pDonViThietKe.Value = model.DonViThietKe.DonViID; myCommand.Parameters.Add(pDonViThietKe); SqlParameter pChuDauTu = new SqlParameter("@ChuDauTu", SqlDbType.Int); pChuDauTu.Value = model.ChuDauTu.DonViID; myCommand.Parameters.Add(pChuDauTu); SqlParameter pCapQD = new SqlParameter("@CapQD", SqlDbType.Int); pCapQD.Value = model.CapQD.DonViID; myCommand.Parameters.Add(pCapQD); SqlParameter pLyDo = new SqlParameter("@LyDo", SqlDbType.NVarChar, 250); pLyDo.Value = model.Lydo; myCommand.Parameters.Add(pLyDo); SqlParameter pMotaQuaTrinh = new SqlParameter("@MotaQuaTrinh", SqlDbType.NText); pMotaQuaTrinh.Value = model.MotaQuaTrinh; myCommand.Parameters.Add(pMotaQuaTrinh); SqlParameter pDiSanID = new SqlParameter("@DiSanID", SqlDbType.Int); pDiSanID.Value = model.DiSan.DiSanID; myCommand.Parameters.Add(pDiSanID); SqlParameter pNoiDung = new SqlParameter("@NoiDung", SqlDbType.NText); pNoiDung.Value = model.NoiDung; myCommand.Parameters.Add(pNoiDung); SqlParameter pThuocTinh = new SqlParameter("@ThuocTinh", SqlDbType.VarChar, 10); pThuocTinh.Value = model.ThuocTinh; myCommand.Parameters.Add(pThuocTinh); SqlParameter pThuocHuyen = new SqlParameter("@ThuocHuyen", SqlDbType.VarChar, 10); pThuocHuyen.Value = model.ThuocHuyen; myCommand.Parameters.Add(pThuocHuyen); SqlParameter pThuocXa = new SqlParameter("@ThuocXa", SqlDbType.VarChar, 10); pThuocXa.Value = model.ThuocXa; myCommand.Parameters.Add(pThuocXa); SqlParameter pDuKienBatDau = new SqlParameter("@DuKienBatDau", SqlDbType.DateTime); pDuKienBatDau.Value = model.DuKienBatDau; myCommand.Parameters.Add(pDuKienBatDau); SqlParameter pDuKienHoanThanh = new SqlParameter("@DuKienHoanThanh", SqlDbType.DateTime); pDuKienHoanThanh.Value = model.DukienHoanThanh; myCommand.Parameters.Add(pDuKienHoanThanh); SqlParameter pTrangThai = new SqlParameter("@TrangThai", SqlDbType.Bit); pTrangThai.Value = model.TrangThai; myCommand.Parameters.Add(pTrangThai); SqlParameter pThucTeBatDau = new SqlParameter("@ThucTeBatDau", SqlDbType.DateTime); pThucTeBatDau.Value = model.ThucTeBatDau; myCommand.Parameters.Add(pThucTeBatDau); SqlParameter pThucTeHoanThanh = new SqlParameter("@ThucTeHoanThanh", SqlDbType.DateTime); pThucTeHoanThanh.Value = model.ThucTeHoanThanh; myCommand.Parameters.Add(pThucTeHoanThanh); SqlParameter pChiPhiDuKien = new SqlParameter("@ChiPhiDuKien", SqlDbType.Decimal); pChiPhiDuKien.Value = model.ChiPhiDuKien; myCommand.Parameters.Add(pChiPhiDuKien); SqlParameter pChiPhiThucTe = new SqlParameter("@ChiPhiThucTe", SqlDbType.Decimal); pChiPhiThucTe.Value = model.ChiPhiThucTe; myCommand.Parameters.Add(pChiPhiThucTe); SqlParameter pFile = new SqlParameter("@File", SqlDbType.NVarChar, 500); pFile.Value = model.File; myCommand.Parameters.Add(pFile); try { myConnection.Open(); myCommand.ExecuteNonQuery(); return(true); } catch { return(false); } } } }