public Card()
 {
     merchendise = (MerchendiseWindowViewModel)Application.Current.Resources["MerchendiseWindowViewModel"];
     CardViewModel cardViewModel = new CardViewModel();
     this.DataContext = cardViewModel;
     InitializeComponent();
 }
 public Card AddItem1(MerchendiseWindowViewModel merch)
 {
     if (addItem == null)
     {
         addItem = new Card(merch);
     }
     return(addItem);
 }
 public Card(MerchendiseWindowViewModel merchendiseWindow)
 {
     merchendise = merchendiseWindow;
     merchendiseWindow.AddItem = this;
     CardViewModel cardViewModel = new CardViewModel(merchendiseWindow);
     this.DataContext = cardViewModel;
     InitializeComponent();
 }
 public Card AddItem1(MerchendiseWindowViewModel merch)
 {
     if (addItem == null)
     {
         addItem = new Card(merch);
     }
     return addItem;
 }
Beispiel #5
0
        private void addItem()
        {
            if (
                Inspection.CheckNumeric(OrderWindowViewModel.AddItem.txtIdContractor.Text, 18, 0) &&
                Inspection.CheckNumeric(OrderWindowViewModel.AddItem.txtSumm.Text, 18, 2) &&
                Inspection.CheckDateTime(OrderWindowViewModel.AddItem.txtDateOrder.Text) &&
                Inspection.CheckDateTime(OrderWindowViewModel.AddItem.txtDateImport.Text)
                )
            {
                Order n = new Order()
                {
                    id_contractor = decimal.Parse(OrderWindowViewModel.AddItem.txtIdContractor.Text),
                    summ          = decimal.Parse(OrderWindowViewModel.AddItem.txtSumm.Text),
                    date_order    = DateTime.Parse(OrderWindowViewModel.AddItem.txtDateOrder.Text),
                    date_import   = DateTime.Parse(OrderWindowViewModel.AddItem.txtDateImport.Text),
                    id_user       = AdministratorWindowViewModel.Current_User.id
                };
                Order m;
                using (var context = new WarehouseEntities()) {
                    context.Order.Add(n);
                    context.SaveChanges();
                    m = context.Order.ToList().Last();
                    var orderTable = (OrderWindowViewModel)Application.Current.Resources["OrderWindowViewModel"];
                    orderTable.Orders = context.Order.ToList();
                }
                MessageBox.Show("Запись создана успешно.");

                MerchendiseWindowViewModel f = (MerchendiseWindowViewModel)Application.Current.Resources["MerchendiseWindowViewModel"];
                var carMerch = f.AddItem1(f);
                carMerch.txtConsignment.Text      = m.consigment.ToString();
                carMerch.txtConsignment.IsEnabled = false;

                Card addmerch = carMerch;
                addmerch.Show();
            }
            else
            {
                MessageBox.Show("Некорректные данные!");
            }
        }
Beispiel #6
0
 public CardViewModel(MerchendiseWindowViewModel merch)
 {
     _merchendiseWindow = merch;
 }
 public CardViewModel(MerchendiseWindowViewModel merch)
 {
     _merchendiseWindow = merch;
 }