Example #1
0
        public MainViewModel()
        {
            LoadedWindowCommand = new RelayCommand <object>((p) => { return(true); }, (p) => {
                IsLoaded = true;
                LoginWindow loginWindow = new LoginWindow();
                loginWindow.ShowDialog();
            });

            //MessageBox.Show("Đã vào trong MainViewModel -> DataContext của mainwindow.xaml");
            UnitCommand = new RelayCommand <object>((p) => { return(true); }, (p) => {
                UnitWindow wd = new UnitWindow();
                wd.ShowDialog();
            });
            //
            SuplierCommand = new RelayCommand <object>((p) => { return(true); }, (p) => {
                SuplierWindow wd = new SuplierWindow();
                wd.ShowDialog();
            });
            //
            CustomerCommand = new RelayCommand <object>((p) => { return(true); }, (p) => {
                CustomerWindow wd = new CustomerWindow();
                wd.ShowDialog();
            });
            //
        }
        private void btnCancel_Click_1(object sender, RoutedEventArgs e)
        {
            CustomerWindow cu = new CustomerWindow();

            this.Close();
            cu.ShowDialog();
        }
Example #3
0
 public void EditCustomer(CustomerVm customer)
 {
     // Hier greifen wir direkt auf eine "View" zu,
     // was wir eigentlich in einem ViewModel nicht wollen
     // -> vgl. Stoff Block 6 nächste Woche
     CustomerWindow.Display(customer);
 }
Example #4
0
        // mọi thứ xử lý sẽ nằm trong này
        public MainViewModel()
        {
            //mở các window
            loadedWindowCommand = new RelayCommand <Window>((p) => { return(true); }, (p) =>
            {
                isLoginLoaded = true;
                if (p == null)
                {
                    return;
                }
                p.Hide();
                LoginWindow loginWindow = new LoginWindow();
                loginWindow.ShowDialog();

                if (loginWindow.DataContext == null)
                {
                    return;
                }
                //lấy quyền truy cập
                var loginVM = loginWindow.DataContext as LoginViewModel;
                level       = loginVM.level;
                if (loginVM.isLogin)
                {
                    p.Show();
                }
                else
                {
                    p.Close();
                }
                p.Show();
            });
            goodsCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
            {
                var w = new GoodsWindow();
                w.ShowDialog();
            });
            staffCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
            {
                if (true == level)
                {
                    var w = new StaffWindow();
                    w.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Bạn không có quyền truy cập mục này!");
                }
            });
            supplierCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
            {
                var w = new SupplierWindow();
                w.ShowDialog();
            });
            customerCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
            {
                var w = new CustomerWindow();
                w.ShowDialog();
            });
        }
 public NewAddressWindow(Address address, Button newAddressButton,
                         CustomerWindow customerWindow, NewCustomerWindow newCustomerWindow) : this()
 {
     this.address           = address;
     this.newAddressButton  = newAddressButton;
     this.customerWindow    = customerWindow;
     this.newCustomerWindow = newCustomerWindow;
 }
        private void Button_cancel_Click(object sender, RoutedEventArgs e)
        {
            CustomerWindow pa = new CustomerWindow();

            //PayforWindow pa = new PayforWindow(this);
            this.Close();
            pa.ShowDialog();
        }
 private void InitializeCustomerWindowCommand()
 {
     CustomerWindowCommand = new RelayCommand <object>(
         sender => { return(true); }, sender =>
     {
         CustomerWindow customerWindow = new CustomerWindow();
         customerWindow.ShowDialog();
     });
 }
Example #8
0
        public MainViewModel()
        {
            LoadedWindowCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => {
                isLoaded = true;
                if (p == null)
                {
                    return;
                }
                p.Hide();
                LoginWindow loginWindow = new LoginWindow();
                loginWindow.ShowDialog();
                if (loginWindow.DataContext == null)
                {
                    return;
                }
                var loginVM = loginWindow.DataContext as LoginViewModel;
                if (loginVM.IsLogin)
                {
                    p.Show();
                }
                else
                {
                    p.Close();
                }
            });

            SuplierWindowCommand = new RelayCommand <object>((p) => { return(true); }, (p) => {
                SuplierWindow window = new SuplierWindow();
                window.ShowDialog();
            });

            CustomerWindowCommand = new RelayCommand <object>((p) => { return(true); }, (p) => {
                CustomerWindow window = new CustomerWindow();
                window.ShowDialog();
            });

            ObjectWindowCommand = new RelayCommand <object>((p) => { return(true); }, (p) => {
                ObjectWindow window = new ObjectWindow();
                window.ShowDialog();
            });

            UserWindowCommand = new RelayCommand <object>((p) => { return(true); }, (p) => {
                UserWindow window = new UserWindow();
                window.ShowDialog();
            });

            InputWindowCommand = new RelayCommand <object>((p) => { return(true); }, (p) => {
                InputWindow window = new InputWindow();
                window.ShowDialog();
            });

            OutputWindowCommand = new RelayCommand <object>((p) => { return(true); }, (p) => {
                OutputWindow window = new OutputWindow();
                window.ShowDialog();
            });
        }
        private void BeginOrder_Click(object sender, RoutedEventArgs e)
        {
            CustomerWindow customerWindow = new CustomerWindow(BrandName_Selected.Text);

            customerWindow.Show();
            this.Close();
            //OrderWindow orderWindow = new OrderWindow(BrandName_Selected.Text);
            //orderWindow.Show();
            //this.Close();
        }
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            _unitOfWork.AdvertisementRepository.Delete(_itemToDelete);
            _unitOfWork.Save();

            CustomerWindow customerWindow = new CustomerWindow();

            customerWindow.Show();
            this.Close();
        }
Example #11
0
 public SaleView()
 {
     InitializeComponent();
     var customerWindow = new CustomerWindow() { DataContext = ItemsGrid, Left = 1024, Top = 0 };
     this.Loaded += (sender, args) =>
         {
             PosBootstrapper._msg.GetStream<ApplicationClosingEvent>()
                            .Subscribe(x => customerWindow.Close());
             customerWindow.Show();
         };
 }
        public NewAddressWindow(Address address,
                                CustomerWindow customerWindow, Button newAddressButton, NewCustomerWindow newCustomerWindow) : this()
        {
            addressTextField.Text = address.AddressName;
            countryTextField.Text = address.Country;

            this.newCustomerWindow = newCustomerWindow;
            this.customerWindow    = customerWindow;
            this.newAddressButton  = newAddressButton;
            this.address           = address;
            isUpdateFlag           = true;
        }
Example #13
0
        private void EnterButton_Click(object sender, RoutedEventArgs e)
        {
            User user = fornitureContext.Users.FirstOrDefault(u => u.Login == TextBoxLogin.Text && u.Password == PasswordBox.Password);

            if (user != null)
            {
                if (TextBoxCapcha.Text == cumcha)
                {
                    switch (user.Role)
                    {
                    case "Заказчик":
                        CustomerWindow customerWindow = new CustomerWindow(user.Login);
                        customerWindow.Show();
                        this.Close();
                        break;

                    case "Менеджер":
                        ManagerWindow managerWindow = new ManagerWindow(user.Login);
                        managerWindow.Show();
                        this.Close();
                        break;

                    case "Заместитель директора":
                        DepDirectorWindow depDirectorWindow = new DepDirectorWindow(user.Login);
                        depDirectorWindow.Show();
                        this.Close();
                        break;

                    case "Мастер":
                        MasterWindow masterWindow = new MasterWindow(user.Login);
                        masterWindow.Show();
                        this.Close();
                        break;

                    case "Директор":
                        DirectorWindow directorWindow = new DirectorWindow(user.Login);
                        directorWindow.Show();
                        this.Close();
                        break;
                    }
                }
                else
                {
                    MessageBox.Show("Капча введена не правильно");
                }
            }
            else
            {
                MessageBox.Show("Такого пользователя не существует!");
            }
        }
        public MainWindow(DatabaseContext context)
        {
            _context = context;
            InitializeComponent();

            _context.Database.EnsureDeleted();
            _context.Database.EnsureCreated();

            companyWindow = new CompanyWindow(_context);
            customerWindow = new CustomerWindow(_context);
            invoiceWindow = new InvoiceWindow(_context);
            productWindow = new ProductWindow(_context);
            taxWindow = new TaxWindow(_context);
        }
 public MainWindow()
 {
     InitializeComponent();
     DataConnection.DefaultSettings = new DbConfig();
     _container = ContainerConfig.BuildAutofacContainer();
     using (var container = _container.BeginLifetimeScope())
     {
         _mainViewModel      = container.Resolve <IMainViewModel>();
         _customerWindow     = container.Resolve <CustomerWindow>();
         _logWindow          = container.Resolve <LogWindow>();
         _locationTreeWindow = container.Resolve <LocationTreeWindow>();
         DataContext         = _mainViewModel;
     }
 }
        private void CustomerButton_Click(object sender, RoutedEventArgs e)
        {
            var customers = new CustomerWindow();
            var fadeIn    = new DoubleAnimation()
            {
                From     = 0,
                To       = 1,
                Duration = new Duration(customers.AnimationDuration)
            };

            customers.BeginAnimation(Window.OpacityProperty, fadeIn);
            customers.IsShowApplyButton = false;
            customers.Load(-1);
            customers.ShowDialog();
        }
Example #17
0
        public SaleView()
        {
            InitializeComponent();
            var customerWindow = new CustomerWindow()
            {
                DataContext = ItemsGrid, Left = 1024, Top = 0
            };

            this.Loaded += (sender, args) =>
            {
                PosBootstrapper._msg.GetStream <ApplicationClosingEvent>()
                .Subscribe(x => customerWindow.Close());
                customerWindow.Show();
            };
        }
        public NewCustomerWindow(Customer customer, DatabaseContext context, CustomerWindow customerWindow) : this(context)
        {
            nameTextField.Text       = customer.Name;
            emailTextField.Text      = customer.Email;
            newAddressButton.Content = customer.Address.AddressName + ", " + customer.Address.Country;
            phoneTextField.Text      = customer.PhoneNumber;
            websiteTextField.Text    = customer.Website;
            nipTextField.Text        = customer.Nip;
            noteTextField.Text       = customer.Note;

            address = customer.Address;

            this.customer       = customer;
            isUpdateFlag        = true;
            this.customerWindow = customerWindow;
        }
Example #19
0
        void btnOK_Click(object sender, RoutedEventArgs e)
        {
            if (comboBox1.SelectedIndex == 0)
            {
                CustomerWindow cu = new CustomerWindow();
                cu.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
                this.Close();
                cu.ShowDialog();
            }

            else
            {
                ManagerLogin ma = new ManagerLogin();
                ma.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
                this.Close();
                ma.ShowDialog();
            }
        }
 // mọi thứ xử lý sẽ nằm trong này
 public MainViewModel()
 {
     if (!IsLoaded)
     {
         LoadedWindowCommand = new RelayCommand <Window>((p) => { return(true); }, (p) =>
         {
             IsLoaded = true;
             if (p == null)
             {
                 return;
             }
             p.Hide();
             LoginWindow login = new LoginWindow();
             login.ShowDialog();
             if (login.DataContext == null)
             {
                 return;
             }
             var LoginVM = login.DataContext as LoginViewModel;
             if (LoginVM.IsLogin)
             {
                 p.Show();
                 LoadTonKhoData();
             }
             else
             {
                 p.Close();
             }
         });
         UnitCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
         {
             UnitWindow unit = new UnitWindow();
             unit.ShowDialog();
         });
         SuplierCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
         {
             SuplierWindow suplier = new SuplierWindow();
             suplier.ShowDialog();
         });
         CustomerCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
         {
             CustomerWindow suplier = new CustomerWindow();
             suplier.ShowDialog();
         });
         ObjectCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
         {
             ObjectWindow suplier = new ObjectWindow();
             suplier.ShowDialog();
         });
         UserCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
         {
             UserWindow suplier = new UserWindow();
             suplier.ShowDialog();
         });
         InputCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
         {
             InputWindow suplier = new InputWindow();
             suplier.ShowDialog();
         });
         OutnputCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
         {
             OutputWindow suplier = new OutputWindow();
             suplier.ShowDialog();
         });
     }
 }
        private void AddItemButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                switch (CategorySelectorComboBox.SelectedValue)
                {
                case "Brands":
                    BrandWindow brandWindow = new BrandWindow();
                    brandWindow.ShowDialog();
                    if (brandWindow.successFlag)
                    {
                        autoManager.Brand.Add(brandWindow.Brand);
                        autoManager.SaveChanges();
                    }
                    break;

                case "Car models":
                    CarModelWindow carModelWindow = new CarModelWindow(autoManager.Brand.ToList());
                    carModelWindow.ShowDialog();
                    if (carModelWindow.successFlag)
                    {
                        autoManager.Car_model.Add(carModelWindow.car_model);
                        autoManager.SaveChanges();
                    }
                    break;

                case "Offices":
                    OfficeWindow officeWindow = new OfficeWindow();
                    officeWindow.ShowDialog();
                    if (officeWindow.successFlag)
                    {
                        autoManager.Office.Add(officeWindow.office);
                        autoManager.SaveChanges();
                    }
                    break;

                case "Customers":
                    CustomerWindow customerWindow = new CustomerWindow();
                    customerWindow.ShowDialog();
                    if (customerWindow.successFlag)
                    {
                        autoManager.Customer.Add(customerWindow.customer);
                        autoManager.SaveChanges();
                    }
                    break;

                case "Employees":
                    EmployeeWindow employeeWindow = new EmployeeWindow(autoManager.Office.ToList());
                    employeeWindow.ShowDialog();
                    if (employeeWindow.successFlag)
                    {
                        autoManager.Employee.Add(employeeWindow.employee);
                        autoManager.SaveChanges();
                    }
                    break;

                case "Accidents":
                    AccidentWindow accidentWindow = new AccidentWindow(autoManager.Car.ToList());
                    accidentWindow.ShowDialog();
                    if (accidentWindow.successFlag)
                    {
                        var id = autoManager.Accident.Select(a => a.accident_id).Max() + 1;
                        accidentWindow.accident.accident_id = id;
                        autoManager.Accident.Add(accidentWindow.accident);
                        autoManager.SaveChanges();
                    }
                    break;

                case "Cars":
                    CarWindow carWindow = new CarWindow(autoManager.Car_model.ToList());
                    carWindow.ShowDialog();
                    if (carWindow.successFlag)
                    {
                        autoManager.Car.Add(carWindow.car);
                        autoManager.SaveChanges();
                    }
                    break;

                case "Lease contracts":
                    LeaseWindow leaseWindow = new LeaseWindow(autoManager.Office.ToList(), autoManager.Customer.ToList(), autoManager.Car.ToList());
                    leaseWindow.ShowDialog();
                    if (leaseWindow.successFlag)
                    {
                        autoManager.Lease_contract.Add(leaseWindow.lease_Contract);
                        autoManager.SaveChanges();
                    }
                    break;

                case "Purchase contracts":
                    PurchaseWindow purchaseWindow = new PurchaseWindow(autoManager.Office.ToList(), autoManager.Customer.ToList(), autoManager.Car.ToList());
                    purchaseWindow.ShowDialog();
                    if (purchaseWindow.successFlag)
                    {
                        autoManager.Purchase_contract.Add(purchaseWindow.purchase_Contract);
                        autoManager.SaveChanges();
                    }
                    break;
                }
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException)
            {
                MessageBox.Show("Error during adding item! Probably, you are trying to insert duplicate key into db", "Error");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error during adding item! " + ex.Message + " " + ex.InnerException, "Warning");
            }
            UpdateGrid();
        }
Example #22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="window"></param>
        public SalesWindowViewModel(Window window)
        {
            //ItemSalesColletion.CollectionChanged += (s, e) =>
            //{
            //    if (e.Action != System.Collections.Specialized.NotifyCollectionChangedAction.Reset)
            //    {
            //        decimal amount = 0;
            //        foreach (ItemSales item in e.NewItems)
            //        {
            //            item.PropertyChanged += (ss, ee) =>
            //            {
            //                if (ee.PropertyName == "SoldPirce")
            //                {
            //                    var sss = (ItemSales)ss;
            //                }
            //            };
            //            amount += item.SoldPirce;
            //            MessageBox.Show(amount.ToString());
            //        }
            //    }
            //};

            SalesDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            Timer timer = new Timer(1000);

            timer.Elapsed += (s, e) => { SalesDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); };
            timer.Start();

            WINDOW        = window;
            LogoutCommand = new DelegateCommand(Execute, () => { return(true); });
            CloseCommand  = new DelegateCommand(() => { Application.Current.Shutdown(); });

            SelectItemMasterCommand = new DelegateCommand(() =>
            {
                SelectItemMasterWindow w        = new SelectItemMasterWindow();
                SelectItemMasterViewModel model = new SelectItemMasterViewModel(w);
                w.DataContext = model;
                w.Owner       = App.Current.MainWindow;
                w.ShowDialog();

                //SOURCE = new ObservableCollection<ItemSales>(model.CheckedList);
                SOURCE.Clear();
                model.CheckedList.ForEach(s =>
                {
                    SOURCE.Add(new ItemSales
                    {
                        Id         = s.Id,
                        ItemId     = s.ItemId,
                        ItemName   = s.ItemName,
                        ItemSize   = s.ItemSize,
                        ItemType   = s.ItemType,
                        StockCount = s.StockCount,
                        SalesType  = 1,
                        SalesCount = 1,
                        StockPrice = s.StockPrice,
                        Price      = s.Price,
                        SoldPirce  = s.Price
                    });
                });
                //ItemSalesColletion = new ObservableCollection<ItemSales>(SOURCE.Skip(PageIndex * PAGESIZE).Take(PAGESIZE));
                ItemSalesColletion.Clear();
                SOURCE.Skip(PageIndex * PAGESIZE).Take(PAGESIZE).ToList().ForEach(ItemSalesColletion.Add);
            });

            SelectCustomerCommand = new DelegateCommand(() =>
            {
                SelectCustomerWindow w        = new SelectCustomerWindow();
                SelectCustomerViewModel model = new SelectCustomerViewModel(w);
                w.DataContext = model;
                w.Owner       = App.Current.MainWindow;
                w.ShowDialog();

                if (model.CheckedList != null)
                {
                    CustomerId   = model.CheckedList.Id;
                    CustomerName = model.CheckedList.Name;
                    Phone        = model.CheckedList.Phone;
                    IM           = model.CheckedList.IM;
                    Deposit      = model.CheckedList.Deposit;
                    DiscountRate = model.CheckedList.Discount;

                    ItemSalesColletion.ToList().ForEach(s =>
                    {
                        s.SoldPirce = s.SoldPirce * DiscountRate / 100;
                    });

                    if (SelectedItemSales != null)
                    {
                        SoldPirce = SelectedItemSales.SoldPirce;
                    }
                }
            });

            ClearCustomerCommand = new DelegateCommand(() =>
            {
                ClearCustomer();

                ItemSalesColletion.ToList().ForEach(s =>
                {
                    s.SoldPirce = s.Price * s.SalesCount;
                });

                if (SelectedItemSales != null)
                {
                    SoldPirce = SelectedItemSales.Price * Count;
                }

                DiscountRate = 100;
            });

            SelectCommand = new DelegateCommand <ItemSales>(s =>
            {
                if (s != null)
                {
                    SelectedItemSales = s;

                    ItemId        = s.ItemId;
                    ItemName      = s.ItemName;
                    ItemSize      = s.ItemSize;
                    ItemType      = s.ItemType;
                    StockPrice    = s.StockPrice;
                    Price         = s.Price;
                    Count         = s.SalesCount;
                    SliderMaximum = s.StockCount;
                    SoldPirce     = s.SoldPirce;
                }
            });

            RemoveCommand = new DelegateCommand <ItemSales>(s =>
            {
                SOURCE.Remove(s);
                ItemSalesColletion = new ObservableCollection <ItemSales>(SOURCE.Skip(PageIndex * PAGESIZE).Take(PAGESIZE));
                ItemId             = "";
                ItemName           = "";
                ItemSize           = 0;
                ItemType           = 0;
                StockPrice         = 0;
                Price = 0;
                Count = 1;
            });

            //ItemMasterColletion = new ObservableCollection<ItemMaster>(SOURCE.Skip(PageIndex * PAGESIZE).Take(PAGESIZE));

            PreviousCommand = new DelegateCommand(() =>
            {
                PageIndex--;
                ItemSalesColletion = new ObservableCollection <ItemSales>(SOURCE.Skip(PageIndex * PAGESIZE).Take(PAGESIZE));
            }, () => { return(PageIndex > 0 ? true : false); });

            NextCommand = new DelegateCommand(() =>
            {
                PageIndex++;
                ItemSalesColletion = new ObservableCollection <ItemSales>(SOURCE.Skip(PageIndex * PAGESIZE).Take(PAGESIZE));
            }, () => { return((PageIndex + 1) * PAGESIZE < SOURCE.Count() ? true : false); });

            SalesItemCommand = new DelegateCommand(() =>
            {
                SalesItemWindow w        = new SalesItemWindow();
                SalesItemViewModel model = new SalesItemViewModel(w);
                w.DataContext            = model;
                w.Owner = App.Current.MainWindow;
                w.ShowDialog();
            });

            CustomerCommand = new DelegateCommand(() =>
            {
                CustomerWindow w        = new CustomerWindow();
                CustomerViewModel model = new CustomerViewModel(w);
                w.DataContext           = model;
                w.Owner = App.Current.MainWindow;
                w.ShowDialog();
            }, () => { return(string.IsNullOrEmpty(CustomerName)); });

            StockCommand = new DelegateCommand(() =>
            {
                StockWindow w        = new StockWindow();
                StockViewModel model = new StockViewModel(w);
                w.DataContext        = model;
                w.Owner = App.Current.MainWindow;
                w.ShowDialog();
            }, () => { return(ItemSalesColletion == null || ItemSalesColletion.Count == 0); });

            VoidCommand = new DelegateCommand(() =>
            {
                VoidWindow w = new VoidWindow();
                VoidWindowViewModel model = new VoidWindowViewModel(w);
                w.DataContext             = model;
                w.Owner = App.Current.MainWindow;
                w.ShowDialog();
            });

            SoldCommand = new DelegateCommand(() =>
            {
                StringBuilder message = new StringBuilder();
                if (!string.IsNullOrEmpty(CustomerName))
                {
                    var ned = Deposit - ItemSalesColletion.Sum(s => s.SoldPirce);
                    if (ned < 0)
                    {
                        message.Append("注意!!!");
                        message.Append(Environment.NewLine);
                        message.Append("客户余额不足,还差:" + ned + "元");
                        message.Append(Environment.NewLine);
                    }
                }
                message.Append("是否确认售出?");
                if (MessageBox.Show(window, message.ToString(), "确认售出点“Yes”,否则点“No”", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes) == MessageBoxResult.Yes)
                {
                    if (!string.IsNullOrEmpty(CustomerId))
                    {
                        ItemSalesColletion.ToList().ForEach(s => { s.CustomerId = CustomerId; s.DepositForUpdate = Deposit; });
                    }

                    if (SqlServerCompactService.InsertItemSales(ItemSalesColletion.ToList()))
                    {
                        message.Clear();
                        message.Append("本次共计售出:" + ItemSalesColletion.Sum(s => s.SalesCount) + "件,赚得:" + (ItemSalesColletion.Sum(s => s.SoldPirce) - ItemSalesColletion.Sum(s => s.StockPrice * s.SalesCount)) + "元!");
                        MessageBox.Show(message.ToString());

                        ClearItem();
                        ClearCustomer();
                        ItemSalesColletion.Clear();
                    }
                    else
                    {
                        message.Clear();
                        message.Append("销售失败,请重试!!!");
                        MessageBox.Show(message.ToString());
                    }
                }
            }, () => { return(ItemSalesColletion != null && ItemSalesColletion.Count > 0); });
        }
Example #23
0
 public MainViewModel()
 {
     IsSort = false;
     LoadedWindowCommand = new RelayCommand <Window>((p) => { return(true); }, (p) =>
     {
         if (p == null)
         {
             return;
         }
         p.Hide();
         LoginWindow loginWindow = new LoginWindow();
         loginWindow.ShowDialog();
         if (loginWindow.DataContext == null)
         {
             return;
         }
         var loginVM = loginWindow.DataContext as LoginViewModel;
         if (loginVM.IsLogin)
         {
             p.Show();
             LoadTonKhoData();
             name = loginVM.UserNames;
         }
         else
         {
             p.Close();
         }
     }
                                                     );
     UnitCommand        = new RelayCommand <object>((p) => { return(true); }, (p) => { UnitWindow wd = new UnitWindow(); UnitViewModel vm = new UnitViewModel(); wd.DataContext = vm; wd.ShowDialog(); });
     SuplierCommand     = new RelayCommand <object>((p) => { return(true); }, (p) => { SuplierWindow wd = new SuplierWindow(); SuplierViewModel vm = new SuplierViewModel(); wd.DataContext = vm; wd.ShowDialog(); });
     CustomerCommand    = new RelayCommand <object>((p) => { return(true); }, (p) => { CustomerWindow wd = new CustomerWindow(); CustomerViewModel vm = new CustomerViewModel(); wd.DataContext = vm; wd.ShowDialog(); });
     ObjectCommand      = new RelayCommand <object>((p) => { return(true); }, (p) => { ObjectWindow wd = new ObjectWindow(); ObjectViewModel vm = new ObjectViewModel(); wd.DataContext = vm; wd.ShowDialog(); });
     UserCommand        = new RelayCommand <object>((p) => { return(true); }, (p) => { UserWindow wd = new UserWindow(); UserViewModel vm = new UserViewModel(); wd.DataContext = vm; wd.ShowDialog(); });
     InputCommand       = new RelayCommand <object>((p) => { return(true); }, (p) => { InputWindow wd = new InputWindow(); InputViewModel vm = new InputViewModel(); wd.DataContext = vm; wd.ShowDialog(); });
     OutputCommand      = new RelayCommand <object>((p) => { return(true); }, (p) => { OutputWindow wd = new OutputWindow(); OutputViewModel vm = new OutputViewModel(); wd.DataContext = vm; wd.ShowDialog(); });
     UpdateCommand      = new RelayCommand <object>((p) => { return(true); }, (p) => { LoadTonKhoData(); });
     ExportExcelCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { ExportExcel(); });
     SearchCommand      = new RelayCommand <TextBox>((p) => { return(true); }, (p) => { CollectionViewSource.GetDefaultView(TonKhoList).Refresh(); });
     timkiemCommand     = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(TonKhoList);
         view.Filter         = UserFilter;
     });
     #region Sort
     SortDisplaynameCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         //lấy ra danh sách tồn kho đang hiển thị
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(TonKhoList);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
             view.SortDescriptions.Clear();                                                                     //xóa sắp xếp cũ để thực hiện lại việc sắp xếp
             view.SortDescriptions.Add(new SortDescription("Object.DisplayName", ListSortDirection.Ascending)); // thực hiện việc sắp xếp tăng dần
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Object.DisplayName", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     SortCountCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(TonKhoList);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Count", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Count", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Count", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("Count", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     STTCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
     {
         CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(TonKhoList);
         if (IsSort)
         {
             //view.SortDescriptions.Remove(new SortDescription("Count", ListSortDirection.Descending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("STT", ListSortDirection.Ascending));
         }
         else
         {
             //view.SortDescriptions.Remove(new SortDescription("Count", ListSortDirection.Ascending));
             view.SortDescriptions.Clear();
             view.SortDescriptions.Add(new SortDescription("STT", ListSortDirection.Descending));
         }
         IsSort = !IsSort;
     });
     #endregion
 }
Example #24
0
 // mọi thứ xử lý sẽ nằm trong này
 public MainViewModel()
 {
     LoadedWindowCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => {
         Isloaded = true;
         p.Hide();
         LoginWindow loginWindow = new LoginWindow();
         loginWindow.ShowDialog();
         p.Show();
     }
                                                     );
     UnitCommand     = new RelayCommand <object>((p) => { return(true); }, (p) => { UnitWindow wd = new UnitWindow(); wd.ShowDialog(); });
     SupplierCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { SupplierWindow wd = new SupplierWindow(); wd.ShowDialog(); });
     CustomerCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { CustomerWindow wd = new CustomerWindow(); wd.ShowDialog(); });
     ObjectCommand   = new RelayCommand <object>((p) => { return(true); }, (p) => { ObjectWindow wd = new ObjectWindow(); wd.ShowDialog(); });
     UserCommand     = new RelayCommand <object>((p) => { return(true); }, (p) => { UserWindow wd = new UserWindow(); wd.ShowDialog(); });
     InputCommand    = new RelayCommand <object>((p) => { return(true); }, (p) => { InputWindow wd = new InputWindow(); wd.ShowDialog(); });
     OutputCommand   = new RelayCommand <object>((p) => { return(true); }, (p) => { OutputWindow wd = new OutputWindow(); wd.ShowDialog(); });
 }
Example #25
0
        public MainWindowViewModel()
        {
            LoadMainWindowCommand = new RelayCommand <Window>(p => { return(p == null ? false : true); }, p =>
            {
                LoadStockInTradeData();
            });

            LoadChildWindowCommand = new RelayCommand <Button>(p => { return(p == null ? false : true); }, p =>
            {
                switch (p.Name)
                {
                case "btnStockin":
                    InputWindow inputWindow  = new InputWindow();
                    FrameworkElement window1 = Window.GetWindow(p);
                    var temp1         = window1 as Window;
                    inputWindow.Owner = temp1;
                    inputWindow.controlBar.packIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.Import;
                    inputWindow.ShowDialog();
                    break;

                case "btnStockout":
                    OutputWindow outputWindow = new OutputWindow();
                    FrameworkElement window2  = Window.GetWindow(p);
                    var temp2          = window2 as Window;
                    outputWindow.Owner = temp2;
                    outputWindow.controlBar.packIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.Export;
                    outputWindow.ShowDialog();
                    break;

                case "btnSupplies":
                    SuppliesWindow suppliesWindow = new SuppliesWindow();
                    FrameworkElement window3      = Window.GetWindow(p);
                    var temp3            = window3 as Window;
                    suppliesWindow.Owner = temp3;
                    suppliesWindow.controlBar.packIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.PackageVariantClosed;
                    suppliesWindow.ShowDialog();
                    break;

                case "btnUnit":
                    UnitWindow unitWindow    = new UnitWindow();
                    FrameworkElement window4 = Window.GetWindow(p);
                    var temp4        = window4 as Window;
                    unitWindow.Owner = temp4;
                    unitWindow.controlBar.packIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.ChartScatterPlotHexbin;
                    unitWindow.ShowDialog();
                    break;

                case "btnSupplier":
                    SupplierWindow supplierWindow = new SupplierWindow();
                    FrameworkElement window5      = Window.GetWindow(p);
                    var temp5            = window5 as Window;
                    supplierWindow.Owner = temp5;
                    supplierWindow.controlBar.packIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.Factory;
                    supplierWindow.ShowDialog();
                    break;

                case "btnCustomer":
                    CustomerWindow customerWindow = new CustomerWindow();
                    FrameworkElement window6      = Window.GetWindow(p);
                    var temp6            = window6 as Window;
                    customerWindow.Owner = temp6;
                    customerWindow.controlBar.packIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.AccountMultiple;
                    customerWindow.ShowDialog();
                    break;

                case "btnUser":
                    UserWindow userWindow    = new UserWindow();
                    FrameworkElement window7 = Window.GetWindow(p);
                    var temp7        = window7 as Window;
                    userWindow.Owner = temp7;
                    userWindow.controlBar.packIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.AccountEdit;
                    userWindow.ShowDialog();
                    break;
                }
            });
        }
 public CustomerViewModel(CustomerWindow customerWindow, POSWindow posWindow)
 {
     _customerWindow = customerWindow;
     _posWindow      = posWindow;
     _posRepository  = SettingHelpers.GetRepositoryImplementation();
 }
 public NewCustomerWindow(CustomerWindow customerWindow, DatabaseContext context) : this(context)
 {
     this.customerWindow = customerWindow;
 }
Example #28
0
        // Xử lý mọi thứ trong này
        public MainViewModel()
        {
            LoadedWindowCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
            {
                isLoaded = true;
                LoginWindow loginWindow = new LoginWindow();
                loginWindow.ShowDialog();
            }
                                                            );

            // Xử lý di chuyển giữa các màn hình.
            CustomerWindowCommand         = new RelayCommand <object>((p) => { return(true); }, (p) => { CustomerWindow window = new CustomerWindow(); window.ShowDialog(); });
            ImageManagementWindowCommand  = new RelayCommand <object>((p) => { return(true); }, (p) => { ImageManagementWindow window = new ImageManagementWindow(); window.ShowDialog(); });
            OutputWindowCommand           = new RelayCommand <object>((p) => { return(true); }, (p) => { OutputWindow window = new OutputWindow(); window.ShowDialog(); });
            OutputManagementWindowCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { ManageOutputWindow window = new ManageOutputWindow(); window.ShowDialog(); });

            //MessageBox.Show(DataProvider.Ins.DB.Users.First().HoTen);
        }
Example #29
0
 public CreateCustomer(MySqlConnection dataBase, CustomerWindow parent)
 {
     InitializeComponent();
     Parent   = parent;
     DataBase = dataBase;
 }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            CustomerWindow window = new CustomerWindow();

            window.Show();
        }
        public MainViewModel()
        {
            ImportWindow = new RelayCommand <Window>((p) => { return(true); }, (p) =>
            {
                if (_UserIDRole != 1)
                {
                    LoadDialogErrorNotPermission();
                    return;
                }
                ImportWindow wd = new ImportWindow();
                wd.ShowDialog();
            });
            SellWindow     = new RelayCommand <Window>((p) => { return(true); }, (p) => { SellWindow wd = new SellWindow(); wd.ShowDialog(); });
            CustomerWindow = new RelayCommand <Window>((p) => { return(true); }, (p) => { if (_UserIDRole != 1)
                                                                                          {
                                                                                              LoadDialogErrorNotPermission(); return;
                                                                                          }
                                                                                          CustomerWindow wd = new CustomerWindow(); wd.ShowDialog(); });
            ProductWindow = new RelayCommand <Window>((p) => { return(true); }, (p) => { if (_UserIDRole != 1)
                                                                                         {
                                                                                             LoadDialogErrorNotPermission(); return;
                                                                                         }
                                                                                         ProductWindow wd = new ProductWindow(); wd.ShowDialog(); });
            SupplierWindow = new RelayCommand <Window>((p) => { return(true); }, (p) => { if (_UserIDRole != 1)
                                                                                          {
                                                                                              LoadDialogErrorNotPermission(); return;
                                                                                          }
                                                                                          SupplierWindow wd = new SupplierWindow(); wd.ShowDialog(); });
            StatisticalWindow = new RelayCommand <Window>((p) => { return(true); }, (p) => { if (_UserIDRole != 1)
                                                                                             {
                                                                                                 LoadDialogErrorNotPermission(); return;
                                                                                             }
                                                                                             StatisticalWindow wd = new StatisticalWindow(); wd.ShowDialog(); });
            UnitWindow = new RelayCommand <Window>((p) => { return(true); }, (p) => { if (_UserIDRole != 1)
                                                                                      {
                                                                                          LoadDialogErrorNotPermission(); return;
                                                                                      }
                                                                                      UnitWindow wd = new UnitWindow(); wd.ShowDialog(); });
            UserListWindow = new RelayCommand <Window>((p) => { return(true); }, (p) => { if (_UserIDRole != 1)
                                                                                          {
                                                                                              LoadDialogErrorNotPermission(); return;
                                                                                          }
                                                                                          UserListWindow wd = new UserListWindow(); wd.ShowDialog(); });
            AccountCreateWindow = new RelayCommand <Window>((p) => { return(true); }, (p) => { if (_UserIDRole != 1)
                                                                                               {
                                                                                                   LoadDialogErrorNotPermission(); return;
                                                                                               }
                                                                                               AccountCreateWindow wd = new AccountCreateWindow(); wd.ShowDialog(); });
            BillWindow = new RelayCommand <Window>((p) => { return(true); }, (p) => { if (_UserIDRole != 1)
                                                                                      {
                                                                                          LoadDialogErrorNotPermission(); return;
                                                                                      }
                                                                                      BillWindow wd = new BillWindow(); wd.ShowDialog(); });
            LoadMainWindow = new RelayCommand <Window>((p) => { return(true); }, (p) =>
            {
                if (!isLoaded)
                {
                    isLoaded = true;
                    if (p == null)
                    {
                        return;
                    }

                    p.Hide();
                    LoginWindow wd = new LoginWindow();
                    wd.ShowDialog();
                    var loginViewModel = wd.DataContext as LoginViewModel;
                    if (loginViewModel == null)
                    {
                        return;
                    }
                    if (loginViewModel.isLogin)
                    {
                        loadUserCurrentLogin();
                        p.Show();
                    }
                    else
                    {
                        p.Close();
                    }
                }
            });

            LoadEditCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { LoadDialogAccountEdit(); });
        }