Beispiel #1
0
        private void addProductButton_Click(object sender, RoutedEventArgs e)
        {
            AddProductWindow form = new AddProductWindow();

            form.ShowDialog();
            this.ShowAll();
        }
Beispiel #2
0
 void ShowWindowAddProduct() // Wyświetlenie okna dialogowego do wprowadzenia nowego typu produktu
 {
     NewProductVM                  = new AddProductViewModel();
     _addProductWindow             = new AddProductWindow();
     _addProductWindow.DataContext = NewProductVM;
     _addProductWindow.ShowDialog();
 }
Beispiel #3
0
        private void EditProduct(ProductControlUC para)
        {
            Product product = new Product();
            int     id      = int.Parse(para.txbID.Text);

            product = (Product)DataProvider.Instance.DB.Products.Where(x => x.ID == id).First();

            ImageBrush imageBrush = new ImageBrush();

            imageBrush.ImageSource = Converter.Instance.ConvertByteToBitmapImage(product.Image);

            AddProductWindow window = new AddProductWindow();

            window.txtID.Text = product.ID.ToString();

            window.txtName.Text           = product.Name;
            window.txtName.SelectionStart = window.txtName.Text.Length;

            window.txtUnit.Text           = product.Unit;
            window.txtUnit.SelectionStart = window.txtUnit.Text.Length;

            window.txtPrice.Text           = ConvertToString(product.ExportPrice);
            window.txtPrice.SelectionStart = window.txtPrice.Text.Length;

            window.Title = "Update info product";
            window.grdImage.Background = imageBrush;
            if (window.grdImage.Children.Count != 0)
            {
                window.grdImage.Children.Remove(window.grdImage.Children[0]);
                window.grdImage.Children.Remove(window.grdImage.Children[0]);
            }

            window.ShowDialog();
        }
        private void newProductButton_Click(object sender, RoutedEventArgs e)
        {
            AddProductWindow apw = new AddProductWindow();

            this.Hide();
            apw.ShowDialog();
            this.Show();
        }
Beispiel #5
0
        private void addProduct_Click(object sender, RoutedEventArgs e)
        {
            AddProductWindow addProduct = new AddProductWindow();

            addProduct.WindowStartupLocation = WindowStartupLocation.CenterScreen;

            addProduct.ShowDialog();
        }
        private void BtnCreate_Click(object sender, RoutedEventArgs e)
        {
            AddProductWindow dlg = new AddProductWindow();

            dlg.ShowDialog();

            UpdateDatabase();
        }
Beispiel #7
0
 private void editProductButton_Click(object sender, RoutedEventArgs e)
 {
     if (productsGrid.SelectedItem != null)
     {
         var edit = (GridsInfo.newProduct)productsGrid.SelectedItem;
         AddProductWindow form = new AddProductWindow(DBContext.Products.Find(edit.ID).ID);
         form.ShowDialog();
     }
     else
     {
         MessageBox.Show("Не выбрано поле для редактирования", "Ошибка");
     }
     this.ShowAll();
 }
Beispiel #8
0
        void ShowWindowEditProduct() // Wyświetlenie okna dialogowego do edycji typu produktu
        {
            if (SelectedProduct != null)
            {
                NewProductVM             = new AddProductViewModel();
                NewProductVM.Prod        = SelectedProduct;
                NewProductVM.ProductType = ProductTypeCollection.Where(x => x.Id == SelectedProduct.ProductTypeId).First();
                NewProductVM.IdVisible   = Visibility.Visible;
                NewProductVM.IsEnabled   = false;

                _addProductWindow             = new AddProductWindow();
                _addProductWindow.DataContext = NewProductVM;
                _addProductWindow.Title       = "Edycja produktu";
                _addProductWindow.ShowDialog();
            }
        }
Beispiel #9
0
 private void allProduct_DG_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     try
     {
         if (allProduct_DG.SelectedCells.Count > 0 && allProduct_DG.SelectedCells[0].IsValid)
         {
             InfoAllProduct   t      = allProduct_DG.SelectedItem as InfoAllProduct;
             AddProductWindow window = new AddProductWindow(t.Shtrix, true);
             window.ShowDialog();
             Refresh_DG();
         }
     }
     catch (Exception err)
     {
         MessageBox.Show("Error16");
     }
 }
Beispiel #10
0
        public Product OpenAddProductWindow()
        {
            AddProductWindow win = new AddProductWindow();

            if (win.ShowDialog() == true)
            {
                Product p = new Product()
                {
                    Name     = win.name.Text,
                    Price    = win.price.Text,
                    Num      = win.num.Text,
                    Category = (win.listCategory.SelectedItem as Category).Name,
                    Cid      = (win.listCategory.SelectedItem as Category).Id,
                    Producer = (win.listProducer.SelectedItem as Producer).Name,
                    Pid      = (win.listProducer.SelectedItem as Producer).Id,
                    Image    = win.Image == "" ? "Image/image1.ico" : win.Image
                };
                return(p);
            }
            return(null);
        }
Beispiel #11
0
        private void OpenAddProductWindow(Views.HomeWindow para)
        {
            AddProductWindow window = new AddProductWindow();

            this.imageFileName = null;
            try
            {
                string query = "SELECT * FROM Product";

                Product product = DataProvider.Instance.DB.Products.SqlQuery(query).Last();
                window.txtID.Text = (product.ID + 1).ToString();
            }
            catch
            {
                window.txtID.Text = "1";
            }
            finally
            {
                window.ShowDialog();
            }
        }
Beispiel #12
0
        //public PageViewModel ViewModel;
        //static Paging PagedTable = new Paging();
        //MultiUsesProductoWindow window;

        //AddToExistentProductWindow window3;

        ////test user github

        ////Numeros a mostrar de pagina
        //public int NumeroPaginaActual;
        //public int NumeroPaginaMax;

        //public User thisUser;

        public PageProducts()
        {
            InitializeComponent();
            PageProductsViewModel vm = new PageProductsViewModel();

            DataContext = vm;

            if (vm.OpenAddProductAction == null)
            {
                vm.OpenAddProductAction = new Action(() =>
                {
                    AddProductWindow addProductWindow = new AddProductWindow();
                    addProductWindow.Show();
                });
            }

            ////Obtener el viewmodel de la ventana principal y lo incializamos
            //ViewModel = pageViewModel;
            //DataContext = ViewModel;

            //UtilidadPaginacion();

            //thisUser = user_;
        }
Beispiel #13
0
 public SaveProductVM(AddProductWindow addproductwindow)
 {
     SaveProductCreatedBy  = App.Current.Properties["LoginUsername"].ToString();
     this.addProductWindow = addproductwindow;
     SaveCommandProduct    = new SaveProductCommand(this);
 }
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            AddProductWindow addProductWindow = new AddProductWindow();

            addProductWindow.Show();
        }
Beispiel #15
0
 private void CloseWindow(AddProductWindow para)
 {
     para.Close();
 }
Beispiel #16
0
        private void AddProduct(AddProductWindow para)
        {
            if (string.IsNullOrEmpty(para.txtName.Text))
            {
                para.txtName.Focus();
                return;
            }
            if (string.IsNullOrEmpty(para.txtUnit.Text))
            {
                para.txtUnit.Focus();
                return;
            }
            if (string.IsNullOrEmpty(para.txtPrice.Text))
            {
                para.txtUnit.Focus();
                return;
            }

            try
            {
                int    id    = int.Parse(para.txtID.Text);
                string name  = para.txtName.Text;
                string unit  = para.txtUnit.Text;
                long   price = ConvertToNumber(para.txtPrice.Text);

                byte[] imgByteArr;
                if (imageFileName == null)
                {
                    imgByteArr = Converter.Instance.ConvertImageToBytes(@"..\..\Resources\Images\default.jpg");
                }
                else
                {
                    imgByteArr = Converter.Instance.ConvertImageToBytes(imageFileName);
                }

                Product product;
                //update product
                if (para.Title == "Update info product")
                {
                    product             = DataProvider.Instance.DB.Products.Where(x => x.ID == id).First();
                    product.ID          = id;
                    product.Name        = name;
                    product.Unit        = unit;
                    product.ExportPrice = price;
                    product.Image       = imgByteArr;
                }
                //add product
                else
                {
                    product             = new Product();
                    product.ID          = id;
                    product.Name        = name;
                    product.Unit        = unit;
                    product.ImportPrice = 0;
                    product.ExportPrice = price;
                    product.Count       = 0;
                    product.Image       = imgByteArr;
                    product.IsDelete    = false;
                }
                this.AddOrUpdateProduct(product);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                LoadProduct(this.HomeWindow);
                para.Close();
            }
        }