public ActionResult Index(Product product) { try { ProductTableData.updateProduct(product.ID, (int)product.Quantity_Available, (int)product.Unit_Price, (int)product.Selling_Price, product.Barcodes.ToArray(), product.Unique_Barcode, DateTime.Now); Supplier supplier = SupplierTableData.getSupplier(product.Model);//supplier name is saved in product model Product_Supplier product_Supplier = new Product_Supplier() { Date = DateTime.Now, Quantity = product.Quantity_Available, Supplier = supplier, Ref_Number = product.Type, Product_ID = product.ID, Unit_Price = product.Unit_Price }; Journal journal = new Journal(); journal.Date = product.Date_Updated; journal.Sub_Account_ID = 10; ///purchase account journal.Type = 0; /// 0 means Debit journal.Status = 1; ///posted journal.PreparedBy = 1; journal.AuthenticatedBy = 1; //Product_SupplierTableData.addNewProduct_Supplier() return(Json(new { msg = "Successfully added " + product.ID + " " + product.Quantity_Available + " " + product.Selling_Price + " " + product.Barcodes.First().Barcode_Serial })); } catch (Exception ex) { throw ex; } }
private void ProductModel_ComboBox_TextChanged(object sender, TextChangedEventArgs e) { if (productModel.SelectedIndex != -1) { product = ProductTableData.getProductByModel(productModel.Text); unitPrice.Text = product.Unit_Price.ToString(); sellingPrice.Text = product.Selling_Price.ToString(); quantityAvailable.Content = product.Quantity_Available; description.Text = product.Des; if (product.Unique_Barcode.Contains("NY")) { sameBarcode.IsChecked = true; } else if (product.Unique_Barcode.Contains("Y")) { uniqBarcode.IsChecked = true; } else if (product.Unique_Barcode.Contains("N")) { noBarcode.IsChecked = true; } } else { unitPrice.Text = ""; sellingPrice.Text = ""; quantityAvailable.Content = 0; quantity.Text = ""; description.Text = ""; } }
private void deleteSelectedBarcode_Click(object sender, RoutedEventArgs e) { List <ListViewItems> it = listView.SelectedItems.Cast <ListViewItems>().ToList(); 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; } foreach (ListViewItems item in it) { try { listView.Items.Remove(item); if (ProductTableData.delete1Barcode(item.IMEI, product.ID) == true) { Xceed.Wpf.Toolkit.MessageBox.Show("Barcode deleted successfully. Press ok to exit.", "Exit"); } } catch (Exception ex) { Xceed.Wpf.Toolkit.MessageBox.Show(ex.Message, "Error"); } } sort(); }
private void fillSaleDGandProductDG() { DB.resetConnString(); productsDG.Items.Clear(); salesHistoryDG.Items.Clear(); listView.Items.Clear(); deleteSelected.IsEnabled = false; adjustQuantity.IsEnabled = false; if (productModel.SelectedIndex == -1) { return; } // for product and barocde datagrid product = ProductTableData.getProductByModel(productModel.SelectedItem.ToString()); Barcode[] barcodes = ProductTableData.getBarcodesByPID(product.ID); if (product.Unique_Barcode.StartsWith("Y")) { deleteSelected.IsEnabled = true; } else { adjustQuantity.IsEnabled = true; } foreach (var item in barcodes) { if (premitBarcodeinListView(item.Barcode_Serial) == true) { listView.Items.Add(new ListViewItems(listView.Items.Count + 1, item.Barcode_Serial, item.Color, item.Date.ToString())); } } productsDG.Items.Add(product); //for sales table List <Customer_Sale> customer_Sale_List = Customer_SaleTableData.getCustomer_SalebyMatchingProduct(product); foreach (var item in customer_Sale_List) { if (item.Sale == null) { MessageBox.Show("Error showing this item. "); continue; } SalesHistoryDataGrid salesHis; if (item.Gifts.Count == 0) { salesHis = new SalesHistoryDataGrid(item, ""); } else { salesHis = new SalesHistoryDataGrid(item, item.Gifts.First().Barcode); } salesHistoryDG.Items.Add(salesHis); } }
private void barcodeimeiTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter && barcodeimeiTextBox.Text != "") { stockHistoryDG.Items.Clear(); salesHistoryDG.Items.Clear(); try { //for stock datagrid Barcode bar = ProductTableData.getBarcode(barcodeimeiTextBox.Text); Product product = bar.Product; stockHistoryDG.Items.Add(product); //for sales datagrid Gift gif = bar.Gift; if (gif != null) { Customer_Sale cus_sale = gif.Customer_Sale; SalesHistoryDataGrid salesHis = new SalesHistoryDataGrid(cus_sale, gif.Barcode); salesHistoryDG.Items.Add(salesHis); } } catch (Exception ex) { Xceed.Wpf.Toolkit.MessageBox.Show("No product found. Press 'OK' to exit.\n\nDetailed Error:" + ex.Message, "Empty Product", MessageBoxButton.OK, MessageBoxImage.Error); } } }
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); } }
private void ProductType_ComboBox_TextChanged(object sender, TextChangedEventArgs e) { listView.Items.Clear(); listView.IsEnabled = true; clearAll.IsEnabled = true; refresh_Button.IsEnabled = true; productModel.ItemsSource = ProductTableData.getAllTypeMachedModels(productType.Text); }
public ActionResult FillProductTable(string selected) { //if (selected != null) var product = ProductTableData.getAllProducts().Where(x => x.Model == selected).Select(x => new { ID = x.ID, Type = x.Type, Model = x.Model, Quantity = x.Quantity_Available, UnitPrice = x.Unit_Price, SellingPrice = x.Selling_Price, UniqueBarcode = x.Unique_Barcode }).FirstOrDefault(); //, UnitPrice = x.Unit_Price, SellingPrice = x.Selling_Price, UniqueBarcode = x.Unique_Barcode return(new JsonResult { Data = product, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public ActionResult FillPrices(string selected) { //if (selected != null) var prices = ProductTableData.getAllProducts().Where(x => x.Model == selected).Select(x => new { ID = x.ID, UnitPrice = x.Unit_Price, SellingPrice = x.Selling_Price, UniqueBarcode = x.Unique_Barcode, Description = x.Des }).FirstOrDefault(); //, UnitPrice = x.Unit_Price, SellingPrice = x.Selling_Price, UniqueBarcode = x.Unique_Barcode return(new JsonResult { Data = prices, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public ActionResult FillDDLModel(string selected) { //if (selected != null) var models = ProductTableData.getAllProducts().Where(x => x.Type == selected).Select(x => new { ID = x.ID, Model = x.Model }).ToList(); //, UnitPrice = x.Unit_Price, SellingPrice = x.Selling_Price, UniqueBarcode = x.uni return(new JsonResult { Data = models, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
// 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()); }
private void adjust_quantity_Click(object sender, RoutedEventArgs e) { int quantity = 0; if (newColor.Text != "" && int.TryParse(newColor.Text, out quantity) == true) { product.Quantity_Available = quantity; ProductTableData.updateProductQuantity(quantity, product.ID); this.Close(); } else { Xceed.Wpf.Toolkit.MessageBox.Show("Invalid value. Pres ok to exit.", "Invalid", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } }
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()); }
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(); }
private void sameBarcode_Checked(object sender, RoutedEventArgs e) { Product pro = ProductTableData.getProductByModel(productModel.Text); Barcode[] barcodeList = ProductTableData.getBarcodesByPID(pro.ID); listView.Items.Clear(); if (barcodeList.Count() == 1) { listView.Items.Add(new ListViewItems(1, barcodeList[0].Barcode_Serial, barcodeList[0].Color)); barcodeSerial.IsEnabled = false; color.IsEnabled = false; barcodeSerial.Background = new SolidColorBrush(Colors.LightBlue); listView.IsEnabled = false; clearAll.IsEnabled = false; Add_Color.IsEnabled = false; } }
public void update_Button_Click(object sender, RoutedEventArgs e) { if (int.TryParse(unitPrice.Text, out unitPriceInt) == true && int.TryParse(sellingPrice.Text, out sellingPriceInt) == true) { try { if (ProductTableData.updatePrice(product.ID, unitPriceInt, sellingPriceInt) == true) { Xceed.Wpf.Toolkit.MessageBox.Show("Price Updated Successfullly. Press ok to exit", "Info"); } } catch (Exception ex) { Xceed.Wpf.Toolkit.MessageBox.Show(ex.Message, "Error"); } this.Close(); } }
private void barcodeSerial_KeyDown(object sender, KeyEventArgs e) { int quan = 0; if (e.Key == Key.Enter && barcodeSerial.Text != "") { if (IsAlreadyExists(barcodeSerial.Text) == true) { Xceed.Wpf.Toolkit.MessageBox.Show("The barcode is already in the list. Pres ok to exit.", "Duplicate Barcode", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); barcodeSerial.Clear(); return; } else if (ProductTableData.hasBarcodeinDB(barcodeSerial.Text) == true) { Xceed.Wpf.Toolkit.MessageBox.Show("The barcode is already in the Database. Pres ok to exit.", "Duplicate Barcode in DB", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); barcodeSerial.Clear(); return; } else if (sameBarcode.IsChecked == true && listView.Items.Count >= 1) { Xceed.Wpf.Toolkit.MessageBox.Show("You can add only one barcode. Pres ok to exit.", "Barcode", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); barcodeSerial.Clear(); return; } else if (uniqBarcode.IsChecked == true && int.TryParse(quantity.Text, out quan) == true && listView.Items.Count > quan - 1) { Xceed.Wpf.Toolkit.MessageBox.Show("You cannot add barcode more than quantity. Press ok to exit.", "Barcode", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); barcodeSerial.Clear(); return; } listView.Items.Add(new ListViewItems(listView.Items.Count + 1, barcodeSerial.Text, "NONE")); listView.SelectedIndex = listView.Items.Count - 1; listView.ScrollIntoView(listView.SelectedItem); barcodeSerial.Clear(); } if (e.Key == Key.Enter && quan == listView.Items.Count && product.Unique_Barcode.StartsWith("Y")) { var uie = e.OriginalSource as UIElement; e.Handled = true; uie.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next)); } }
// 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_Button_Click(object sender, RoutedEventArgs e) { if (dataGrid.Items.Count == 0) { return; } int count = 0; try { foreach (Product obj in listProduct) { ProductTableData.updateProduct(obj.ID, (int)obj.Quantity_Available, (int)obj.Unit_Price, (int)obj.Selling_Price, obj.Barcodes.ToArray(), obj.Unique_Barcode, DateTime.Now); Product_SupplierTableData.addNewProduct_Supplier(listProduct_Supplier[count]); /// inserting new row in product supplier count++; dataGrid.Items.RemoveAt(0); ///Console.WriteLine(dataGrid.Items.Count); } int amount = (int)listProduct.Sum(ee => ee.Unit_Price * ee.Quantity_Available); /// Journal journal = new Journal(); journal.Date = datetime; journal.Sub_Account_ID = 10; ///purchase account journal.Type = 0; /// 0 means Debit journal.Status = 1; ///posted journal.PreparedBy = BL.Login.ID; journal.AuthenticatedBy = BL.Login.ID; if (paymentDueDouble != 0) ///adding due payment in journal details { //listJournal_Detail.Add(new Journal_Detail(5, (decimal)paymentDueDouble, "")); /// 5 is Accounts Payable listJournal_Detail.Add(new Journal_Detail() { Sub_Account_ID = 5, Amount = (decimal)paymentDueDouble }); /// 5 is Accounts Payable } JurnalTable_Data.PostPurchaseJournal(journal, listProduct_Supplier, listJournal_Detail, amount, paymentDueDouble); ///posting journal for purchase DB.DBSubmitChanges(); ///Confirming all the changes in Database listProduct.Clear(); referenceNo.Text = ""; supplier.Text = ""; supplier.IsEnabled = true; paymentCheckBox.IsChecked = false; totalPaymentDouble = 0; totalPayment.Content = 0; totalQuantityInt = 0; totalQuantity.Content = 0; grandTotalDouble = 0; grandTotal.Content = 0; paymentDue.Content = 0; paymentDueDouble = 0; paymentDatagrid.Items.Clear(); listProduct_Supplier.Clear(); product = null; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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); } }
private void ProductType_ComboBox_TextChanged(object sender, TextChangedEventArgs e) { productModel.ItemsSource = ProductTableData.getAllTypeMachedModels(productType.Text); }