private void deleteProduct_Click(object sender, RoutedEventArgs e)
        {
            if (productsDG.Items.Count == 0)
            {
                return;
            }
            MessageBoxResult res = Xceed.Wpf.Toolkit.MessageBox.Show("Are you sure?. Press 'Yes' to Confirm.", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Error, MessageBoxResult.No);

            if (res != MessageBoxResult.Yes)
            {
                return;
            }

            try
            {
                if (ProductTableData.deleteProduct(product.ID) == true)
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Product deleted form database");
                    productType.ItemsSource    = ProductTableData.getAllProductTypes();
                    productModel.SelectedIndex = -1;
                    productType.SelectedIndex  = -1;
                }
            }
            catch (Exception ex)
            {
                Xceed.Wpf.Toolkit.MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
        // GET: Purchase
        public ActionResult Index()
        {
            ViewBag.test = ProductTableData.getAllProducts();
            string[] supplier = SupplierTableData.getAllSupplierName().ToArray();
            string[] types    = ProductTableData.getAllProductTypes().ToArray();
            ViewData["supplierList"]     = supplier;
            ViewData["typeList"]         = types;
            ViewData["modelList"]        = new string[] { "Select" };
            ViewData["selectedType"]     = "Select";
            ViewData["selectedSupplier"] = "Select";

            return(View());
        }
        public ProductsWindow()
        {
            InitializeComponent();
            DB.resetConnString();
            addDatagridColumninStockHistory();

            Search_Product SP = new Search_Product();

            SP.addDatagridColumninSalesHistory(salesHistoryDG, true); //show unit price

            productType.AddHandler(System.Windows.Controls.Primitives.TextBoxBase.TextChangedEvent,
                                   new TextChangedEventHandler(ProductType_ComboBox_TextChanged));
            productModel.AddHandler(System.Windows.Controls.Primitives.TextBoxBase.TextChangedEvent, new TextChangedEventHandler(ProductModel_ComboBox_TextChanged));

            productType.ItemsSource = ProductTableData.getAllProductTypes();
        }
Пример #4
0
        public ActionResult Index(FormCollection collection)
        {
            string[] supplier = SupplierTableData.getAllSupplierName().ToArray();
            string[] types    = ProductTableData.getAllProductTypes().ToArray();
            ViewData["supplierList"] = supplier;
            ViewData["typeList"]     = types;

            string selected = collection["type"];

            ViewData["selectedType"]     = selected;
            ViewData["selectedSupplier"] = collection["supplier"].ToString();
            ViewData["selectedModel"]    = "Select";

            ViewData["modelList"] = ProductTableData.getAllTypeMachedModels(selected).ToArray();
            return(View());
        }
        // GET: PurchaseTest
        public ActionResult Index()
        {
            ViewBag.test = ProductTableData.getAllProducts();
            string[] supplier = SupplierTableData.getAllSupplierName().ToArray();
            string[] types    = ProductTableData.getAllProductTypes().ToArray();
            string[] colors   = FileManagement.getAllColor().ToArray();
            ViewBag.supplierList     = supplier;
            ViewData["supplierList"] = supplier;
            ViewData["typeList"]     = types;
            ViewData["colorList"]    = colors;

            ViewData["selectedSupplier"] = "Select";
            ViewData["selectedType"]     = "Select";
            ViewData["selectedModel"]    = "Select";
            ViewData["modelList"]        = new string[] { "Select" };
            ViewData["selectedColor"]    = "None";

            return(View());
        }
        public Stock()
        {
            InitializeComponent();
            DB.resetConnString();
            this.MaxHeight   = SystemParameters.MaximizedPrimaryScreenHeight;
            date.Text        = DateTime.Now.ToString();
            paymentDate.Text = DateTime.Now.ToString("dd/MM/yyyy hh:mm tt");

            color.AddHandler(System.Windows.Controls.Primitives.TextBoxBase.TextChangedEvent,
                             new TextChangedEventHandler(Color_ComboBox_TextChanged));

            supplier.AddHandler(System.Windows.Controls.Primitives.TextBoxBase.TextChangedEvent,
                                new TextChangedEventHandler(Supplier_Combobox_TextChanged));

            productType.AddHandler(System.Windows.Controls.Primitives.TextBoxBase.TextChangedEvent,
                                   new TextChangedEventHandler(ProductType_ComboBox_TextChanged));

            productModel.AddHandler(System.Windows.Controls.Primitives.TextBoxBase.TextChangedEvent,
                                    new TextChangedEventHandler(ProductModel_ComboBox_TextChanged));

            try
            {
                productType.ItemsSource = ProductTableData.getAllProductTypes();
                color.ItemsSource       = FileManagement.getAllColor();
                supplier.ItemsSource    = SupplierTableData.getAllSupplierName();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            paymentCheckBox.IsChecked = false;
            barcodeType.IsEnabled     = false;
            referenceNo.Focus();
            addDatagridColumns();
            addDatagridPaymentColumns();
        }
        private void ok_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (isTextBox == true && newProductModel.Text != "" && newProductTypeTextBox.Text != "" && unitPrice.Text != "" && sellingPrice.Text != "")
                {
                    Console.WriteLine(ProductTableData.IsProductAlreadyExists(newProductTypeTextBox.Text, newProductModel.Text));

                    if (ProductTableData.IsProductAlreadyExists(newProductTypeTextBox.Text, newProductModel.Text) == true)
                    {
                        Xceed.Wpf.Toolkit.MessageBox.Show("Product type or model is already in database. Please try again.\n\nPress ok to exit.", "Duplicate Product", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                        return;
                    }

                    Product product = new Product {
                        Model = newProductModel.Text, Type = newProductTypeTextBox.Text, Quantity_Available = 0, Quantity_Sold = 0, Unit_Price = unitPriceInt, Selling_Price = sellingPriceInt, Des = "None", Date_Updated = DateTime.Now, Unique_Barcode = getBarcodeSystem()
                    };


                    if (ProductTableData.addNewProduct(product) == true)
                    {
                        //FileManagement.setNewProductType(product.Type);
                        //FileManagement.setNewProductModel(product.Model);

                        productType.ItemsSource  = ProductTableData.getAllProductTypes();
                        productModel.ItemsSource = ProductTableData.getAllTypeMachedModels(product.Type);

                        productType.SelectedItem  = product.Type;
                        productModel.SelectedItem = product.Model;
                    }
                    else
                    {
                        Xceed.Wpf.Toolkit.MessageBox.Show("product is not added.", "No Intput", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                    }
                    this.Close();
                }
                else if (isTextBox == false && newProductModel.Text != "" && newProductTypeComboBox.SelectedIndex != -1 && unitPrice.Text != "" && sellingPrice.Text != "")
                {
                    if (ProductTableData.IsProductAlreadyExists("", newProductModel.Text) == true)
                    {
                        Xceed.Wpf.Toolkit.MessageBox.Show("Product model is already in database. Please try again.\n\nPress ok to exit.", "Duplicate Product Model", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                        return;
                    }
                    Product product = new Product {
                        Model = newProductModel.Text, Type = newProductTypeComboBox.Text, Quantity_Available = 0, Quantity_Sold = 0, Unit_Price = unitPriceInt, Selling_Price = sellingPriceInt, Des = "None", Date_Updated = DateTime.Now, Unique_Barcode = getBarcodeSystem()
                    };


                    if (ProductTableData.addNewProduct(product) == true)
                    {
                        //FileManagement.setNewProductModel(product.Model);

                        productType.ItemsSource  = ProductTableData.getAllProductTypes();
                        productModel.ItemsSource = ProductTableData.getAllTypeMachedModels(product.Type);

                        //productType.SelectedIndex = productType.Items.Count - 1;
                        //productModel.SelectedIndex = productModel.Items.Count - 1;
                        productType.Text  = newProductTypeComboBox.Text;
                        productModel.Text = newProductModel.Text;
                    }
                    else
                    {
                        Xceed.Wpf.Toolkit.MessageBox.Show("product is not added.", "No Intput", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                    }
                    this.Close();
                }
                else
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Some fields are empty.", "No Intput Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                    //this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n\n" + ex.StackTrace);
            }
        }