public string GetIDProductBill(string namepro)
        {
            DTO_Product dtt  = new DTO_Product();
            string      masp = dataProduct.GetIdProduct(namepro);

            return(masp);
        }
        public int addProduct(string nameProduct, string infoProduct, long categoryId, long brandId, long userId, bool sessionAuth)
        {
            try
            {
                if (checkPermission.checkAuth(sessionAuth))
                {
                    DTO_Product dto_product = new DTO_Product();

                    dto_product.ProductId   = dal_products.increment();
                    dto_product.NameProduct = nameProduct;
                    dto_product.InfoProduct = infoProduct;
                    dto_product.CategoryId  = categoryId;
                    dto_product.BrandId     = brandId;
                    dto_product.Point       = 0;
                    dto_product.UserId      = userId;

                    if (dal_products.addProduct(dto_product))
                    {
                        return(200);
                    }
                    else
                    {
                        return(400);
                    }
                }
                else
                {
                    return(403);
                }
            }
            catch
            {
                return(400);
            }
        }
        public bool DAL_AddNewProduct(DTO_Product product)
        {
            try
            {
                using (SqlCommand cmd = new SqlCommand("ThemMoiSanPham", _conn)
                {
                    CommandType = CommandType.StoredProcedure,
                })
                {
                    _conn.Open();

                    cmd.Parameters.AddWithValue("@MaLoai", product.CategoryID);
                    cmd.Parameters.AddWithValue("@MaHangSX", product.ManufacturerID);
                    cmd.Parameters.AddWithValue("@TenSP", product.ProductName);
                    cmd.Parameters.AddWithValue("@DonGia", product.ProductPrice);
                    cmd.Parameters.AddWithValue("@SoLuong", product.ProductQuantity);
                    cmd.Parameters.AddWithValue("@HinhAnh", product.ProductImage);


                    if (cmd.ExecuteNonQuery() <= 0)
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                _conn.Close();
            }
            return(true);
        }
示例#4
0
        private void btnUpdateProduct_Click(object sender, EventArgs e)
        {
            Image imagee = pictureBoxImageProduct.Image;

            byte[]         image_aray;
            ImageConverter converter = new ImageConverter();

            image_aray = (byte[])converter.ConvertTo(imagee, typeof(byte[]));
            DTO_Product ex = new DTO_Product();

            ex.MaSP      = txtIdProduct.Text;
            ex.TenSP     = txtNameProduct.Text;
            ex.MaLSP     = Convert.ToInt32(comboBoxTypeProduct.SelectedValue);
            ex.GiaNhap   = Convert.ToDecimal(txtPriceProduct.Text);
            ex.GiaBan    = Convert.ToDecimal(txtSellPriceProduct.Text);
            ex.SoLuong   = Convert.ToInt32(txtAmoutProduct.Text);
            ex.HinhAnh   = image_aray;
            ex.KhuyenMai = Convert.ToInt32(txtSaleProduct.Text);
            ex.HSD       = Convert.ToDateTime(dateTimePickerEXP.Text);
            ex.NSX       = Convert.ToDateTime(dateTimePickerMFG.Text);
            dataProduct1.EditProduct(ex);
            MessageBox.Show("Cập nhật sản phẩm thành công!");
            ShowDataProduct();
            ClearForms();
        }
        private void btnAddToCart_Click(object sender, EventArgs e)
        {
            string      id        = txtProID.Text;
            string      proIdtype = dgvProduct.Rows[indexPro].Cells[2].Value.ToString();
            string      name      = txtProName.Text;
            float       size      = float.Parse(txtSize.Text);
            int         price     = int.Parse(txtProPrice.Text);
            int         quantity  = int.Parse(QuantityUpDown.Value.ToString());
            string      discount  = txtDiscount.Text;
            DTO_Product product   = findProductByID(id, listCart);

            dgvCart.DataSource = null;
            if (product != null)
            {
                product.proQuantity += quantity;
                product.proPrice    += price;
                dgvCart.DataSource   = listCart;
                QuantityUpDown.Value = 1;

                dgvCart.Columns["proIdType"].Visible = false;
                dgvCart.Columns["proStatus"].Visible = false;
            }
            else
            {
                DTO_Product x = new DTO_Product(id, proIdtype, name, size, price, quantity, discount);
                listCart.Add(x);
                dgvCart.DataSource = listCart;

                dgvCart.Columns["proIdType"].Visible = false;
                dgvCart.Columns["proStatus"].Visible = false;
                QuantityUpDown.Value = 1;
            }
            loadTotal();
        }
示例#6
0
        private void txtSearchProduct_TextChanged(object sender, EventArgs e)
        {
            DTO_Product     ex      = new DTO_Product();
            BLL_DataProduct bl      = new BLL_DataProduct();
            string          keyword = txtSearchProduct.Text;

            try
            {
                if (keyword == "")
                {
                    tensp = txtProductName.Text;
                    txtAmoutProduct.Text          = "";
                    txtPriceProduct.Text          = "";
                    txtProductName.Text           = "";
                    pictureBoxImageeProduct.Image = null;
                    return;
                }
                else
                {
                    ex = bl.searchProductBill(keyword);
                    int khuyenmai = ex.KhuyenMai;
                    txtProductName.Text = ex.TenSP;
                    decimal giaban = (ex.GiaBan * ((100 - (decimal)khuyenmai) / 100));
                    txtPriceProduct.Text          = Convert.ToString(giaban);
                    pictureBoxImageeProduct.Image = byteArrayToImage(ex.HinhAnh);
                }
            }
            catch
            {
                //MessageBox.Show(exx.Message);
            }
        }
示例#7
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         Image          imagee = pictureBoxImageProduct.Image;
         byte[]         image_aray;
         ImageConverter converter = new ImageConverter();
         image_aray = (byte[])converter.ConvertTo(imagee, typeof(byte[]));
         DTO_Product pd = new DTO_Product();
         pd.MaSP  = txtIdProduct.Text;
         pd.TenSP = txtNameProduct.Text;
         pd.MaLSP = Convert.ToInt32(comboBoxTypeProduct.SelectedValue);
         decimal gianhap = Convert.ToDecimal(txtPriceProduct.Text);
         pd.GiaNhap = gianhap;
         decimal loinhuan = ((100 + (Convert.ToDecimal(txtProfit.Text))) * gianhap) / 100;
         txtSellPriceProduct.Text = Convert.ToString(loinhuan);
         pd.GiaBan    = loinhuan;
         pd.SoLuong   = Convert.ToInt32(txtAmoutProduct.Text);
         pd.HinhAnh   = image_aray;
         pd.KhuyenMai = Convert.ToInt32(txtSaleProduct.Text);
         pd.HSD       = dateTimePickerEXP.Value;
         pd.NSX       = dateTimePickerMFG.Value;
         if (gianhap > 0)
         {
             dataProduct1.InsertProduct(pd);
             MessageBox.Show("Thêm sản phẩm thành công!");
         }
         ShowDataProduct();
         ClearForms();
     }
     catch (Exception ex)
     {
         MessageBox.Show("loi" + ex);
     }
 }
        public DTO_Product searchProductBill(string keyword)
        {
            DTO_Product k = new DTO_Product();

            k = dataProduct.searchProductforBill(keyword);
            return(k);
        }
        // lưu danh sách các sản phẩm dựa vào danh mục vào 1 list
        private void GetDataProducts(int nComboBoxSeletedValue = -1)
        {
            listProducts.Clear();

            // nếu chọn tất cả thì cho = -1
            if (cmbProductCategories.GetItemText(cmbProductCategories.SelectedItem) == "Tất cả")
            {
                nComboBoxSeletedValue = -1;
            }

            // lây danh sách sản phẩm dựa vào loại sản phẩm
            DataTable dtProducts = bus_Products.BUS_GetProduct(nComboBoxSeletedValue);

            if (dtProducts == null)
            {
                MessageBox.Show("Có lỗi xảy ra khi load dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            foreach (DataRow row in dtProducts.Rows)
            {
                DTO_Product product = new DTO_Product
                {
                    ID              = int.Parse(row["ID_MASP"].ToString()),
                    CategoryID      = int.Parse(row["ID_MALOAI"].ToString()),
                    ManufacturerID  = int.Parse(row["ID_HANGSX"].ToString()),
                    ProductName     = row["TENSP"].ToString(),
                    ProductQuantity = int.Parse(row["SOLUONG"].ToString()),
                    ProductPrice    = int.Parse(row["DONGIA"].ToString()),
                    ProductImage    = (Byte[])row["HINHANH"]
                };

                listProducts.Add(product);
            }
        }
示例#10
0
 public void Deleted(DTO_Product ex)
 {
     sqlCm.Connection  = connectionProduct.OpenConnection();
     sqlCm.CommandText = "DELETEDPRODUCT";
     sqlCm.CommandType = CommandType.StoredProcedure;
     sqlCm.Parameters.AddWithValue("@maSP", ex.MaSP);
     sqlCm.ExecuteNonQuery();
     sqlCm.Parameters.Clear();
 }
示例#11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtName.Text == "" || txtAmount.Text == "" || txtPrice.Text == "" || txtWarrantyDate.Text == "")
            {
                MessageBox.Show("Vui lòng nhập tên cho sản phẩm", "Thông báo");
                return;
            }

            if (!isInt(txtAmount.Text))
            {
                MessageBox.Show("Số lượng phải là số !", "Thông báo");
                return;
            }

            if (!isInt(txtPrice.Text))
            {
                MessageBox.Show("Giá tiền phải là số !", "Thông báo");
                return;
            }

            if (!isInt(txtWarrantyDate.Text))
            {
                MessageBox.Show("Thời hạn bảo hành phải là số !", "Thông báo");
                return;
            }

            DTO_Product info = new DTO_Product();

            info.Account.Id     = Convert.ToInt32(Account["id"]);
            info.Category.Id    = Convert.ToInt32(cboCategory.SelectedValue);
            info.Producer.Id    = Convert.ToInt32(cboProducer.SelectedValue);
            info.Origin.Id      = Convert.ToInt32(cboOrigin.SelectedValue);
            info.Name           = txtName.Text;
            info.Amount         = Convert.ToInt32(txtAmount.Text);
            info.Price          = Convert.ToInt32(txtPrice.Text);
            info.WarrantyPeriod = Convert.ToInt32(txtWarrantyDate.Text);

            if (this.action == "add")
            {
                bus.addItem(info);
            }

            if (this.action == "edit")
            {
                bus.editItem(Convert.ToInt32(txtId.Text), info);
            }

            foreach (DataGridViewRow row in dataGridView.SelectedRows)
            {
                this.index = row.Index;
            }

            GUI_Product_Load(sender, e);
            endableAll(true);
            groupBox.Enabled         = false;
            dataGridView.CurrentCell = dataGridView.Rows[this.index].Cells[0];
        }
示例#12
0
        public void addItem(DTO_Product info)
        {
            string[] valss =
            {
                info.Name,
                info.Category.Id.ToString(),
                info.Producer.Id.ToString(),
                info.Origin.Id.ToString(),
                info.Price.ToString()
            };
            DataRow product = dataProduct.getID(valss);

            if (product == null)
            {
                string   timeNow = DateTime.Now.ToString("yyyy-MM-dd");
                string[] val     =
                {
                    timeNow
                };
                DataRow getImport = dataImport.getDate(val);
                if (getImport == null)
                {
                    info.Import.Id = dataImport.InsertID(val);
                }
                else
                {
                    info.Import.Id = Convert.ToInt32(getImport["id"]);
                }
                string[] value =
                {
                    info.Account.Id.ToString(),
                    info.Category.Id.ToString(),
                    info.Producer.Id.ToString(),
                    info.Import.Id.ToString(),
                    info.Origin.Id.ToString(),
                    info.Name,
                    info.Amount.ToString(),
                    info.Price.ToString(),
                    info.WarrantyPeriod.ToString()
                };
                dataProduct.Insert(value);
            }
            else
            {
                int      soluong = Convert.ToInt32(product["amount"]) + info.Amount;
                string[] value   =
                {
                    soluong.ToString(),
                    product["id"].ToString()
                };
                dataProduct.UpdateAmount(value);
            }
        }
示例#13
0
        private void btnDeleteProduct_Click(object sender, EventArgs e)
        {
            DTO_Product ex = new DTO_Product();

            txtIdProduct.Text = dataGridViewProduct.CurrentRow.Cells["Mã sản phẩm"].Value.ToString();
            ex.MaSP           = txtIdProduct.Text;
            if (MessageBox.Show("Bạn có chắn chắn muốn xóa sản phẩm này!", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                dataProduct1.DeletedProduct(ex);
            }
            ShowDataProduct();
            ClearForms();
        }
示例#14
0
 public void editItem(int id, DTO_Product info)
 {
     string[] value =
     {
         info.Category.Id.ToString(),
         info.Producer.Id.ToString(),
         info.Origin.Id.ToString(),
         info.Name,
         info.Amount.ToString(),
         info.Price.ToString(),
         info.WarrantyPeriod.ToString(),
         id.ToString()
     };
     dataProduct.Update(value);
 }
        public static bool updateProduct(DTO_Product pro)
        {
            string sql = string.Format("Update Products set IDProductType = (select IDProductType from ProductTypes where NameProductType= '{0}'), NameProduct = '{1}', Size = '{2}', Price = '{3}', Quantity = '{4}' , Discount = '{5}' where IDProduct = '{6}' ", pro.proIdType, pro.proName, pro.proSize, pro.proPrice, pro.proQuantity, pro.discount, pro.proID);

            cnn = DataProvider.ConnectData();
            SqlCommand command = new SqlCommand(sql, cnn);
            int        row     = command.ExecuteNonQuery();

            cnn.Close();
            if (row > 0)
            {
                return(true);
            }
            return(false);
        }
        public static bool addProduct(DTO_Product pro)
        {
            string sql = string.Format("insert into Products values (  dbo.countProductbyIDshop(), (select IDProductType from ProductTypes where NameProductType= '{0}'),'{1}' ,'{2}','{3}','{4}','{5}','On')", pro.proIdType, pro.proName, pro.proSize, pro.proPrice, pro.proQuantity, pro.discount);

            cnn = DataProvider.ConnectData();
            SqlCommand command = new SqlCommand(sql, cnn);
            int        row     = command.ExecuteNonQuery();

            cnn.Close();
            if (row > 0)
            {
                return(true);
            }
            return(false);
        }
示例#17
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (CheckData() == true)
     {
         DTO_Product dto_pro = new DTO_Product(txtProductID.Text, txtProductType.Text, txtName.Text, txtSupplier.Text, txtNation.Text, long.Parse(txtPrice.Text));
         if (bus_pro.Edit(dto_pro))
         {
             MessageBox.Show("EDIT SUCCESS!", "EDIT", MessageBoxButtons.OK, MessageBoxIcon.Information);
             LoadData();
         }
         else
         {
             MessageBox.Show("EDIT FAIL!", "EDIT", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
示例#18
0
        public bool updateProduct(DTO_Product product)
        {
            String     query   = "UPDATE MATHANG SET TENMH = @productName, SL_TON = @productAmount, DONVITINH = @productUnit, DONGIA = @productPrice WHERE MSMH = @productID";
            SqlCommand command = new SqlCommand(query, DAL_CDBConnect.myconn);

            command.Parameters.Add("@productID", SqlDbType.Char).Value       = product.ProductID;
            command.Parameters.Add("@productName", SqlDbType.NVarChar).Value = product.ProductName;
            command.Parameters.Add("@productAmount", SqlDbType.Int).Value    = product.ProductAmount;
            command.Parameters.Add("@productPrice", SqlDbType.Float).Value   = product.ProductPrice;
            command.Parameters.Add("@productUnit", SqlDbType.NVarChar).Value = product.ProductUnit;

            bool success = command.ExecuteNonQuery() >= 0;

            command.Dispose();
            return(success);
        }
示例#19
0
        public bool insertProduct(DTO_Product product)
        {
            String     query   = "INSERT INTO MATHANG VALUES(@productID, @productName, @productAmount, @productPrice, @productUnit)";
            SqlCommand command = new SqlCommand(query, DAL_CDBConnect.myconn);

            command.Parameters.Add("@productID", SqlDbType.Char).Value       = product.ProductID;
            command.Parameters.Add("@productName", SqlDbType.NVarChar).Value = product.ProductName;
            command.Parameters.Add("@productAmount", SqlDbType.Int).Value    = product.ProductAmount;
            command.Parameters.Add("@productPrice", SqlDbType.Float).Value   = product.ProductPrice;
            command.Parameters.Add("@productUnit", SqlDbType.NVarChar).Value = product.ProductUnit;

            bool success = command.ExecuteNonQuery() >= 0;

            command.Dispose();
            return(success);
        }
示例#20
0
        public bool DAL_UpdateProductInfoAndProfile(DTO_Product product, DTO_ProductProfile productProfile)
        {
            try
            {
                _conn.Open();

                using (SqlCommand cmd = new SqlCommand("UpdateThongTinVaCauHinhSanPham", _conn)
                {
                    CommandType = CommandType.StoredProcedure,
                })
                {
                    // product
                    cmd.Parameters.AddWithValue("@MaSP", product.ID);
                    cmd.Parameters.AddWithValue("@MaLoai", product.CategoryID);
                    cmd.Parameters.AddWithValue("@MaHangSX", product.ManufacturerID);
                    cmd.Parameters.AddWithValue("@TenSP", product.ProductName);
                    cmd.Parameters.AddWithValue("@DonGia", product.ProductPrice);
                    cmd.Parameters.AddWithValue("@HinhAnh", product.ProductImage);

                    // product profile
                    cmd.Parameters.AddWithValue("@Id_ChiTietCauHinh", productProfile.IDProductProfile);
                    cmd.Parameters.AddWithValue("@CPU", productProfile.CPU);
                    cmd.Parameters.AddWithValue("@GPU", productProfile.GPU);
                    cmd.Parameters.AddWithValue("@RAM", productProfile.RAM);
                    cmd.Parameters.AddWithValue("@BoNho", productProfile.Storage);
                    cmd.Parameters.AddWithValue("@ManHinh", productProfile.Screen);
                    cmd.Parameters.AddWithValue("@Camera", productProfile.Camera);
                    cmd.Parameters.AddWithValue("@Pin", productProfile.PIN);
                    cmd.Parameters.AddWithValue("@HeDieuHanh", productProfile.OS);
                    cmd.Parameters.AddWithValue("@Khac", productProfile.More);

                    if (cmd.ExecuteNonQuery() <= 0)
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                _conn.Close();
            }
            return(true);
        }
示例#21
0
 public void Edita(DTO_Product ex)
 {
     sqlCm.Connection  = connectionProduct.OpenConnection();
     sqlCm.CommandText = "EDITPRODUCT";
     sqlCm.CommandType = CommandType.StoredProcedure;
     sqlCm.Parameters.AddWithValue("@maSP", ex.MaSP);
     sqlCm.Parameters.AddWithValue("@tenSP", ex.TenSP);
     sqlCm.Parameters.AddWithValue("@maLSP", ex.MaLSP);
     sqlCm.Parameters.AddWithValue("@giaNhap", ex.GiaNhap);
     sqlCm.Parameters.AddWithValue("@giaBan", ex.GiaBan);
     sqlCm.Parameters.AddWithValue("@soLuong", ex.SoLuong);
     sqlCm.Parameters.AddWithValue("@khuyenMai", ex.KhuyenMai);
     sqlCm.Parameters.AddWithValue("@NSX", ex.NSX);
     sqlCm.Parameters.AddWithValue("@HSD", ex.HSD);
     sqlCm.Parameters.AddWithValue("@hinhAnh", ex.HinhAnh);
     sqlCm.ExecuteNonQuery();
     sqlCm.Parameters.Clear();
 }
 private void btnRemove_Click(object sender, EventArgs e)
 {
     try
     {
         DataGridViewRow selectedRow = dgvCart.Rows[indexCart];
         string          id          = selectedRow.Cells[0].Value.ToString();
         DTO_Product     product     = findProductByID(id, listCart);
         listCart.Remove(product);
         dgvCart.DataSource = listCart;
         loadTotal();
         if (listCart.Count == 0)
         {
             dgvCart.Columns.Clear();
         }
     }
     catch (Exception)
     {
     }
 }
示例#23
0
        public string GetIdProduct(string namepro)
        {
            DataTable   dataTable = new DataTable();
            DTO_Product ex        = new DTO_Product();
            string      masp      = "";

            sqlCm.Connection  = connectionProduct.OpenConnection();
            sqlCm.CommandText = "SELECT maSP FROM SANPHAM WHERE tenSP=N'" + namepro + "'";
            sqlCm.CommandType = CommandType.Text;
            SqlDataAdapter adapter = new SqlDataAdapter(sqlCm);

            adapter.Fill(dataTable);
            if (dataTable.Rows.Count > 0)
            {
                masp = dataTable.Rows[0]["maSP"].ToString();
            }
            connectionProduct.CloseConnection();
            return(masp);
        }
示例#24
0
        public void GetInfoProduct(List <DTO_Product> lstProducts)
        {
            DataTable dt = DAO_NhapXuatKho.Instance.GetInfoProduct();

            //lstProducts.AddRange(from DataRow item in dt.Rows select new DTO_Product((string) item[0], (string) item[1], (string) item[2], float.Parse(item[3].ToString()), (string) item[4]));

            foreach (DataRow item in dt.Rows)
            {
                if (string.IsNullOrEmpty(item[3].ToString()))
                {
                    item[3] = 0.0;
                }
                if (string.IsNullOrEmpty(item[4].ToString()))
                {
                    item[4] = "-";
                }
                DTO_Product rm = new DTO_Product((string)item[0], (string)item[1], (string)item[2], float.Parse(item[3].ToString()), (string)item[4]);
                lstProducts.Add(rm);
            }
        }
示例#25
0
        public DTO_Product searchProductforBill(string keyword)
        {
            DTO_Product k         = new DTO_Product();
            DataTable   dataTable = new DataTable();

            sqlCm.Connection  = connectionProduct.OpenConnection();
            sqlCm.CommandText = "SELECT tenSP,replace(convert(varchar,cast(floor(giaBan) as money),1), '.00', '')as giaBan,soLuong,khuyenMai,hinhAnh FROM SANPHAM WHERE maSP LIKE '%" + keyword + "%' OR tenSP LIKE N'%" + keyword + "%' ";
            sqlCm.CommandType = CommandType.Text;
            SqlDataAdapter adapter = new SqlDataAdapter(sqlCm);

            adapter.Fill(dataTable);
            if (dataTable.Rows.Count > 0)
            {
                k.TenSP     = dataTable.Rows[0]["tenSP"].ToString();
                k.SoLuong   = Convert.ToInt32(dataTable.Rows[0]["soLuong"].ToString());
                k.GiaBan    = Convert.ToDecimal(dataTable.Rows[0]["giaBan"].ToString());
                k.KhuyenMai = Convert.ToInt32(dataTable.Rows[0]["khuyenMai"].ToString());
                k.HinhAnh   = (byte[])dataTable.Rows[0]["hinhAnh"];
            }
            connectionProduct.CloseConnection();
            return(k);
        }
示例#26
0
        public int editProduct(long productId, string nameProduct, string infoProduct, long categoryId, long brandId, long userId, bool sessionAuth)
        {
            try
            {
                if (checkPermission.checkAuth(sessionAuth))
                {
                    DTO_Product dto_product = new DTO_Product();

                    dto_product.ProductId   = productId;
                    dto_product.NameProduct = nameProduct;
                    dto_product.InfoProduct = infoProduct;
                    dto_product.CategoryId  = categoryId;
                    dto_product.BrandId     = brandId;
                    dto_product.Point       = dal_products.getPoint();
                    dto_product.UserId      = userId;

                    //if (checkRoleProduct.checkRole(dto_product.ProductId, userId) || checkPermission.isAdmin(userId))
                    // {
                    if (dal_products.editProduct(dto_product))
                    {
                        return(200);
                    }
                    else
                    {
                        return(400);
                    }
                    //}
                    // else return false;
                }
                else
                {
                    return(403);
                }
            }
            catch
            {
                return(400);
            }
        }
示例#27
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (CheckData() == true)
     {
         if (Check_ProductIDExist() == true)
         {
             DTO_Product dto_pro = new DTO_Product(txtProductID.Text, txtProductType.Text, txtName.Text, txtSupplier.Text, txtNation.Text, long.Parse(txtPrice.Text));
             if (bus_pro.Add(dto_pro))
             {
                 MessageBox.Show("ADDING SUCCESS!", "ADD", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 LoadData();
                 ResetValues();
             }
             else
             {
                 MessageBox.Show("ADDING FAIL!", "ADD", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         else
         {
             MessageBox.Show("'    " + txtProductID.Text + "' already exists!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
示例#28
0
 public bool addProduct(DTO_Product dto_product)
 {
     try
     {
         openConnect();
         SqlCommand cmd = new SqlCommand("stp_addProduct", conn); //Tên store procedure
         cmd.CommandType = CommandType.StoredProcedure;           //Cho biết đây là store procedure
         cmd.Parameters.AddWithValue("@masp", dto_product.ProductId);
         cmd.Parameters.AddWithValue("@tensp", dto_product.NameProduct);
         cmd.Parameters.AddWithValue("@thongtin", dto_product.InfoProduct);
         cmd.Parameters.AddWithValue("@madm", dto_product.CategoryId);
         cmd.Parameters.AddWithValue("@math", dto_product.BrandId);
         cmd.Parameters.AddWithValue("@diemdanhgia", dto_product.Point);
         cmd.Parameters.AddWithValue("@matk", dto_product.UserId);
         cmd.ExecuteNonQuery();
         closeConnect(); //Đóng kết nối
         return(true);
     }
     catch
     {
         closeConnect();
         return(false);
     }
 }
示例#29
0
 public bool Edit(DTO_Product dto_pro)
 {
     return(dto_pro.Edit());
 }
示例#30
0
 public bool Add(DTO_Product dto_pro)
 {
     return(dto_pro.Add());
 }