コード例 #1
0
ファイル: Form1.cs プロジェクト: NetoVillalobos/ShoesApp
        private void GetProducts_SP()
        {
            List <JEVJ1_MuestraProductos_Result> lst = ProductBL.GetProducts_SP();

            dgvProducts.DataSource = lst.ToList();
        }
コード例 #2
0
        //public static async Task CancelRetailerOrder()
        //{
        //    List<OrderDetail> matchingOrder = new List<OrderDetail>();//list maintains the order details of the order which user wishes to cancel
        //    try
        //    {
        //        using (IRetailerBL retailerBL = new RetailerBL())
        //        {
        //            //gives the current retailer
        //            Retailer retailer = await retailerBL.GetRetailerByEmailBL(CommonData.CurrentUser.Email);
        //            using (IOrderBL orderDAL = new OrderBL())
        //            {
        //                //list of orders ordered by the retailer
        //                List<Order> RetailerOrderList = await orderDAL.GetOrdersByRetailerIDBL(retailer.RetailerID);
        //                Console.WriteLine("Enter the order number which you want to cancel");
        //                int orderToBeCancelled = int.Parse(Console.ReadLine());//user input of order which he has to cancel
        //                foreach (Order order in RetailerOrderList)
        //                {
        //                    using (IOrderDetailBL orderDetailBL = new OrderDetailBL())
        //                    {
        //                        //getting the order details of required order to be cancelled
        //                        List<OrderDetail> RetailerOrderDetails = await orderDetailBL.GetOrderDetailsByOrderIDBL(order.OrderId);
        //                        matchingOrder = RetailerOrderDetails.FindAll(
        //                                   (item) => { return item.OrderSerial == orderToBeCancelled; }
        //                               );
        //                        break;
        //                    }
        //                }

        //                if (matchingOrder.Count != 0)
        //                {
        //                    OrderDetailBL orderDetailBL = new OrderDetailBL();
        //                    //cancel order if order not delivered
        //                    if (!( await orderDetailBL.UpdateOrderDeliveredStatusBL(matchingOrder[0].OrderId)))
        //                    {
        //                        int serial = 0;
        //                        Console.WriteLine("Products in the order are ");
        //                        foreach (OrderDetail orderDetail in matchingOrder)
        //                        {
        //                            //displaying order details with the products ordered
        //                            serial++;
        //                            Console.WriteLine("#\tProductID \t ProductQuantityOrdered");
        //                            Console.WriteLine($"{ serial}\t{ orderDetail.ProductID}\t{ orderDetail.ProductQuantityOrdered}");
        //                        }
        //                        Console.WriteLine("Enter The Product to be Cancelled");
        //                        int ProductToBeCancelled = int.Parse(Console.ReadLine());
        //                        Console.WriteLine("Enter The Product Quantity to be Cancelled");
        //                        int quantityToBeCancelled = int.Parse(Console.ReadLine());
        //                        if (matchingOrder[ProductToBeCancelled - 1].ProductQuantityOrdered >= quantityToBeCancelled)
        //                        {
        //                            //updating order quantity and revenue
        //                            matchingOrder[ProductToBeCancelled - 1].ProductQuantityOrdered -= quantityToBeCancelled;
        //                            matchingOrder[ProductToBeCancelled - 1].TotalAmount -= matchingOrder[ProductToBeCancelled - 1].ProductPrice * quantityToBeCancelled;
        //                            OrderDetailBL orderDetailBL1 = new OrderDetailBL();
        //                            await orderDetailBL1.UpdateOrderDetailsBL(matchingOrder[ProductToBeCancelled - 1]);

        //                            Console.WriteLine("Product Cancelled Succesfully");

        //                        }
        //                        else
        //                        {
        //                            Console.WriteLine("PRODUCT QUANTITY EXCEEDED");
        //                        }
        //                    }
        //                    else
        //                    {
        //                        Console.WriteLine("Order Can't be cancelled as it is delivered");
        //                    }
        //                }
        //            }
        //        }
        //    }
        //    catch (Exception)
        //    {

        //        throw;
        //    }
        //}



        public static async Task CancelRetailerOrder()
        {
            IProductBL         productBL     = new ProductBL();
            List <OrderDetail> matchingOrder = new List <OrderDetail>();//list maintains the order details of the order which user wishes to cancel

            Console.WriteLine("Enter the order number which you want to cancel");
            double orderToBeCancelled = double.Parse(Console.ReadLine());//user input of order which he has to cancel

            Console.WriteLine("Entered Number is: " + orderToBeCancelled);
            try
            {
                using (IOrderBL orderBL = new OrderBL())
                {
                    try
                    {
                        Order order = await orderBL.GetOrderByOrderNumberBL(orderToBeCancelled);

                        using (IOrderDetailBL orderDetailBL = new OrderDetailBL())
                        {
                            matchingOrder = await orderDetailBL.GetOrderDetailsByOrderIDBL(order.OrderId);

                            int a = matchingOrder.Count();
                            Console.WriteLine("No. of Products ordered: " + a);
                        }
                    }
                    catch (Exception)
                    {
                        WriteLine("Invalid OrderId");
                    }
                }


                if (matchingOrder.Count != 0)
                {
                    OrderDetailBL orderDetailBL = new OrderDetailBL();
                    //cancel order if order not delivered
                    if ((await orderDetailBL.UpdateOrderDeliveredStatusBL(matchingOrder[0].OrderId)))
                    {
                        int serial = 0;

                        Console.WriteLine("Products in the order are ");
                        Console.WriteLine("# \t\t\tProductID \t\t\t ProductQuantityOrdered \t\t UnitProductPrice");
                        foreach (OrderDetail orderDetail in matchingOrder)
                        {
                            //displaying order details with the products ordered
                            Product product = await productBL.GetProductByProductIDBL(orderDetail.ProductID);

                            serial++;
                            //Console.WriteLine(product.ProductName);
                            Console.WriteLine($"{ serial}\t{ orderDetail.ProductID}\t\t{ orderDetail.ProductQuantityOrdered}\t\t{orderDetail.ProductPrice}");
                        }
                        Console.WriteLine("Enter The Product to be Cancelled");
                        int ProductToBeCancelled = int.Parse(Console.ReadLine());
                        if (ProductToBeCancelled < matchingOrder.Count && ProductToBeCancelled > 0)
                        {
                            Console.WriteLine("Enter The Product Quantity to be Cancelled");
                            int quantityToBeCancelled = int.Parse(Console.ReadLine());
                            if (matchingOrder[ProductToBeCancelled - 1].ProductQuantityOrdered >= quantityToBeCancelled)
                            {
                                //updating order quantity and revenue
                                matchingOrder[ProductToBeCancelled - 1].ProductQuantityOrdered -= quantityToBeCancelled;
                                matchingOrder[ProductToBeCancelled - 1].TotalAmount            -= matchingOrder[ProductToBeCancelled - 1].ProductPrice * quantityToBeCancelled;
                                Console.WriteLine("Total Refund Amount: " + (matchingOrder[ProductToBeCancelled - 1].ProductPrice * quantityToBeCancelled));
                                OrderDetailBL orderDetailBL1 = new OrderDetailBL();
                                await orderDetailBL1.UpdateOrderDetailsBL(matchingOrder[ProductToBeCancelled - 1]);

                                Console.WriteLine("Product Cancelled Succesfully");
                            }
                            else
                            {
                                Console.WriteLine("PRODUCT QUANTITY EXCEEDED");
                            }
                        }
                        else
                        {
                            Console.WriteLine("Wrong Input");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Order Can't be cancelled as it is delivered");
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #3
0
        public static async Task UploadOfflineOrder()
        {
            try
            {
                //Read inputs
                OfflineOrder   offlineOrder    = new OfflineOrder();
                OfflineOrderBL offlineOrderBL1 = new OfflineOrderBL();
                offlineOrder.TotalOrderAmount = 10;
                offlineOrder.TotalQuantity    = 10;

                using (IRetailerBL retailerBL = new RetailerBL())
                {
                    int serial = 0;


                    //Get and display list of Retailer.
                    List <Retailer> retailers = await retailerBL.GetAllRetailersBL();

                    WriteLine("Retailers:");
                    if (retailers != null && retailers?.Count > 0)
                    {
                        WriteLine("#\tName\tEmail\tRetailerID\t");

                        foreach (var retailer in retailers)
                        {
                            serial++;
                            WriteLine($"{serial}\t{retailer.RetailerName}\t{retailer.Email}\t{retailer.RetailerID}");
                        }
                    }

                    Write("Select Retailer #: ");
                    bool isNumberValid = int.TryParse(ReadLine(), out serial);
                    if (isNumberValid)
                    {
                        serial--;
                        if (serial <= retailers.Count - 1)
                        {
                            Retailer retailer1 = retailers[serial];

                            offlineOrder.RetailerID = retailer1.RetailerID;
                        }
                        else
                        {
                            WriteLine("INVALID ENTRY");
                        }
                    }
                    SalesPersonBL salespersonBL = new SalesPersonBL();
                    SalesPerson   salesPerson   = await salespersonBL.GetSalesPersonByEmailBL(CommonData.CurrentUser.Email);

                    offlineOrder.SalesPersonID = salesPerson.SalesPersonID;
                }


                using (IProductBL productBL = new ProductBL())
                {
                    int serial1 = 0;

                    //Get and display list of Product.
                    List <Product> products = await productBL.GetAllProductsBL();

                    WriteLine("Select Products from following List");
                    WriteLine("Products:");
                    if (products != null && products?.Count > 0)
                    {
                        WriteLine("#\tProductName\tPrice\t\tDescription\t");

                        foreach (var product in products)
                        {
                            serial1++;
                            WriteLine($"{serial1}\t{product.ProductName}\t{product.ProductPrice}\t{product.ProductColor}\t{product.ProductSize}\t{product.ProductMaterial}");
                        }
                    }
                    //Add Product Details
                    char c;
                    WriteLine("Add product(Y/N):");
                    c = Char.Parse(ReadLine());

                    while ((c == 'Y') || (c == 'y'))
                    {
                        OfflineOrderDetail offlineOrderDetail = new OfflineOrderDetail();
                        offlineOrderDetail.OfflineOrderID = offlineOrder.OfflineOrderID;

                        Write("Select Product #: ");
                        bool isNumberValid1 = int.TryParse(ReadLine(), out serial1);
                        if (isNumberValid1)
                        {
                            serial1--;
                            if (serial1 <= products.Count - 1)
                            {
                                Product product1 = products[serial1];

                                offlineOrderDetail.ProductID   = product1.ProductID;
                                offlineOrderDetail.UnitPrice   = product1.ProductPrice;
                                offlineOrderDetail.ProductName = product1.ProductName;
                                WriteLine("Enter Quantity:");

                                double quantity = Double.Parse(ReadLine());
                                offlineOrderDetail.Quantity   = quantity;
                                offlineOrderDetail.TotalPrice = offlineOrderDetail.UnitPrice * quantity;
                                using (IOfflineOrderDetailBL offlineOrderDetailBL = new OfflineOrderDetailBL())
                                {
                                    bool isAdded = await offlineOrderDetailBL.AddOfflineOrderDetailBL(offlineOrderDetail);

                                    if (isAdded)
                                    {
                                        WriteLine("Offline Order Detail Added");
                                    }
                                }
                            }
                            else
                            {
                                WriteLine("Invalid Serial Number");
                            }
                        }
                        else
                        {
                            WriteLine("Invalid choice");
                        }

                        WriteLine("Add product(Y/N)");
                        c = Char.Parse(ReadLine());
                    }
                    if (!(c == 'y') || (c == 'Y') || (c == 'n') || (c == 'N'))
                    {
                        WriteLine("Invalid Choice");
                    }
                }

                using (IOfflineOrderBL offlineOrderBL = new OfflineOrderBL())
                {
                    bool isAdded;

                    isAdded = await offlineOrderBL.AddOfflineOrderBL(offlineOrder);

                    if (isAdded)
                    {
                        // WriteLine("Offline Order Added");
                    }

                    using (IOfflineOrderDetailBL offlineOrderDetailBL = new OfflineOrderDetailBL())
                    {
                        //Get and display list of offline order details using order ID .
                        List <OfflineOrderDetail> offlineOrderDetails = await offlineOrderDetailBL.GetAllOfflineOrderDetailBL();

                        WriteLine("OfflineOrderDetails:");
                        if (offlineOrderDetails != null && offlineOrderDetails?.Count > 0)
                        {
                            WriteLine("#\tProductName\tUnitPrice\tQuantity\tTotal Price");
                            int serial2 = 0;
                            foreach (var offlineOrderDetail in offlineOrderDetails)
                            {
                                serial2++;
                                WriteLine($"{serial2}\t{offlineOrderDetail.ProductName}\t\t {offlineOrderDetail.UnitPrice}\t\t {offlineOrderDetail.Quantity}\t\t {offlineOrderDetail.TotalPrice}");
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #4
0
 public ProductModel()
 {
     _productBl = new ProductBL();
 }
コード例 #5
0
        private static void AddProduct()
        {
            try
            {
                Product newProduct = new Product();
                int     choice;

                Console.WriteLine("Press 1 for Juice");
                Console.WriteLine("Press 2 for Soft Drink");
                Console.WriteLine("Press 3 for Energy Drink");
                Console.WriteLine("Press 4 for Mocktail");
                Console.WriteLine("Press 5 for Tonic Water");
                Console.WriteLine("Enter your Choice:");
                do
                {
                    choice = Convert.ToInt32(Console.ReadLine());
                    switch (choice)
                    {
                    case 1:
                        newProduct.ProductType = "Juice";
                        newProduct.ProductCode = "JC";
                        break;

                    case 2:
                        newProduct.ProductType = "Soft Drink";
                        newProduct.ProductCode = "SD";
                        break;

                    case 3:
                        newProduct.ProductType = "Energy Drink";
                        newProduct.ProductCode = "ED";
                        break;

                    case 4:
                        newProduct.ProductType = "Mocktail";
                        newProduct.ProductCode = "MT";
                        break;

                    case 5:
                        newProduct.ProductType = "Tonic Water";
                        newProduct.ProductCode = "TW";
                        break;

                    default:
                        Console.WriteLine("Wrong Choice, please enter again");
                        break;
                    }
                } while ((choice > 6) || (choice < 0));

                Console.WriteLine("Enter Product ID :");
                newProduct.ProductID = Console.ReadLine();
                Console.WriteLine("Enter Product Name :");
                newProduct.ProductName = Console.ReadLine();
                Console.WriteLine("Enter Product MFD :");
                newProduct.ProductMFD = Console.ReadLine();
                Console.WriteLine("Enter Product EXP :");
                newProduct.ProductEXP = Console.ReadLine();

                ProductBL productBL    = new ProductBL();
                bool      productAdded = productBL.AddProductBL(newProduct);
                if (productAdded)
                {
                    Console.WriteLine("Product Added");
                }
                else
                {
                    Console.WriteLine("Product not Added");
                }
            }
            catch (SystemException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string idString = "";
            int    id;

            // get id from URL segment
            try
            {
                var segments = Request.GetFriendlyUrlSegments();
                idString = segments[0];
            }
            catch (Exception ex)
            {
                ex.GetBaseException();
                Debug.Write(ex.ToString());
                lblError.Text = "Error URL";
            }

            // get id from query string and try to parse
            if (!string.IsNullOrEmpty(idString) && int.TryParse(idString, out id))
            {
                //call product from Database
                ProductBL db = new ProductBL();
                SizeBL    sb = new SizeBL();

                if (IsPostBack)
                {
                    labelPrice.Text  = sb.GetPriceBySize(id, Convert.ToInt32(unitDropDownList.SelectedValue)).ToString();
                    totalAmount.Text = GetTotalAmount(labelPrice.Text, quantityDropDownList.SelectedValue.ToString());
                    lblResult.Text   = "";
                }
                if (!IsPostBack)
                {
                    // retrieve a prodcut from our db
                    var            product        = db.GetProduct(id);
                    var            details        = sb.GetDetails(product.GetId());
                    List <SizeDTO> productDetails = details.ToList();

                    //only display available products to the customer
                    if (product != null && product.GetStatus() == 1)
                    {
                        // set up detail page elements with data from the product
                        headerTitle.Text        = product.GetName();
                        headerSubtitle.Text     = product.GetShortInfo();
                        descriptionLabel.Text   = product.GetInfo();
                        destinationImg.ImageUrl = product.GetImgPath();
                        nameLabel.Text          = product.GetName();
                        labelProduct.Text       = product.GetProductType();
                        labelProducer.Text      = product.GetProducer();
                        for (int i = 0; i < productDetails.Count; i++)
                        {
                            unitDropDownList.Items.Add(productDetails[i].GetSize().ToString());
                        }
                        labelPrice.Text = sb.GetPriceBySize(id, Convert.ToInt32(unitDropDownList.SelectedValue)).ToString();
                        for (int i = 1; i < product.GetStock(); i++)
                        {
                            quantityDropDownList.Items.Add(i.ToString());
                        }
                        if (product.GetStock() <= 5)
                        {
                            lowStock.Text = $"Low stock. Only {product.GetStock()} available";
                        }
                        if (product.GetProductType() == "Cheese")
                        {
                            lblUnit.Text = "(gr)";
                        }
                        else
                        {
                            lblUnit.Text = "(ml)";
                        }
                    }
                    else
                    {
                        headerTitle.Text = "Product currently not available";
                    }
                }
            }
            else
            {
                lblError.Text = "Error URL";
            }
        }
コード例 #7
0
        private void saveProduct()
        {
            //main data
            Product product = new Product();

            product.Name          = txtName.Text;
            product.Code          = bool.Parse(ConfigurationManager.AppSettings["fillZeroCode"]) ? txtCode.Text.PadLeft(13, '0') : txtCode.Text;
            product.SupplierCode  = txtSupplierCode.Text;
            product.Brand         = new Brand();
            product.Brand.BrandID = int.Parse(cmbBrand.SelectedValue);
            product.Description   = txtDescription.Text;
            product.Price         = double.Parse(txtPrice.Text);
            product.WebPrice      = double.Parse(txtWebPrice.Text);
            product.VatID         = int.Parse(cmbVat.SelectedValue);
            //product.InsertDate = product.UpdateDate = DateTime.Now;
            product.SupplierID    = int.Parse(cmbSupplier.SelectedValue);
            product.IsApproved    = chkApproved.Checked;
            product.IsActive      = chkActive.Checked;
            product.IsLocked      = chkLocked.Checked;
            product.IsInStock     = chkInStock.Checked;
            product.Ean           = bool.Parse(ConfigurationManager.AppSettings["fillZeroBarcode"]) ? txtEan.Text.PadLeft(13, '0') : txtEan.Text;
            product.Specification = txtSpecification.Text;
            product.ProductID     = (lblProductID.Value != string.Empty) ? int.Parse(lblProductID.Value) : 0;
            product.UnitOfMeasure = new UnitOfMeasure(int.Parse(cmbUnitOfMeasure.SelectedValue), cmbUnitOfMeasure.SelectedItem.Text, string.Empty);

            if (cmbPromotions.SelectedIndex > 0)
            {
                product.Promotion             = new Promotion();
                product.Promotion.PromotionID = int.Parse(cmbPromotions.SelectedValue);
                product.Promotion.Price       = double.Parse(txtPromotionPrice.Text);
            }

            //category and attributes
            if (cmbCategory.SelectedIndex > -1)
            {
                product.Categories = new List <Category>();
                product.Categories.Add(new Category(int.Parse(cmbCategory.SelectedValue), cmbCategory.SelectedItem.Text, 0, string.Empty, string.Empty, 0, 0, 0, string.Empty, true, 0, false, false));
                product.Attributes = new List <AttributeValue>();

                if (bool.Parse(ConfigurationManager.AppSettings["productInMultipleCategories"]))
                {
                    foreach (ListItem item in lstCategories.Items)
                    {
                        product.Categories.Add(new Category(int.Parse(item.Value), item.Text, 0, string.Empty, string.Empty, 0, 0, 0, string.Empty, true, -1, false, false));
                    }
                }

                //foreach (object obj in TabContainer1.Controls)
                //{
                //if (obj is AjaxControlToolkit.TabPanel)
                //{
                //AjaxControlToolkit.TabPanel tabPanel = obj as AjaxControlToolkit.TabPanel;

                //if (tabPanel.ID == "tbpCategories")
                //{

                foreach (object control in pnlAttributes.Controls)
                {
                    if (control is customControls.AttributeControl)
                    {
                        //Control c = tpControl as Control;
                        //foreach (object innerCtrl in c.Controls)
                        //{
                        //if (innerCtrl is DropDownList)
                        //if (((DropDownList)tpControl).ID != "cmbCategory")
                        product.Attributes.Add(new AttributeValue(((customControls.AttributeControl)control).AttributeValueID, ((customControls.AttributeControl)control).AttributeValue, -1, 0, string.Empty, 0));
                        //}
                    }
                }
                //}
                //}
                //}
            }

            //images
            if (rptImages.Items.Count > 0)
            {
                product.Images = new List <ProductImage>();
                //List<ProductImage> images = (List<ProductImage>)ViewState["images"];
                foreach (RepeaterItem productImage in rptImages.Items)
                {
                    product.Images.Add(new ProductImage(((Label)productImage.FindControl("lblImageUrl")).Text, int.Parse(((TextBox)productImage.FindControl("txtSortOrder")).Text)));
                }
            }



            ProductBL productBL = new ProductBL();
            string    productID = productBL.SaveProduct(product).ToString();

            //if (lblProductID.Value == "0")
            lblProductID.Value = productID;
        }
コード例 #8
0
 public ProductMenu(ProductBL productBL, ValidationService validationService)
 {
     _productBL         = productBL;
     _validationService = validationService;
 }
コード例 #9
0
 public ProductController()
 {
     productBussiness = new ProductBL();
 }
コード例 #10
0
 public ProductsController(ProductBL productBL)
 {
     _ProductBL = productBL;
 }
コード例 #11
0
 public ProfileMenu(OrderBL orderBL, ProductBL productBL, LocationBL locationBL)
 {
     _orderBL    = orderBL;
     _productBL  = productBL;
     _locationBL = locationBL;
 }
コード例 #12
0
 public ProductController()
 {
     productBl = new ProductBL();
 }
コード例 #13
0
ファイル: Form1.cs プロジェクト: NetoVillalobos/ShoesApp
        private void GetProductByName(string pName)
        {
            List <JEVJ1_BuscaProductoPorNombre_Result> lst = ProductBL.GetProductsByName(pName);

            dgvProducts.DataSource = lst.ToList();
        }
コード例 #14
0
ファイル: Form1.cs プロジェクト: NetoVillalobos/ShoesApp
        private void GetProductById(int pId)
        {
            List <JEVJ1_BuscaProductoPorID_Result> lst = ProductBL.GetProductsById(pId);

            dgvProducts.DataSource = lst.ToList();
        }
コード例 #15
0
 // PUT: api/Product/5
 public void Put(int id, [FromBody] ProductDTO product)
 {
     ProductBL.Update(id, product, base._DB);
 }
コード例 #16
0
        public static async Task <int> CustomerProductMenu()
        {
            int choice = -2;

            using (IProductBL productBL = new ProductBL())
            {
                do
                {
                    List <Product> products = await productBL.GetAllProductsBL();

                    WriteLine("\n***************Products***********\n");
                    WriteLine("Product:");
                    if (products != null && products?.Count > 0)
                    {
                        WriteLine("#\tProductName\tPrice\tDescription\t");
                        int serialNo = 0;
                        foreach (var product in products)
                        {
                            serialNo++;
                            WriteLine($"{serialNo}\t{product.ProductName}\t\t{product.ProductPrice}\t" +
                                      $"{product.ProductColor}{product.ProductSize},{product.ProductMaterial},{product.Category}");
                        }
                    }
                    WriteLine("\n1.Add Product to cart");
                    WriteLine("2.Remove Product from Cart");
                    WriteLine("3.Confirm Order");
                    WriteLine("4.Get Product Details");
                    WriteLine("0.Back");
                    WriteLine("-1.Exit");
                    Write("Choice: ");
                    bool isValidChoice = int.TryParse(ReadLine(), out choice);
                    if (isValidChoice)
                    {
                        switch (choice)
                        {
                        case 1:
                            await AddtoCart();

                            break;

                        case 2:
                            await RemoveFromCart();

                            break;

                        case 3:
                            await ConfirmOrder();

                            break;

                        case 4:
                            await GetProduct();

                            break;

                        case 0:
                            break;

                        case -1:
                            break;

                        default:
                            WriteLine("Invalid Choice");
                            break;
                        }
                    }
                    else
                    {
                        choice = -2;
                    }
                } while (choice != 0 || choice != -1);
            }
            return(choice);
        }
コード例 #17
0
 // DELETE: api/Product/5
 public void Delete(int id)
 {
     ProductBL.Delete(id, base._DB);
 }
コード例 #18
0
        public static async Task ConfirmOrder()
        {
            try
            {
                IProductBL         productBL = new ProductBL();
                Guid               tempOrderID;
                ICartProductBL     cartProductBL = new CartProductBL();
                List <CartProduct> cart          = await cartProductBL.GetAllCartProductsBL();

                using (IOrderDetailBL orderDetailBL = new OrderDetailBL())
                {
                    CustomerBL customerBL = new CustomerBL();
                    Customer   customer   = await customerBL.GetCustomerByEmailBL(UserData.CurrentUser.Email);

                    AddressBL      addressBL = new AddressBL();
                    List <Address> addresses = await addressBL.GetAddressByCustomerIDBL(customer.CustomerID);

                    double totalamount = 0;
                    int    quantity    = 0;
                    Guid   orderID     = Guid.NewGuid();
                    tempOrderID = orderID;

                    foreach (var cartProduct in cart)
                    {
                        OrderDetail orderDetail = new OrderDetail();
                        WriteLine("#\tAddressLine 1\tLandMark\tCity");
                        int serial = 0;
                        foreach (var address in addresses)
                        {
                            serial++;
                            WriteLine($"{serial}\t{address.AddressLine1}\t{address.Landmark}\t{address.City}");
                        }

                        Write("Address #: ");
                        bool isNumberValid = int.TryParse(ReadLine(), out int serial1);
                        if (isNumberValid)
                        {
                            serial1--;

                            if (serial1 <= addresses.Count - 1)
                            {
                                //Read inputs
                                Address address = addresses[serial1];
                                orderDetail.AddressId = address.AddressID;
                            }
                        }
                        orderDetail.OrderId                = orderID;
                        orderDetail.ProductID              = cartProduct.ProductID;
                        orderDetail.ProductPrice           = cartProduct.ProductPrice;
                        orderDetail.ProductQuantityOrdered = cartProduct.ProductQuantityOrdered;
                        orderDetail.TotalAmount            = (cartProduct.ProductPrice * cartProduct.ProductQuantityOrdered);
                        totalamount += orderDetail.TotalAmount;
                        quantity    += orderDetail.ProductQuantityOrdered;
                        bool isAdded;
                        Guid newguid;
                        (isAdded, newguid) = await orderDetailBL.AddOrderDetailsBL(orderDetail);
                    }

                    using (IOrderBL orderBL = new OrderBL())
                    {
                        Order order = new Order
                        {
                            OrderId       = orderID,
                            CustomerID    = customer.CustomerID,
                            TotalQuantity = quantity,
                            OrderAmount   = totalamount
                        };
                        bool isAdded;
                        Guid newguid;
                        (isAdded, newguid) = await orderBL.AddOrderBL(order);

                        if (isAdded)
                        {
                            WriteLine("Order  Added");
                        }
                    }
                }

                IOrderBL orderBL1 = new OrderBL();
                Order    order1   = await orderBL1.GetOrderByOrderIDBL(tempOrderID);

                WriteLine($"Your Order No. {order1.OrderNumber}\t{order1.TotalQuantity}\t{order1.OrderAmount}\t{order1.DateOfOrder}");
                WriteLine("Order Details");
                IOrderDetailBL     orderDetailBL1   = new OrderDetailBL();
                List <OrderDetail> orderDetailslist = await orderDetailBL1.GetOrderDetailsByOrderIDBL(tempOrderID);

                foreach (var item in orderDetailslist)
                {
                    Product product = await productBL.GetProductByProductIDBL(item.ProductID);

                    WriteLine($"{product.ProductName}\t{item.ProductPrice}\t{item.ProductQuantityOrdered}\t{item.TotalAmount}");
                }
                cart.Clear();
            }
            catch (Exception ex)
            {
                ExceptionLogger.LogException(ex);
                WriteLine(ex.Message);
            }
        }
コード例 #19
0
        private void loadProduct(int productID)
        {
            ProductBL productBL = new ProductBL();
            Product   product   = productBL.GetProduct(productID, string.Empty, false, string.Empty);

            lblProductID.Value        = product.ProductID.ToString();
            txtCode.Text              = product.Code;
            txtSupplierCode.Text      = product.SupplierCode;
            txtName.Text              = product.Name;
            cmbBrand.SelectedValue    = cmbBrand.Items.FindByValue(product.Brand.BrandID.ToString()).Value;
            txtDescription.Text       = product.Description;
            txtPrice.Text             = string.Format("{0:N2}", product.Price);
            txtWebPrice.Text          = string.Format("{0:N2}", product.WebPrice);
            txtInsertDate.Text        = product.InsertDate.ToString();
            txtUpdateDate.Text        = product.UpdateDate.ToString();
            cmbVat.SelectedValue      = cmbVat.Items.FindByValue(product.VatID.ToString()).Value;
            cmbSupplier.SelectedValue = cmbSupplier.Items.FindByValue(product.SupplierID.ToString()).Value;
            chkApproved.Checked       = product.IsApproved;
            chkActive.Checked         = product.IsActive;
            chkLocked.Checked         = product.IsLocked;
            chkInStock.Checked        = product.IsInStock;
            txtEan.Text           = product.Ean;
            txtSpecification.Text = product.Specification;
            Page.Title            = product.Name + " | Admin panel";
            ViewState.Add("pageTitle", Page.Title);
            txtSupplierPrice.Text          = string.Format("{0:N2}", product.SupplierPrice);
            cmbUnitOfMeasure.SelectedValue = product.UnitOfMeasure.UnitOfMeasureID.ToString();

            if (product.Promotion != null)
            {
                cmbPromotions.SelectedValue = cmbPromotions.Items.FindByValue(product.Promotion.PromotionID.ToString()).Value;
                txtPromotionPrice.Text      = product.Promotion.Price.ToString();
            }

            if (product.Categories != null)
            {
                cmbCategory.SelectedValue = cmbCategory.Items.FindByValue(product.Categories[0].CategoryID.ToString()).Value;
                createControls();
                int i = 0;
                if (product.Attributes != null)
                {
                    int attributeID = -1;
                    foreach (object control in pnlAttributes.Controls)
                    {
                        if (control is Literal)
                        {
                            int.TryParse(((Literal)control).Text, out attributeID);
                        }
                        if (control is customControls.AttributeControl)
                        {
                            int index;
                            if ((index = hasAttribute(product.Attributes, attributeID)) > -1)
                            {
                                ((customControls.AttributeControl)control).AttributeValueID = product.Attributes[index].AttributeValueID;
                            }
                            else
                            {
                                ((customControls.AttributeControl)control).AttributeValue = "NP";
                            }
                        }
                    }
                }
                btnAddProductToCategory.Enabled = true;

                if (product.Categories.Count > 1)
                {
                    for (int j = 1; j < product.Categories.Count; j++)
                    {
                        lstCategories.Items.Add(new ListItem(product.Categories[j].Name, product.Categories[j].CategoryID.ToString()));
                    }
                }
            }

            if (product.Images != null)
            {
                ViewState.Add("images", product.Images);
                loadImages();

                string imageUrl  = product.Images[0].ImageUrl.Substring(0, product.Images[0].ImageUrl.LastIndexOf("."));
                string extension = product.Images[0].ImageUrl.Substring(product.Images[0].ImageUrl.LastIndexOf('.'));
                string directory = new ProductBL().CreateImageDirectory(int.Parse(imageUrl));
                imgProduct.ImageUrl = directory + imageUrl + "-" + ConfigurationManager.AppSettings["mainName"] + extension;
                imgHome.ImageUrl    = directory + imageUrl + "-" + ConfigurationManager.AppSettings["listName"] + extension;
                imgLarge.ImageUrl   = directory + imageUrl + "-" + ConfigurationManager.AppSettings["thumbName"] + extension;
                imgThumb.ImageUrl   = directory + imageUrl + "-" + ConfigurationManager.AppSettings["thumbName"] + extension;
            }

            /*rptImages.DataSource = product.Images;
             * rptImages.DataBind();*/
        }
コード例 #20
0
        public static async Task GetProduct()
        {
            try
            {
                using (IProductBL productBL = new ProductBL())
                {
                    int choice;
                    WriteLine("\n1.Get all products");
                    WriteLine("2.Get product by product name");
                    WriteLine("3.Get product by product category");
                    Write("Enter your choice : ");
                    choice = int.Parse(ReadLine());
                    switch (choice)
                    {
                    case 1:
                        List <Product> allProductList = new List <Product>();
                        allProductList = await productBL.GetAllProductsBL();

                        break;

                    case 2:
                        Write("Product name: ");
                        string         productName     = ReadLine();
                        List <Product> productNameList = new List <Product>();
                        productNameList = await productBL.GetProductsByProductNameBL(productName);

                        break;

                    case 3:
                        WriteLine("Choose among the following categories:");
                        WriteLine("1.Clothing");
                        WriteLine("2.Footwear");
                        WriteLine("3.Bags");
                        WriteLine("4.Books");
                        WriteLine("5.Furniture");
                        bool     isCategory = int.TryParse(ReadLine(), out int choice1);
                        Category givenCategory;
                        if (isCategory)
                        {
                            if (choice1 == 1)
                            {
                                givenCategory = Category.Clothing;
                            }
                            else if (choice1 == 2)
                            {
                                givenCategory = Category.Footwear;
                            }
                            else if (choice1 == 3)
                            {
                                givenCategory = Category.Bags;
                            }
                            else if (choice1 == 4)
                            {
                                givenCategory = Category.Books;
                            }
                            else if (choice1 == 5)
                            {
                                givenCategory = Category.Furniture;
                            }
                            else
                            {
                                givenCategory = Category.Clothing;
                            }
                        }
                        else
                        {
                            givenCategory = Category.Clothing;
                        }
                        List <Product> categoryProductList = new List <Product>();
                        categoryProductList = await productBL.GetProductsByProductCategoryBL(givenCategory);

                        break;

                    default:
                        WriteLine("Invalid Choice"); break;
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionLogger.LogException(ex);
                WriteLine(ex.Message);
            }
        }
コード例 #21
0
 public ProductController()
 {
     ProductBL = new ProductBL(new ProductConcrete());
 }
コード例 #22
0
        public static string SaveProductFromExternalApplication(string barcode, string name, string quantity, string price, bool insertIfNew)
        {
            bool status = new ProductBL().SaveProductFromExternalApplication(barcode, name, double.Parse(quantity), double.Parse(price), insertIfNew);

            return(status ? "Saved" : "Error");
        }
コード例 #23
0
        static void Main(string[] args)
        {
            RawMaterial rawMaterial1 = new RawMaterial()
            {
                RawMaterialID = "RM101", RawMaterialName = "Mango", RawMaterialCode = "MGO"
            };
            RawMaterialBL rawMaterialBL = new RawMaterialBL();

            rawMaterialBL.AddRawMaterialBL(rawMaterial1);
            Product product1 = new Product()
            {
                ProductID = "P101", ProductName = "MJUICE", ProductCode = "JC", ProductMFD = "12-09-2019", ProductEXP = "12-09-2020", ProductType = "Juice"
            };
            ProductBL productBL = new ProductBL();

            productBL.AddProductBL(product1);

            int choice;

            do
            {
                PrintMenu();
                Console.WriteLine("Enter your Choice:");
                choice = Convert.ToInt32(Console.ReadLine());
                switch (choice)
                {
                case 1:
                    AddRawMaterial();
                    break;

                case 2:
                    ListAllRawMaterial();
                    break;

                case 3:
                    SearchRawMaterialByID();
                    break;

                case 4:
                    SearchRawMaterialByName();
                    break;

                case 5:
                    SearchRawMaterialByCode();
                    break;

                case 6:
                    UpdateRawMaterial();
                    break;

                case 7:
                    DeleteRawMaterial();
                    break;

                case 8:
                    AddProduct();
                    break;

                case 9:
                    ListAllProduct();
                    break;

                case 10:
                    SearchProductByID();
                    break;

                case 11:
                    SearchProductByType();
                    break;

                case 12:
                    SearchProductByCode();
                    break;

                case 13:
                    UpdateProduct();
                    break;

                case 14:
                    DeleteProduct();
                    break;

                case 15:
                    SerializeRawMaterial();
                    break;

                case 16:
                    DeserializeRawMaterial();
                    break;

                case 17:
                    SerializeProduct();
                    break;

                case 18:
                    DeserializeProduct();
                    break;

                case 19:
                    return;

                default:
                    Console.WriteLine("Invalid Choice");
                    break;
                }
            } while (choice != -1);
        }
コード例 #24
0
 // GET: api/Product
 public IEnumerable <ProductDTO> Get()
 {
     return(ProductBL.GetList(base._DB));
 }
コード例 #25
0
        private void btnAddItem_Click(object sender, EventArgs e)
        {
            if (uvAddItem.Validate(true, false).IsValid)
            {
                OperationResult objOperationResult = new OperationResult();

                ProductBL          objProductBL   = new ProductBL();
                List <ProductList> objProductList = new List <ProductList>();

                var x = (KeyValueDTO)ddlProductId.SelectedItem;

                if (x.Value4 < Single.Parse(txtQuantity.Text.ToString()))
                {
                    MessageBox.Show("La cantidad es mayor al stock actual, por favor ingrese una cantidad igual o menor al stock actual", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (_TempMovementDetailList == null)
                {
                    _TempMovementDetailList = new List <MovementDetailList>();
                }
                grdData.DataSource     = new MovementDetailList();
                _objMovementDetailList = new MovementDetailList();
                objProductList         = objProductBL.GetProductsPagedAndFiltered(ref objOperationResult, 0, null, "", "v_ProductId==" + "\"" + ddlProductId.SelectedValue.ToString() + "\"");

                //Buscar si un producto ya esta en la Grilla
                var findResult = _TempMovementDetailList.Find(p => p.v_ProductId == ddlProductId.SelectedValue.ToString());
                if (findResult == null)
                {
                    _objMovementDetailList.v_ProductId    = objProductList[0].v_ProductId;
                    _objMovementDetailList.v_ProductName  = objProductList[0].v_Name;
                    _objMovementDetailList.v_CategoryName = objProductList[0].v_CategoryName;
                    _objMovementDetailList.v_Brand        = objProductList[0].v_Brand;
                    _objMovementDetailList.v_Model        = objProductList[0].v_Model;
                    _objMovementDetailList.v_SerialNumber = objProductList[0].v_SerialNumber;
                    _objMovementDetailList.r_Quantity     = float.Parse(txtQuantity.Text.Trim().ToString());
                    _TempMovementDetailList.Add(_objMovementDetailList);
                    grdData.DataSource = _TempMovementDetailList;
                }
                else
                {
                    var findIndex = _TempMovementDetailList.FindIndex(p => p.v_ProductId == ddlProductId.SelectedValue.ToString());

                    _objMovementDetailList.v_ProductId    = objProductList[0].v_ProductId;
                    _objMovementDetailList.v_ProductName  = objProductList[0].v_Name;
                    _objMovementDetailList.v_CategoryName = objProductList[0].v_CategoryName;
                    _objMovementDetailList.v_Brand        = objProductList[0].v_Brand;
                    _objMovementDetailList.v_Model        = objProductList[0].v_Model;
                    _objMovementDetailList.v_SerialNumber = objProductList[0].v_SerialNumber;
                    _objMovementDetailList.r_Quantity     = float.Parse(txtQuantity.Text.Trim().ToString()) + findResult.r_Quantity;

                    bool Result;
                    if (x.Value4 < _objMovementDetailList.r_Quantity)
                    {
                        _objMovementDetailList.r_Quantity = _objMovementDetailList.r_Quantity - float.Parse(txtQuantity.Text.Trim().ToString());
                        Result = true;
                    }
                    else
                    {
                        Result = false;
                    }

                    _TempMovementDetailList.Add(_objMovementDetailList);
                    _TempMovementDetailList.RemoveAt(findIndex);
                    grdData.DataSource = _TempMovementDetailList;

                    if (Result)
                    {
                        MessageBox.Show("La cantidad es mayor al stock actual, por favor ingrese una cantidad igual o menor al stock actual", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                grdData.Refresh();
                lblRecordCount.Text        = string.Format("Se encontraron {0} registros.", _TempMovementDetailList.Count());
                txtQuantity.Text           = "";
                txtProductSearch.Text      = "";
                ddlProductId.SelectedValue = "-1";
            }
            else
            {
                MessageBox.Show("Por favor corrija la información ingresada. Vea los indicadores de error.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #26
0
 // GET: api/Product/5
 public ProductDTO Get(int id)
 {
     return(ProductBL.Get(id, base._DB));
 }
コード例 #27
0
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     ProductBL productViewerBL = new ProductBL();
 }
コード例 #28
0
 // POST: api/Product
 public int Post([FromBody] ProductDTO product)
 {
     return(ProductBL.Create(product, base._DB));
 }
コード例 #29
0
ファイル: BLogic.cs プロジェクト: delestz/WebApplication6
 public void AddProduct(ProductBL productBL)
 {
     db.Products.Create(Mapper.Map <Product>(productBL));
     db.Save();
 }
コード例 #30
0
ファイル: Form1.cs プロジェクト: NetoVillalobos/ShoesApp
        private void GetProducts()
        {
            List <Product> lst = ProductBL.GetProducts();

            dgvProducts.DataSource = lst.ToList();
        }