public bool them(NV_HoiDongThamDinh_ChiTiet model) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_HoiDongThamDinh_add", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pTenHoiDong = new SqlParameter("@TenHoiDong", SqlDbType.NVarChar, 200); pTenHoiDong.Value = model.TenHoiDong; myCommand.Parameters.Add(pTenHoiDong); SqlParameter pMoTa = new SqlParameter("@MoTa", SqlDbType.NVarChar, 2000); pMoTa.Value = model.MoTa; myCommand.Parameters.Add(pMoTa); try { myConnection.Open(); myCommand.ExecuteNonQuery(); return(true); } catch { return(false); } } } }
public NV_HoiDongThamDinh_ChiTiet GetById(int id) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_HoiDongThamDinh_getByID", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pID = new SqlParameter("@ID", SqlDbType.Int); pID.Value = id; myCommand.Parameters.Add(pID); DataTable dt; NV_HoiDongThamDinh_ChiTiet model = new NV_HoiDongThamDinh_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_HoiDongThamDinh_ChiTiet(dt.Rows[0]); } return(model); } } }