Exemplo n.º 1
0
        public bool DeleteTL(TheLoai tl)
        {
            string sql = "DELETE FROM TheLoai WHERE MatheLoai = @maTL";
            List <SqlParameter> Parameters = new List <SqlParameter>();

            Parameters.Add(new SqlParameter("@maTL", tl.MaTheLoai));
            try
            {
                return(myExecuteNonQuery(sql, CommandType.Text, Parameters) > 0);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public bool UpdateTL(TheLoai tloai)
        {
            string sql = "UPDATE TheLoai SET TenTheLoai = @tenTL WHERE MaTheLoai = @maTL";
            List <SqlParameter> Parameters = new List <SqlParameter>();

            Parameters.Add(new SqlParameter("@maTL", tloai.MaTheLoai));
            Parameters.Add(new SqlParameter("@tenTL", tloai.TenTheLoai));
            try
            {
                return(myExecuteNonQuery(sql, CommandType.Text, Parameters) > 0);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        public List <TheLoai> getAllReturnList()
        {
            String    query = "select MaTheLoai,TenTheLoai from TheLoai";
            DataTable dt    = this.dp.ExecuteQuery(query);

            List <TheLoai> lstTheLoai = new List <TheLoai>();

            foreach (DataRow dr in dt.Rows)
            {
                TheLoai theLoai = new TheLoai();
                theLoai.MaTheLoai  = (int)dr["MaTheLoai"];
                theLoai.TenTheLoai = dr["TenTheLoai"].ToString();

                lstTheLoai.Add(theLoai);
            }
            return(lstTheLoai);
        }
Exemplo n.º 4
0
        public int Add(TheLoai theLoaiSach)
        {
            string sql = "INSERT INTO TheLoai VALUES (@id,@name)";
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("@id", theLoaiSach.MaTheLoai));
            parameters.Add(new SqlParameter("@name", theLoaiSach.TenTheLoai));


            try
            {
                return(myExecuteNonQuery(sql, CommandType.Text, parameters));
            }
            catch (SqlException ex)
            {
                throw ex;
            }
        }
Exemplo n.º 5
0
        public TheLoai getByTenTheLoai(String TenTheLoai)
        {
            String query = "select MaTheLoai, TenTheLoai from TheLoai where TenTheLoai = @TenTheLoai";
            List <SqlParameter> sqlParameters = new List <SqlParameter>();
            SqlParameter        param         = new SqlParameter("TenTheLoai", TenTheLoai);

            sqlParameters.Add(param);
            DataTable dt = this.dp.ExecuteQuery(query, sqlParameters);

            if (dt.Rows.Count == 0)
            {
                return(null);
            }
            else
            {
                TheLoai theLoai = new TheLoai();
                theLoai.MaTheLoai  = (int)dt.Rows[0]["MaTheLoai"];
                theLoai.TenTheLoai = dt.Rows[0]["TenTheLoai"].ToString();

                return(theLoai);
            }
        }