Esempio n. 1
0
        private void iconBtnSearch_Click(object sender, EventArgs e)
        {
            ProductDAO1 p  = new ProductDAO1();
            DBContextSV db = new DBContextSV(Program.connectionString);

            dataGridViewListProduct.DataSource = db.sanphams.Where(x => x.masp.Contains(txtIDProduct.Text)).ToList();
        }
Esempio n. 2
0
        private void iconbtnUpdate_Click(object sender, EventArgs e)
        {
            sanpham s = new sanpham();

            s.masp   = txtID.Text;
            s.nhasx  = txtNSX.Text;
            s.tensp  = txtName.Text;
            s.loai   = txtTypeProductName.Text;
            s.giaban = Int32.Parse(txtPrice.Text);
            s.nhacc  = txtNCC.Text;
            ProductDAO1 p      = new ProductDAO1();
            int         result = p.Edit(s);

            if (result == 1)
            {
                MessageBox.Show("Cập nhật sản phẩm thành công");
                LoadData();
                Clear();
            }
            else
            {
                MessageBox.Show("Cập nhật sản phẩm thất bại");
            }
            if ((idproduct == 0) && (name == ""))
            {
                LoadDataByResetButton();
            }
            else
            {
                FindProduct();
            }
        }
Esempio n. 3
0
        private void txtNameProduct_TextChanged_1(object sender, EventArgs e)
        {
            ProductDAO1 p  = new ProductDAO1();
            DBContextSV db = new DBContextSV(Program.connectionString);

            dataGridViewListProduct.DataSource = db.sanphams.Where(x => x.tensp.Contains(txtNameProduct.Text)).ToList();
        }
Esempio n. 4
0
        private void iconbtnDelete_Click(object sender, EventArgs e)
        {
            string      ID     = txtID.Text;
            ProductDAO1 p      = new ProductDAO1();
            int         result = p.Delete(ID);

            if (result == 1)
            {
                MessageBox.Show("Xóa sản phẩm thành công");
                LoadData();
                Clear();
            }
            else
            {
                MessageBox.Show("Xóa sản phẩm thất bại");
            }
            if ((idproduct == 0) && (name == ""))
            {
                LoadDataByResetButton();
            }
            else
            {
                FindProduct();
            }
        }
Esempio n. 5
0
        private void iconbtnAdd_Click(object sender, EventArgs e)
        {
            sanpham s = new sanpham();

            s.masp   = txt_masp.Text;
            s.tensp  = txt_tenSP.Text;
            s.loai   = cbTypeProduct.Text;
            s.nhacc  = cbSupplier.Text;
            s.nhasx  = cbNSX.Text;
            s.giaban = Int32.Parse(txtPrice.Text);
            ProductDAO1 p   = new ProductDAO1();
            StorageDAO  kho = new StorageDAO();

            if (p.create(s) == 1)
            {
                MessageBox.Show("Thêm thành công");
            }
            else
            {
                MessageBox.Show("Thêm thất bại");
            }
        }