public QuotationEditor(int SalesId)
        {
            InitializeComponent();

            lDataContext = new CommonFunction().JSDataContext();

            MainPage.CloseCommand -= MainPage_CloseCommand;
            MainPage.CloseCommand += MainPage_CloseCommand;


            HSQuotation lEditSales = new HSQuotation();

            DataSource.Sale lSales = lDataContext.Sales.SingleOrDefault(p => p.Id == SalesId);

            if (lSales != null)
            {
                lEditSales.Id               = lSales.Id;
                lEditSales.CustomerId       = lSales.CustomerId.Value;
                lEditSales.SelectedCustomer = lSales.Customer;
                lEditSales.SalesDate        = lSales.SalesDate;
                lEditSales.SellerId         = lSales.SellerId;
                lEditSales.Description      = lSales.Description;
                //lEditSales.Order = lEditSales.Order;
                //lEditSales.Order = lSales.Order;
                lEditSales.IsMaster   = lSales.Master;
                lEditSales.ExpireDate = lSales.ExpireDate;
                //lEditSales.SalesPerson = new HSEmployee { Id = lSales.Id, SelectedPerson = lSales.Employee.Person };

                lEditSales.DeleteEnabled = true;


                foreach (DataSource.SalesItem l in lSales.SalesItems)
                {
                    lEditSales.SalesItems.Add(new HSOrderItem
                    {
                        Id                  = l.Id,
                        CustomerId          = lSales.CustomerId.Value,
                        OrderId             = l.SalesId.Value,
                        ProductId           = l.ProductId.Value,
                        SelectedProduct     = l.Product,
                        UnitPrice           = l.UnitPrice,
                        VatId               = l.VatId,
                        SelectedVat         = l.VatRate,
                        Quantity            = l.Quantity,
                        SellingUnitId       = l.SellingUnitId,
                        SelectedSellingUnit = l.SellingUnit,
                        ProductName         = l.Product.Name,
                        ProductDescription  = l.Product.Description,
                        VAT                 = l.VatRate.Name,
                        Unit                = (l.SellingUnit == null) ? "NA" : l.SellingUnit.Unit,
                        Description         = l.Description
                    });
                }

                this.DataContext = lEditSales;
            }
        }
Ejemplo n.º 2
0
        public static HSQuotation PrintSales(int salesId)
        {
            JSDataContext lDataContext = new CommonFunction().JSDataContext();

            HSQuotation lEditSales = new HSQuotation();

            DataSource.Sale lSales = lDataContext.Sales.SingleOrDefault(p => p.Id == salesId);

            if (lSales != null)
            {
                lEditSales.Id               = lSales.Id;
                lEditSales.CustomerId       = lSales.CustomerId.Value;
                lEditSales.SelectedCustomer = lSales.Customer;
                lEditSales.SalesDate        = lSales.SalesDate;
                lEditSales.SellerId         = lSales.SellerId;
                lEditSales.Description      = lSales.Description;
                lEditSales.Order            = lEditSales.Order;
                //lEditSales.Order = lSales;
                //lEditSales.SalesPerson = new HSEmployee { Id = lSales.Id, SelectedPerson = lSales.Employee.Person };

                lEditSales.DeleteEnabled = true;


                foreach (DataSource.SalesItem l in lSales.SalesItems)
                {
                    lEditSales.SalesItems.Add(new HSOrderItem
                    {
                        Id                  = l.Id,
                        CustomerId          = lSales.CustomerId.Value,
                        OrderId             = l.SalesId.Value,
                        ProductId           = l.ProductId.Value,
                        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(lEditSales);
        }