コード例 #1
0
ファイル: HSOrder.cs プロジェクト: cyrenian37/JohnStoneInit
        public HSOrder(int CutomerId)
        {
            lDataContext = new CommonFunction().JSDataContext();

            _orderItems = new ObservableCollection <HSOrderItem>();
            _invoice    = new HSInvoice();
        }
コード例 #2
0
        public HSSupply()
        {
            lDataContext = new CommonFunction().JSDataContext();

            _supplyItems = new ObservableCollection <HSSupplyItem>();
            _invoice     = new HSInvoice();

            this.saveCommand    = new DelegateCommand(OnSaveCommandExecuted);
            this.AddNewCommand  = new DelegateCommand(OnAddNewCommandExecuted);
            this.deleteCommand  = new DelegateCommand(OnDeleteCommandExecuted);
            this.printCommand   = new DelegateCommand(OnPrintCommandExecuted);
            this.previewCommand = new DelegateCommand(OnPreviewCommandExecuted);
            this.invoiceCommand = new DelegateCommand(OnInvoiceCommandExecuted);
            this.closeCommand   = new DelegateCommand(OnCloseCommandExecuted);

            _invoice.InvoiceStatusId = 1;

            ButtonEnabled = false;
            DeleteEnabled = false;
            IsBusy        = false;
            Foreground    = "Blue";
        }
コード例 #3
0
        //public static void AddPriceHistory(HSOrderItem lOrderItems)
        //{
        //    JSDataContext lDataContext = new CommonFunction().JSDataContext();

        //    DataSource.PriceHistory lPriceHist = new PriceHistory();


        //    var lOrderHist = lDataContext.PriceHistories.SingleOrDefault(p => p.OrderId == lOrderItems.OrderId
        //            && p.ProductId == lOrderItems.ProductId && p.SellingUnitId == lOrderItems.SellingUnitId);

        //    lPriceHist.OrderId = lOrderItems.OrderId;
        //    lPriceHist.CustomerId = lOrderItems.CustomerId;
        //    lPriceHist.VatRate = lOrderItems.SelectedVat.Rate;
        //    lPriceHist.ProductId = lOrderItems.ProductId;
        //    lPriceHist.SellingUnitId = lOrderItems.SellingUnitId;
        //    lPriceHist.UnitPrice = lOrderItems.UnitPrice;

        //    if (lOrderHist == null)
        //    {
        //        lDataContext.PriceHistories.InsertOnSubmit(lPriceHist);
        //    }

        //    lDataContext.SubmitChanges();


        //}


        public static HSOrder PrintOrder(int?orderId)
        {
            if (orderId == null)
            {
                MessageBox.Show("Not Found Selected Order");
                return(null);
            }

            JSDataContext lDataContext = new CommonFunction().JSDataContext();

            HSOrder   lEditOrder = new HSOrder();
            HSInvoice lInvoice   = new HSInvoice();

            DataSource.Order lOrder = lDataContext.Orders.SingleOrDefault(p => p.Id == orderId);

            DataSource.vEmpDept lEmpDelivery = new DataSource.vEmpDept();


            //lEmpDelivery.Person = lOrder.Employee1.Person.LastName + "," + lOrder.Employee1.Person.FirstName;

            if (lOrder.Invoice.Employee != null)
            {
                lEmpDelivery.Person = lOrder.Invoice.Employee.Person.LastName + "," + lOrder.Invoice.Employee.Person.FirstName;
            }

            if (lOrder != null)
            {
                lEditOrder.Id                = lOrder.Id;
                lEditOrder.CustomerId        = lOrder.CustomerId;
                lEditOrder.SelectedCustomer  = lOrder.Customer;
                lEditOrder.SelectedDeliverer = lEmpDelivery;
                lEditOrder.OrderDate         = lOrder.OrderDate;
                lEditOrder.SellerId          = lOrder.EmployeeId;


                if (lOrder.Invoice != null)
                {
                    lInvoice.Id            = lOrder.Invoice.Id;
                    lInvoice.InvoiceNo     = lOrder.Invoice.InvoiceNo;
                    lInvoice.InvoiceDate   = lOrder.Invoice.InvoiceDate;
                    lInvoice.DeliveryDate  = lOrder.Invoice.DeliveryDate;
                    lEditOrder.DelivererId = lOrder.Invoice.EmpDeliveryId;
                    lInvoice.Description   = lOrder.Invoice.Description;
                    lEditOrder.Invoice     = lInvoice;
                }


                foreach (DataSource.OrderItem l in lOrder.OrderItems)
                {
                    lEditOrder.OrderItems.Add(new HSOrderItem
                    {
                        Id                  = l.Id,
                        CustomerId          = lOrder.CustomerId,
                        OrderId             = l.OrderId,
                        SalesStatusId       = l.SalesStatusId,
                        ProductId           = l.ProductId,
                        SelectedProduct     = l.Product,
                        UnitPrice           = l.UnitPrice,
                        VatId               = l.VatId,
                        VAT                 = l.VatRate.Name,
                        SelectedVat         = l.VatRate,
                        Quantity            = l.Quantity,
                        SellingUnitId       = l.SellingUnitId,
                        Unit                = l.SellingUnit.Unit,
                        SelectedSellingUnit = l.SellingUnit,
                        ProductName         = l.Product.Name,
                        ProductDescription  = l.Product.Description,
                        Description         = l.Description
                    });
                }
            }

            return(lEditOrder);
        }