Esempio n. 1
0
        public Order RemoveOrder(int UserNumber, DateTime ListName)
        {
            try {
                Order orderError = new Order();
                orderError.Area = -1;
                Order linedateError = new Order();
                linedateError.Area = -2;
                Order Correct = new Order();
                Correct.Area = 1;
                int counter = 0;

                bool FileCheck = FilePathCheck.ValidateFile(ListName);
                if (FileCheck != true)
                {
                    return(linedateError);
                }
                string date = Namecreator(ListName);
                _filePath = $"{_FilePath}" + $"{date}";
                var OrderList = Orders();

                for (int i = 0; i < OrderList.Count; i++)
                {
                    if (OrderList[i].OrderNumber == UserNumber)
                    {
                        counter++;
                        OrderList.Remove(OrderList[i]);
                        CreateOrderFile(OrderList);
                    }
                }
                if (counter == 0)
                {
                    return(orderError);
                }
                return(Correct);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(null);
            }
        }
Esempio n. 2
0
        public Order EditOrder(Order order, DateTime ListName, int OrderNumber)
        {
            try
            {
                Order orderError = new Order();
                orderError.Area = -1;
                Order linedateError = new Order();
                linedateError.Area = -2;
                Order Correct = new Order();
                Correct.Area = 1;

                int counter = 0;

                bool FileCheck = FilePathCheck.ValidateFile(ListName);
                if (FileCheck != true)
                {
                    return(linedateError);
                }

                string date = Namecreator(ListName);
                _filePath = $"{_FilePath}" + $"{date}";
                var OrderList = Orders();



                for (int i = 0; i < OrderList.Count; i++)
                {
                    if (OrderList[i].OrderNumber == OrderNumber)
                    {
                        counter++;
                        if (order.Area == 0)
                        {
                        }
                        else
                        {
                            OrderList[i].Area = order.Area;
                        }


                        if (order.CustomerName == "")
                        {
                        }
                        else
                        {
                            OrderList[i].CustomerName = order.CustomerName;
                        }

                        if (order.State == "")
                        {
                        }
                        else
                        {
                            OrderList[i].State   = order.State;
                            OrderList[i].TaxRate = order.TaxRate;
                        }

                        if (order.ProductType == "")
                        {
                        }
                        else
                        {
                            OrderList[i].ProductType            = order.ProductType;
                            OrderList[i].CostPerSquareFoot      = order.CostPerSquareFoot;
                            OrderList[i].LaborCostPerSquareFoot = order.LaborCostPerSquareFoot;
                        }

                        OrderList[i].MaterialCost = OrderList[i].Area * OrderList[i].CostPerSquareFoot;
                        OrderList[i].LaborCost    = OrderList[i].Area * OrderList[i].LaborCostPerSquareFoot;
                        OrderList[i].Tax          = (OrderList[i].MaterialCost + OrderList[i].LaborCost) * (OrderList[i].TaxRate / 100);
                        OrderList[i].Total        = (OrderList[i].MaterialCost + OrderList[i].LaborCost + OrderList[i].Tax);

                        CreateOrderFile(OrderList);
                    }
                }
                if (counter == 0)
                {
                    return(orderError);
                }
                return(Correct);
            }catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(null);
            }
        }