public static void UpdateProduct(OrderItem orderItem, CellValue productCell, OrderCollections source)
        {
            var newProduct = source.Products.First(x => x.Name == productCell.TextValue);

            orderItem.Product   = newProduct;
            orderItem.ProductId = newProduct.Id;
        }
        public static void UpdateEmployeeIfNeeded(Order order, CellValue value, OrderCollections source)
        {
            var newEmployee = source.Employees.First(x => x.FullName == value.TextValue);

            if (order.EmployeeId != newEmployee.Id)
            {
                order.Employee   = newEmployee;
                order.EmployeeId = newEmployee.Id;
            }
        }
        public static void UpdateCustomerIfNeeded(Order order, CellValue value, OrderCollections source)
        {
            var newCustomer = source.Customers.First(x => x.Name == value.TextValue);

            if (order.StoreId != newCustomer.Id)
            {
                order.Customer   = newCustomer;
                order.CustomerId = newCustomer.Id;
            }
        }
        public static void UpdateCustomerStoreIfNeeded(Order order, CellValue value, OrderCollections source)
        {
            var newStore = source.CustomerStores.First(x => x.City == value.TextValue);

            if (order.StoreId != newStore.Id)
            {
                order.Store   = newStore;
                order.StoreId = newStore.Id;
            }
        }
Пример #5
0
        public static void UpdateDependentCells(Worksheet invoice, Order order, OrderCollections source)
        {
            var customer = GetCustomer(order, source);
            var store    = GetStore(order, source);

            if (customer != null)
            {
                invoice.Cells[FindLeftCell(CellsKind.ShippingCustomerName)].Value = customer.Name;
                invoice.Cells[FindLeftCell(CellsKind.CustomerStreetLine)].Value   = customer.HomeOffice.Line;
                invoice.Cells[FindLeftCell(CellsKind.CustomerCityLine)].Value     = customer.HomeOffice.CityLine;
            }
            if (store != null)
            {
                invoice.Cells[FindLeftCell(CellsKind.CustomerStoreStreetLine)].Value = store.Address.Line;
                invoice.Cells[FindLeftCell(CellsKind.CustomerStoreCityLine)].Value   = store.Address.CityLine;
            }
        }
Пример #6
0
        public InvoiceHelper(IWorkbook workbook, Tuple <OrderCollections, Order> dataSource, EditActions editActions)
        {
            this.source      = dataSource.Item1;
            this.order       = dataSource.Item2;
            this.editActions = editActions;

            SetActualOrderItems();
            LoadInvoice(workbook);

            CellsHelper.UpdateEditableCells(Invoice, order, source);
            CellsHelper.UpdateDependentCells(Invoice, order, source);

            if (AllowChangeOrder())
            {
                CellsHelper.GenerateEditors(CellsHelper.OrderCells, Invoice);
                CreateCollectionEditors();
            }
            AddOrderItemsToSheet();
        }
Пример #7
0
        public static void UpdateEditableCells(Worksheet invoice, Order order, OrderCollections source)
        {
            invoice.Cells[FindLeftCell(CellsKind.Date)].Value          = order.OrderDate.Millisecond != 0 ? order.OrderDate : DateTime.FromBinary(0);
            invoice.Cells[FindLeftCell(CellsKind.InvoiceNumber)].Value = order.InvoiceNumber;
            invoice.Cells[FindLeftCell(CellsKind.CustomerName)].Value  = GetCustomer(order, source) != null?GetCustomer(order, source).Name : string.Empty;

            invoice.Cells[FindLeftCell(CellsKind.CustomerStoreName)].Value = GetStore(order, source) != null?GetStore(order, source).City : string.Empty;

            invoice.Cells[FindLeftCell(CellsKind.EmployeeName)].Value = GetEmployee(order, source) != null?GetEmployee(order, source).FullName : string.Empty;

            invoice.Cells[FindLeftCell(CellsKind.CustomerHomeOfficeName)].Value = "Home Office";
            invoice.Cells[FindLeftCell(CellsKind.PONumber)].Value = order.PONumber;
            invoice.Cells[FindLeftCell(CellsKind.ShipDate)].Value = order.ShipDate;
            invoice.Cells[FindLeftCell(CellsKind.ShipVia)].Value  = order.ShipmentCourier.ToString();
            invoice.Cells[FindLeftCell(CellsKind.FOB)].Value      = string.Empty;
            invoice.Cells[FindLeftCell(CellsKind.Terms)].Value    = order.OrderTerms != null?int.Parse(new Regex(@"\d+").Match(order.OrderTerms).Value) : 5;

            invoice.Cells[FindLeftCell(CellsKind.Shipping)].Value = (double)order.ShippingAmount;
            invoice.Cells[FindLeftCell(CellsKind.Comments)].Value = order.Comments;
        }
Пример #8
0
 static Employee GetEmployee(Order order, OrderCollections source)
 {
     return(order.Employee ?? (order.EmployeeId == null ? null : source.Employees.FirstOrDefault(x => x.Id == order.EmployeeId)));
 }
Пример #9
0
 static CustomerStore GetStore(Order order, OrderCollections source)
 {
     return(order.Store ?? (order.StoreId == null ? null : source.CustomerStores.FirstOrDefault(x => x.Id == order.StoreId)));
 }
Пример #10
0
 static Customer GetCustomer(Order order, OrderCollections source)
 {
     return(order.Customer ?? (order.CustomerId == null ? null : source.Customers.FirstOrDefault(x => x.Id == order.CustomerId)));
 }