private void gridOrderItem_RowEditEnded(object sender, Telerik.Windows.Controls.GridViewRowEditEndedEventArgs e) { if (e.EditAction == GridViewEditAction.Cancel) { return; } HSSupply lOrder = comboSupplier.SelectedItem as HSSupply; }
public SupplyEditor(int?SupplyId) { InitializeComponent(); this.comboStatus.IsEnabled = false; if (MainPage.lCurrentUser.UserRole.Name == "Admin") { this.comboStatus.IsEnabled = true; } MainPage.CloseCommand -= MainPage_CloseCommand; MainPage.CloseCommand += MainPage_CloseCommand; JSDataContext lDataContext = new CommonFunction().JSDataContext(); HSSupply lEditOrder = new HSSupply(); //HSInvoice lInvoice = new HSInvoice(); DataSource.Supply lSupply = lDataContext.Supplies.SingleOrDefault(p => p.Id == SupplyId); if (lSupply != null) { lEditOrder.Id = lSupply.Id; lEditOrder.CustomerId = lSupply.SupplierId; lEditOrder.SelectedSupplier = lSupply.Supplier; lEditOrder.OrderDate = lSupply.SupplyDate; lEditOrder.SellerId = lSupply.EmployeeId; lEditOrder.Description = lSupply.Description; //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; // lInvoice.InvoiceStatusId = lOrder.Invoice.Status; //} lEditOrder.DeleteEnabled = true; foreach (DataSource.SupplyItem l in lSupply.SupplyItems) { lEditOrder.SupplyItems.Add(new HSSupplyItem { Id = l.Id, CustomerId = lSupply.SupplierId, OrderId = l.SupplyId, 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, ProductName = l.Product.Name, ProductDescription = l.Product.Description, VAT = l.VatRate.Name, Unit = l.SellingUnit.Unit, Description = l.Description }); } this.DataContext = lEditOrder; } }