public bool them(NV_LoaiNguonKinhPhi_ChiTiet model) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_LoaiNguonKinhPhi_add", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pTenLoai = new SqlParameter("@TenLoai", SqlDbType.NVarChar, 100); pTenLoai.Value = model.TenLoai; myCommand.Parameters.Add(pTenLoai); SqlParameter pMoTa = new SqlParameter("@MoTa", SqlDbType.NText); pMoTa.Value = model.MoTa; myCommand.Parameters.Add(pMoTa); try { myConnection.Open(); myCommand.ExecuteNonQuery(); return(true); } catch { return(false); } } } }
public NV_LoaiNguonKinhPhi_ChiTiet GetById(int id) { using (SqlConnection myConnection = new SqlConnection(ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("NV_LoaiNguonKinhPhi_getByID", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; SqlParameter pID = new SqlParameter("@ID", SqlDbType.VarChar, 10); pID.Value = id; myCommand.Parameters.Add(pID); DataTable dt; NV_LoaiNguonKinhPhi_ChiTiet model = new NV_LoaiNguonKinhPhi_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_LoaiNguonKinhPhi_ChiTiet(dt.Rows[0]); } return(model); } } }