示例#1
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);
        }
        private void OnPrintCommandExecuted(object Param)
        {
            HSOrderHistory lOrderHistory = Param as HSOrderHistory;

            HSOrder lEditOrder = CommonFunction.PrintOrder(lOrderHistory.OrderId);

            if (lEditOrder == null)
            {
                return;
            }

            //HSInvoice lInvoice = new HSInvoice();

            //DataSource.Order lOrder = lDataContext.Orders.SingleOrDefault(p => p.Id == lOrderHistory.OrderId);

            //if (lOrder != null)
            //{

            //    lEditOrder.Id = lOrder.Id;
            //    lEditOrder.CustomerId = lOrder.CustomerId;
            //    lEditOrder.SelectedCustomer = lOrder.Customer;
            //    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,
            //            SelectedVat = l.VatRate,
            //            Quantity = l.Quantity,
            //            SellingUnitId = l.SellingUnitId,
            //            SelectedSellingUnit = l.SellingUnit
            //        });
            //    }

            //}


            SunSeven.Reports.ReportViewer lRptViewer = new Reports.ReportViewer(lEditOrder, lEditOrder.OrderItems);

            Window lWindows = Models.CommonFunction.GetApplicationWindow();

            if (lWindows != null)
            {
                lRptViewer.Owner = lWindows;
            }

            lRptViewer.ShowDialog();
        }