Пример #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            string masp, tensp, donvitinh, dongia, maloaisp;

            masp      = txtId.Text;
            tensp     = txtName.Text;
            donvitinh = txtDonvitinh.Text;
            dongia    = txtDongia.Text;
            maloaisp  = txtMaloaisp.Text;

            Products1 s            = new Products1(masp, tensp, donvitinh, dongia, maloaisp);
            int       numberOfRows = proBUS.Delete(masp);

            if (numberOfRows > 0)
            {
                List <Products1> list = proBUS.LoadProducts1();
                dgvProducts1.DataSource = list;
                MessageBox.Show("Xóa thành công");
                txtId.Clear();
                txtName.Clear();
                txtDonvitinh.Clear();
                txtDongia.Clear();
                txtMaloaisp.Clear();
            }
            else
            {
                MessageBox.Show("Xóa thất bại");
            }
        }
Пример #2
0
        public List <Products1> LoadProducts1()
        {
            Connect();
            string sql = "SELECT * FROM SanPham";
            //SqlCommand cmd = new SqlCommand();
            //cmd.Connection = cn;
            //cmd.CommandText = sql;
            //cmd.CommandType = System.Data.CommandType.Text;

            //SqlDataReader dr = cmd.ExecuteReader();

            SqlDataReader dr = MyExecuteReader(sql);
            string        masp, tensp, donvitinh, dongia, maloaisp;

            List <Products1> list = new List <Products1>();

            while (dr.Read())
            {
                masp      = dr[0].ToString();
                tensp     = dr[1].ToString();
                donvitinh = dr[2].ToString();
                dongia    = dr[3].ToString();
                maloaisp  = dr[4].ToString();

                Products1 s = new Products1(masp, tensp, donvitinh, dongia, maloaisp);
                list.Add(s);
            }
            dr.Close();
            DisConnect();
            return(list);
        }
Пример #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string masp, tensp, donvitinh, dongia, maloaisp;

            masp      = txtId.Text;
            tensp     = txtName.Text;
            donvitinh = txtDonvitinh.Text;
            dongia    = txtDongia.Text;
            maloaisp  = txtMaloaisp.Text;

            Products1 s            = new Products1(masp, tensp, donvitinh, dongia, maloaisp);
            int       numberOfRows = proBUS.Add(s);

            //if (numberOfRows > 0)
            //    MessageBox.Show("Them thanh cong!");
            //else
            //    MessageBox.Show("Them that bai!");
            if (numberOfRows > 0)
            {
                List <Products1> list = proBUS.LoadProducts1();
                dgvProducts1.DataSource = list;
                MessageBox.Show("Them thanh cong");
            }
            else
            {
                MessageBox.Show("Them that bai");
            }
        }
 public void PostProduct([FromBody] Products1 product)
 {
     using (ProductsDBEntities dbContext = new ProductsDBEntities())
     {
         dbContext.Products.Add(product);
         dbContext.SaveChanges();
     }
 }
        public void Put(int id, [FromBody] Products1 value)
        {
            var w = product.Products1.FirstOrDefault(e => e.Pid == id);

            w.Pid   = value.Pid;
            w.Pname = value.Pname;
            product.SaveChanges();
        }
Пример #6
0
        public void ThemChiNhapMaSP()//Test pass
        {
            Products1DAO u = new Products1DAO();

            sp1 = new Products1("HT03", " ", " ", " ", " ");
            double expected = 1;
            double actual   = u.Add(sp1);

            Assert.AreEqual(expected, actual);
        }
Пример #7
0
        public void ThemThanhCong()//Test pass
        {
            Products1DAO u = new Products1DAO();

            sp1 = new Products1("HT01", "Hồng Trà", "chai", "30000", "4");
            double expected = 1;
            double actual   = u.Add(sp1);

            Assert.AreEqual(expected, actual);
        }
Пример #8
0
        public void SuaMaLoaiSP()//pass
        {
            Products1DAO u = new Products1DAO();

            sp2 = new Products1("Bb12", "Bia bến thành", "Ly", "13000", "3");
            double expected = 1;
            double actual   = u.Update(sp2);

            Assert.AreEqual(expected, actual);
        }
Пример #9
0
        public void SuaKhongNhapMaSP()//pass
        {
            Products1DAO u = new Products1DAO();

            sp2 = new Products1("", "Bia bến thành", "Ly", "10000", "2");//Sửa mã loại sp
            double expected = -1;
            double actual   = u.Update(sp2);

            Assert.AreEqual(expected, actual);
        }
Пример #10
0
        public void ThemNhapMaSPQuaSoKyTu()//Test fail
        {
            Products1DAO u = new Products1DAO();

            sp1 = new Products1("CP1000", "Cà phê trân châu", "Ly", "15000", "4");
            double expected = -1;
            double actual   = u.Add(sp1);

            Assert.AreEqual(expected, actual);
        }
Пример #11
0
        public void ThemChiNhapMaLoaiSP()//Test fail
        {
            Products1DAO u = new Products1DAO();

            sp1 = new Products1("", "", "", "", "44");
            double expected = -1;
            double actual   = u.Add(sp1);

            Assert.AreEqual(expected, actual);
        }
Пример #12
0
        public void ThemChiNhapDonViTinh()//Test fail
        {
            Products1DAO u = new Products1DAO();

            sp1 = new Products1("", "", "Cốcc", "", "");
            double expected = -1;
            double actual   = u.Add(sp1);

            Assert.AreEqual(expected, actual);
        }
Пример #13
0
        public void ThemChiNhapTenSP()//fail
        {
            Products1DAO u = new Products1DAO();

            sp1 = new Products1("", "Cà phê CoCa", "", "", "");
            double expected = -1;
            double actual   = u.Add(sp1);

            Assert.AreEqual(expected, actual);
        }
 public void PutProduct(int id, [FromBody] Products1 product)
 {
     using (ProductsDBEntities dbContext = new ProductsDBEntities())
     {
         var entity = dbContext.Products.FirstOrDefault(e => e.ID == id);
         entity.Name        = product.Name;
         entity.Price       = product.Price;
         entity.Category_Id = product.Category_Id;
         dbContext.SaveChanges();
     }
 }
Пример #15
0
        public int Update(Products1 s)
        {
            string sql          = "UPDATE SanPham SET TenSP = N'" + s.TenSP + "', Donvitinh = N'" + s.DonViTinh + "', Dongia = N'" + s.DonGia + "', MaLoaiSP = N'" + s.MaLoaiSP + "' WHERE MaSP = '" + s.MaSP + "'";
            int    numberOfRows = MyExecuteNonQuery(sql);

            if (numberOfRows > 0)
            {
                return(1);
            }
            else
            {
                return(-1);
            }
        }
Пример #16
0
        public int Add(Products1 s)
        {
            string sql = "INSERT INTO SanPham values(N'" + s.MaSP + "',N'" + s.TenSP + "',N'" + s.DonViTinh + "', N'" + s.DonGia + "', N'" + s.MaLoaiSP + "')";

            int numberOfRows = MyExecuteNonQuery(sql);

            if (numberOfRows > 0)
            {
                return(1);
            }
            else
            {
                return(-1);
            }
        }
        private void GenerateSource()
        {
            for (int i = 0; i < productRepository.Names.Count(); i++)
            {
                var name = productRepository.Names[i];
                var p    = new Product()
                {
                    Name   = name,
                    Weight = productRepository.Weights[i],
                    Price  = productRepository.Prices[i],
                    Image  = productRepository.FruitNames[i] + ".jpg"
                };

                Products1.Add(p);
            }
        }
Пример #18
0
        public int Add(Products1 s)
        {
            string sql = "INSERT INTO SanPham values(N'" + s.MaSP + "',N'" + s.TenSP + "',N'" + s.DonViTinh + "', N'" + s.DonGia + "', N'" + s.MaLoaiSP + "')";
            //SqlCommand cmd = new SqlCommand();
            //cmd.Connection = cn;
            //cmd.CommandType = System.Data.CommandType.Text;
            //cmd.CommandText = sql;

            //int numberOfRows = cmd.ExecuteNonQuery();

            int numberOfRows = MyExecuteNonQuery(sql);

            if (numberOfRows > 0)
            {
                return(numberOfRows);
            }
            else
            {
                return(-1);
            }
        }
        private void GenerateSource()
        {
            Assembly assembly = typeof(LoadMoreOrders).GetTypeInfo().Assembly;

            for (int i = 0; i < productRepository.Names.Count(); i++)
            {
                var name = productRepository.Names[i];
                var p    = new Product()
                {
                    Name   = name,
                    Weight = productRepository.Weights[i],
                    Price  = productRepository.Prices[i],
#if COMMONSB
                    Image = ImageSource.FromResource("SampleBrowser.Icons.LoadMore." + name.Replace(" ", string.Empty) + ".jpg", assembly)
#else
                    Image = ImageSource.FromResource("SampleBrowser.SfListView.Icons.LoadMore." + name.Replace(" ", string.Empty) + ".jpg", assembly)
#endif
                };

                Products1.Add(p);
            }
        }
 public void Post([FromBody] Products1 value)
 {
     product.Products1.Add(value);
     product.SaveChanges();
 }
Пример #21
0
        public string GetProducts(string p, string x)
        {
            Products1 p = new Products1();

            return(JsonConvert.SerializeObject(p.ShowMyProducts()));
        }
Пример #22
0
        static void Main(string[] args)
        {
            /*Ficha10Solucao.Exercicio1();*/
            /*Ficha10Solucao.Exercicio2();*/
            /*Ficha10Solucao.Exercicio3();*/
            /*Ficha10Solucao.Exercicio4();*/
            /*Ficha10Solucao.Exercicio5();*/
            /*Ficha10Solucao.Exercicio7();*/
            /*Ficha10Solucao.Exercicio8();*/
            /*Ficha10Solucao.Exercicio10();*/
            //Ficha10Solucao.Exercicio11();
            //Ficha10Solucao.Exercicio12();
            //Ficha10Solucao.Exercicio13();
            //Ficha10Solucao.Exercicio14();
            //Ficha10Solucao.Exercicio15();
            //Ficha10Solucao.Exercicio16();

            //Ficha11Solucao.Exercicio71();
            //Ficha11Solucao.Exercicio2();
            //Ficha11Solucao.Exercicio3();
            //Ficha11Solucao.Exercicio4();
            //Ficha11Solucao.Exercicio5();
            //Ficha11Solucao.Exercicio6();
            //Ficha11Solucao.Exercicio7DoWhile();
            //Ficha11Solucao.Exercicio7While();
            //Ficha11Solucao.Exercicio7For();
            //Ficha11Solucao.Exercicio8();
            //Ficha11Solucao.Exercicio9();
            //Ficha11Solucao.Exercicio10();
            //Ficha11Solucao.Exercicio11();
            //Ficha11Solucao.Exercicio12();
            //Ficha11Solucao.Exercicio13();
            //Ficha11Solucao.Exercicio14();
            //Ficha11Solucao.Exercicio15();
            //Ficha11Solucao.Exercicio16();
            //Ficha11Solucao.Exercicio17();
            //Ficha11Solucao.Exercicio18();

            //Ficha12Solucao.Exercicio1();
            //Ficha12Solucao.Exercicio2();
            //Ficha12Solucao.Exercicio3();
            //Ficha12Solucao.Exercicio4();
            //Ficha12Solucao.Exercicio5();
            //Ficha12Solucao.Exercicio6();
            //Ficha12Solucao.Exercicio7();
            //Ficha12Solucao.Exercicio8();
            //Ficha12Solucao.Exercicio9();
            //Ficha12Solucao.Exercicio10();
            //Ficha12Solucao.Exercicio11();
            //Ficha12Solucao.Exercicio12();
            //Ficha12Solucao.Exercicio13();
            //Ficha12Solucao.Exercicio14();
            //Ficha12Solucao.Exercicio15();

            //Ficha13Solucao.Calculadora();
            //Ficha13Solucao.Forca();
            //Ficha13Solucao.PalavraRandom();

            //Ficha14Solucao.Exercicio1();
            //Ficha14Solucao.Exercicio2();
            //Ficha14Solucao.Exercicio3();
            //Ficha14Solucao.Exercicio4();
            //Ficha14Solucao.Exercicio5();
            //Ficha14Solucao.Exercicio6();

            //Ficha15Solucao.Exercicio1();
            //Ficha15Solucao.Exercicio2();
            //Ficha15Solucao.Exercicio3();
            //Ficha15Solucao.Exercicio4();
            //Ficha15Solucao.Exercicio5();
            //Ficha15Solucao.Exercicio6();
            //Ficha15Solucao.Exercicio7();
            //Ficha15Solucao.Exercicio8();
            //Ficha15Solucao.Exercicio9();

            //Ficha16Solucao.Exercicio1();
            //Ficha16Solucao.Exercicio2();
            //Ficha16Solucao.Exercicio3();
            //Ficha16Solucao.Exercicio4();
            //Ficha16Solucao.Exercicio5();
            //Ficha16Solucao.Exercicio6();
            //Ficha16Solucao.Exercicio7();
            //Ficha16Solucao.Exercicio8();

            //Ficha17Solucao.Exercicio1();
            //Ficha17Solucao.Exercicio2();
            //Ficha17Solucao.Exercicio3();
            //Ficha17Solucao.Exercicio4();
            //Ficha17Solucao.Exercicio5();
            //Ficha17Solucao.Exercicio6();
            //Ficha17Solucao.Exercicio7();

            //Testes.Testes.Summarize();

            Car p1 = new Car("Peugeut", "208", 2007);
            Car p2 = new Car("Ferrari", "FXX", 2018);

            Console.WriteLine($"{p1.GetBrand()}-{p1.GetYear()}-{p1.GetModel()}");
            Console.WriteLine($"{p2.GetBrand()}-{p2.GetYear()}-{p2.GetModel()}");

            Car1 p3 = new Car1("Peugeut", "208", 2007);
            Car1 p4 = new Car1("Ferrari", "FXX", 2018);

            Console.WriteLine($"{p3.brand} {p3.model} {p3.year}");
            Console.WriteLine($"{p4.brand} {p4.model} {p4.year}");

            Products p5 = new Products("Banana", 1.98, Types.Fruit);

            Console.WriteLine($"{p5.GetName()} - {p5.GetPrice()} - {p5.GetType()}");

            Products1 p6 = new Products1("Banana", 1.98, Types.Fruit);

            Console.WriteLine($"{p6.name} - {p6.price} - {p6.type}");

            Player1 player1 = new Player1("Renaldo", 42, 1.65f, 20, Sponsor.Nyka);

            Console.WriteLine($"{player1.GetName()} - {player1.GetAge()} - {player1.GetHeight()} - {player1.GetWeight()} - {player1.GetSponsor()} - {player1.GetIMC()}");

            Player2 player2 = new Player2("Messias", 39, 2.50f, 98, Sponsor.Acliclas);

            Console.WriteLine($"{player2.name} - {player2.age} - {player2.height} - {player2.weight} - {player2.sponsor} - {player2.imc}");
        }
Пример #23
0
 public int Add(Products1 s)
 {
     return(supPro.Add(s));
 }
Пример #24
0
 public int Update(Products1 s)
 {
     return(supPro.Update(s));
 }