public NV_LuongDinhNghia_ChiTiet GetById(int id) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_LuongDinhNghia_getByID", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pID = new SqlParameter("@ID", SqlDbType.Int); pID.Value = id; myCommand.Parameters.Add(pID); DataTable dt; NV_LuongDinhNghia_ChiTiet model = new NV_LuongDinhNghia_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_LuongDinhNghia_ChiTiet(dt.Rows[0]); } return(model); } } }
public bool update(NV_LuongDinhNghia_ChiTiet model) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_LuongDinhNghia_update", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pID = new SqlParameter("@ID", SqlDbType.Int); pID.Value = model.ID; myCommand.Parameters.Add(pID); SqlParameter pTenLinhVuc = new SqlParameter("@Ten", SqlDbType.NVarChar, 250); pTenLinhVuc.Value = model.Ten; myCommand.Parameters.Add(pTenLinhVuc); SqlParameter pStt = new SqlParameter("@Stt", SqlDbType.Int); pStt.Value = model.Stt; myCommand.Parameters.Add(pStt); SqlParameter pIDQuyTrinh = new SqlParameter("@IDQuyTrinh", SqlDbType.Int); pIDQuyTrinh.Value = model.IDQuyTrinh; myCommand.Parameters.Add(pIDQuyTrinh); SqlParameter pNguoiXuLy = new SqlParameter("@NguoiXuLy", SqlDbType.Int); pNguoiXuLy.Value = model.NguoiXuLy; myCommand.Parameters.Add(pNguoiXuLy); SqlParameter pMoTa = new SqlParameter("@MoTa", SqlDbType.NVarChar, 1000); pMoTa.Value = model.MoTa; myCommand.Parameters.Add(pMoTa); SqlParameter pCoQuanID = new SqlParameter("@CoQuanID", SqlDbType.Int); pCoQuanID.Value = model.CoQuanID; myCommand.Parameters.Add(pCoQuanID); SqlParameter pThoiGianHT = new SqlParameter("@ThoiGianHT", SqlDbType.Int); pThoiGianHT.Value = model.ThoiGianHT; myCommand.Parameters.Add(pThoiGianHT); try { myConnection.Open(); myCommand.ExecuteNonQuery(); return(true); } catch { return(false); } } } }