Example #1
0
        public NV_LoaiQuyTrinh_ChiTiet GetById(int id)
        {
            using (SqlConnection myConnection = new SqlConnection(ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("NV_LoaiQuyTrinh_getByID", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    SqlParameter pID = new SqlParameter("@ID", SqlDbType.Int);
                    pID.Value = id;
                    myCommand.Parameters.Add(pID);

                    NV_LoaiQuyTrinh_ChiTiet model = new NV_LoaiQuyTrinh_ChiTiet();
                    DataTable dt;

                    myConnection.Open();
                    using (SqlDataAdapter mData = new SqlDataAdapter(myCommand))
                    {
                        dt = new DataTable();
                        mData.Fill(dt);
                    }
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        model = new NV_LoaiQuyTrinh_ChiTiet(dt.Rows[0]);
                    }
                    return(model);
                }
            }
        }
Example #2
0
        public NV_LoaiQuyTrinh_ChiTiet GetByUrl(string url)
        {
            using (SqlConnection myConnection = new SqlConnection(ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("NV_LoaiQuyTrinh_getByUrl", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    SqlParameter pUrl = new SqlParameter("@Url", SqlDbType.NVarChar, 200);
                    pUrl.Value = url;
                    myCommand.Parameters.Add(pUrl);

                    NV_LoaiQuyTrinh_ChiTiet model = new NV_LoaiQuyTrinh_ChiTiet();
                    DataTable dt;

                    myConnection.Open();
                    using (SqlDataAdapter mData = new SqlDataAdapter(myCommand))
                    {
                        dt = new DataTable();
                        mData.Fill(dt);
                    }
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        model = new NV_LoaiQuyTrinh_ChiTiet(dt.Rows[0]);
                    }
                    return(model);
                }
            }
        }
Example #3
0
        public bool update(NV_LoaiQuyTrinh_ChiTiet model)
        {
            using (SqlConnection myConnection = new SqlConnection(ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("NV_LoaiQuyTrinh_update", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    SqlParameter pID = new SqlParameter("@ID", SqlDbType.Int);
                    pID.Value = model.ID;
                    myCommand.Parameters.Add(pID);

                    SqlParameter pTenLoai = new SqlParameter("@TenLoai", SqlDbType.NVarChar, 250);
                    pTenLoai.Value = model.TenLoai;
                    myCommand.Parameters.Add(pTenLoai);

                    SqlParameter pMoTa = new SqlParameter("@MoTa", SqlDbType.NVarChar, 1000);
                    pMoTa.Value = model.MoTa;
                    myCommand.Parameters.Add(pMoTa);

                    SqlParameter pStt = new SqlParameter("@Stt", SqlDbType.Int);
                    pStt.Value = model.Stt;
                    myCommand.Parameters.Add(pStt);

                    SqlParameter pUrl = new SqlParameter("@Url", SqlDbType.NVarChar, 200);
                    pUrl.Value = model.Url;
                    myCommand.Parameters.Add(pUrl);
                    try
                    {
                        myConnection.Open();
                        myCommand.ExecuteNonQuery();
                        return(true);
                    }
                    catch
                    {
                        return(false);
                    }
                }
            }
        }