示例#1
0
        public bool them(NV_DM_ChucVu_ChiTiet model)
        {
            using (SqlConnection myConnection = new SqlConnection(ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("NV_ChucVu_add", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;


                    SqlParameter pTenChucVu = new SqlParameter("@TenChucVu", SqlDbType.NVarChar, 100);
                    pTenChucVu.Value = model.TenChucVu;
                    myCommand.Parameters.Add(pTenChucVu);


                    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);
                    }
                }
            }
        }
示例#2
0
        public NV_DM_ChucVu_ChiTiet GetById(int id)
        {
            using (SqlConnection myConnection = new SqlConnection(ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("NV_ChucVu_getByID", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;
                    SqlParameter pID = new SqlParameter("@id", SqlDbType.Int);
                    pID.Value = id;
                    myCommand.Parameters.Add(pID);

                    DataTable            dt;
                    NV_DM_ChucVu_ChiTiet model = new NV_DM_ChucVu_ChiTiet();

                    myConnection.Open();
                    using (SqlDataAdapter mData = new SqlDataAdapter(myCommand))
                    {
                        dt = new DataTable();
                        mData.Fill(dt);
                    }
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        model.ChucvuID  = id;
                        model.TenChucVu = dt.Rows[0]["TenChucVu"].ToString();
                        model.Mota      = dt.Rows[0]["MoTa"].ToString();
                    }
                    return(model);
                }
            }
        }