예제 #1
0
        public JsonResult SaveProduct(string product)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            Product p = serializer.Deserialize <Product>(product);

            try
            {
                if (p != null)
                {
                    if (p.ID == 0)
                    {
                        productBLL.AddProduct(p);
                    }
                    else
                    {
                        productBLL.EditProduct(p);
                    }
                    return(Json(true));
                }
                else
                {
                    return(Json(false));
                }
            }
            catch (Exception)
            {
                return(Json(false));
            }
        }
        private void btnSua_Click(object sender, EventArgs e)
        {
            ProductBLL productBLL = new ProductBLL();
            Product    product    = new Product();

            product.productname = txtProductname.Text;
            product.detail      = txtDetail.Text;
            product.price       = int.Parse(price.Value.ToString());
            product.amount      = int.Parse(amount.Value.ToString());

            /* Lấy Id từ commobox đưa vào cơ sở dữ liệu */
            Category s = (Category)comboCategory.SelectedItem;

            product.categoryid = s.Id;

            /*Lấy Tên Ảnh đưa vào cơ sở dữ liệu*/
            product.image = path;
            try
            {
                if (flag && !File.Exists(DBConnection.folder_product + path))
                {
                    File.Copy(fullpath, DBConnection.folder_product + path);
                }
                productBLL.EditProduct(product, id);
            }
            catch (Exception)
            {
            }
            LoadListview();
            flag = false;
        }
예제 #3
0
 public ActionResult EditProduct(Product product)
 {
     if (ModelState.IsValid)
     {
         productBll.EditProduct(product);
     }
     return(RedirectToAction("GetProducts"));
 }
예제 #4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            LapDonHangBLL donHangBLL = new LapDonHangBLL();

            if (newCus)
            {
                donHangBLL.AddKhach(firstname, lastname, phone, address);
            }
            int totalqty = 0;

            foreach (ObjCombo item in arr_combo)
            {
                totalqty += item.Quantity;
                ComboBLL  comboBLL = new ComboBLL();
                ArrayList listid   = comboBLL.ListIDProduct(item.Combo.Id);
                foreach (int a in listid)
                {
                    ProductBLL productBLL = new ProductBLL();
                    productBLL.EditProduct(item.Quantity, a);
                }
            }
            foreach (ObjProduct item in arr_product)
            {
                totalqty += item.Quantity;
                ProductBLL productBLL = new ProductBLL();
                productBLL.EditProduct(item.Quantity, item.Product.id);
            }
            Invoice invoice = new Invoice();

            if (newCus)
            {
                invoice.customer_id = donHangBLL.getIdCustommer();
            }
            else
            {
                invoice.customer_id = idcus;
            }
            invoice.customeraddress = address;
            invoice.totalmoney      = txtThanhtien.Text.Replace(",", "");
            invoice.amount          = totalqty.ToString();
            invoice.creatday        = DateTime.Now;
            invoice.ordernote       = "123";
            invoice.postcode        = "123";
            invoice.status          = "Done";
            donHangBLL.AddInvoice(invoice);
            string products = "";

            if (arr_product.Count != 0)
            {
                products = JsonConvert.SerializeObject(arr_product);
            }
            string combos = "";

            if (arr_combo.Count != 0)
            {
                combos = JsonConvert.SerializeObject(arr_combo);
            }
            donHangBLL.AddInvoiceDetail(products, combos);
            LoadListViewSelect();
            arr_combo   = new ArrayList();
            arr_product = new ArrayList();
            MessageBox.Show("Đã thêm đơn hàng thành công");
        }