public void LoadSale() { ObservableCollection <SaleAux> sales = new ObservableCollection <SaleAux>(); using (MFSContext context = new MFSContext()) { var data = from o in context.Sales select new { Id = o.SaleId, UserId = o.User.UserId, UserName = o.User.Name, CustomerId = o.Customer.CustomerId, CustomerName = o.Customer.Name + " " + o.Customer.LastName, Date = o.Date, CodSale = o.CodSale }; foreach (var or in data) { SaleAux order = new SaleAux(); order.SaleID = or.Id; order.UserId = or.UserId; order.UserName = or.UserName; order.CustomerId = or.CustomerId; order.CustomerName = or.CustomerName; order.Date = or.Date; order.CodSale = or.CodSale; sales.Add(order); } } Sales = sales; }
private void OnAddCategory() { SelectedSale = new SaleAux() { Date = DateTime.Now.Date }; OnPropertyChanged("SelectedSale"); }
public SaleViewModel() { SelectedSale = new SaleAux() { SaleID = 0, Date = DateTime.Now.Date }; AddSaleCommand = new MyICommand(OnAddCategory, CanAddCategory); UpdateSaleCommand = new MyICommand(OnUpdateSale, CanUpdateSale); LoadSale(); }
private void DataGridSales_MouseDoubleClick(object sender, MouseButtonEventArgs e) { SaleAux sale = DataGridSales.SelectedItem as SaleAux; if (sale != null) { SaleDetailView saleDetailView = new SaleDetailView(); saleDetailView.SaleId.Text = Convert.ToString(sale.SaleID); saleDetailView.ShowDialog(); } }