Exemple #1
0
        public static List<SanPhamDTO> GetAllProduct()
        {
            List<SanPhamDTO> rs = new List<SanPhamDTO>();

            string query = "select * from db3c04c35a9c6b45918ba3a551005e16ee.product";

            DataTable dt = DataProvider.ExecuteQuery(query);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                SanPhamDTO sp = new SanPhamDTO();

                    sp.ID = (string)dt.Rows[i]["ID"];
                    sp.Name = (string)dt.Rows[i]["Name"];
                    sp.Publisher = (string)dt.Rows[i]["Publisher"];
                    sp.Price = (int)dt.Rows[i]["Price"];
                    sp.ExtraInfor = (string)dt.Rows[i]["ExtraInfor"];
                    sp.Category = (string)dt.Rows[i]["Category"];
                    sp.Image = (string)dt.Rows[i]["Image"];

                rs.Add(sp);
            }

            return rs;
        }
Exemple #2
0
        public ActionResult ChiTiet()
        {
            SanPhamDTO dto = new SanPhamDTO();
            if (Request["productID"] != null)
            {
                dto = DataAccess.SanPhamDAO.GetProductByID(Request["productID"]);

            }

            ViewBag.product = dto;

            return View();
        }
Exemple #3
0
        public static string AddProduct(SanPhamDTO dto)
        {
            string id = NextProductID();
            string query = "insert into db3c04c35a9c6b45918ba3a551005e16ee.product "
                            + "value ('" + id + "','" + dto.Name + "','" + dto.Publisher + "','" + dto.Price + "','" + dto.Image + "','" + dto.ExtraInfor + "','" + dto.Category +"')";

            if (DataProvider.ExecuteNonQuery(query))
            {
                return id;
            }
            else
            {
                return "";
            }
        }
Exemple #4
0
        public static SanPhamDTO GetProductByID(string id)
        {
            SanPhamDTO rs = new SanPhamDTO();

            string query = "select * from db3c04c35a9c6b45918ba3a551005e16ee.product where ID like '" + id + "'";

            DataTable dt = DataProvider.ExecuteQuery(query);

            for (int i = 0; i < dt.Rows.Count; i++)
            {

                    rs.ID = (string)dt.Rows[i]["ID"];
                    rs.Name = (string)dt.Rows[i]["Name"];
                    rs.Publisher = (string)dt.Rows[i]["Publisher"];
                    rs.Price = (int)dt.Rows[i]["Price"];
                    rs.ExtraInfor = (string)dt.Rows[i]["ExtraInfor"];
                    rs.Category = (string)dt.Rows[i]["Category"];
                    rs.Image = (string)dt.Rows[i]["Image"];

            }

            return rs;
        }