private void btnChangeBarcode_Click(object sender, EventArgs e) { if (txtBarcode.Text != "") { clsProductItem prod = clsProductItem.SearchProduct(txtBarcode.Text.Trim()); if (prod != null) { frmInput input = new frmInput(); input.Title = "Change Barcode"; input.Caption = "New Barcode"; input.withDecimal = false; input.IsNumericOnly = false; if (input.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (txtBarcode.Text.Trim() != input.Text.Trim()) { clsProductItem tmp = clsProductItem.SearchProduct(input.Value.Trim()); if (tmp != null) { MessageBox.Show("Change Barcode", "Barcode already exists!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { clsProductItem.ChangeBarcode(txtBarcode.Text.Trim(), input.Value.Trim()); txtBarcode.Text = input.Value.Trim(); txtSearchString.Text = input.Value.Trim(); btnSearch.PerformClick(); } } } } } }
private void AddItemToGrid(clsProductItem fitem) { int rowidx = dgvPurchase.Rows.Add(); dgvPurchase.Rows[rowidx].Cells[0].Value = fitem.BarCode; dgvPurchase.Rows[rowidx].Cells[1].Value = fitem.Description; dgvPurchase.Rows[rowidx].Cells[2].Value = fitem.Capital; dgvPurchase.Rows[rowidx].Cells[3].Value = fitem.Amount; dgvPurchase.Rows[rowidx].Cells[4].Value = fitem.WSAmount; dgvPurchase.Rows[rowidx].Cells[5].Value = fitem.Category; dgvPurchase.Rows[rowidx].Cells[6].Value = fitem.TotalInventoryQty; dgvPurchase.Rows[rowidx].Cells[7].Value = fitem.QtySold; dgvPurchase.Rows[rowidx].Cells[8].Value = fitem.TotalInventoryQty - fitem.QtySold; dgvPurchase.Rows[rowidx].Cells[9].Value = fitem.TotalInventoryQty - fitem.QtySold; dgvPurchase.Rows[rowidx].Cells[10].Value = string.Format("=J{0}-I{0}", rowidx + 2); //else //{ // dbConnect con = new dbConnect(); // Int32 ret = con.GetSoldItems(fitem.BarCode); // con.Close(); // dgvPurchase.Rows[rowidx].Cells[2].Value = ret; // if (ret > 0) // { // fitem.QtySold = ret; // fitem.Save(); // } //} }
private void ValidateOrder(bool enterqty = false) { if (mReceipt == null) { NewCustomer(); } if (mReceipt != null)// && (txtInput.Text.Substring(0, 4) == "RICE" || txtInput.Text.Substring(0, 4) == "SOFT" || txtInput.Text.Substring(0, 2) == "V0") { clsProductItem fi = AddProductToReceipt(txtInput.Text.ToUpper()); if (fi != null) { if (mAddItem) { if (enterqty) { frmQty fqty = new frmQty(); fqty.Quantity = fi.Qty; if (fqty.ShowDialog() == System.Windows.Forms.DialogResult.OK) { fi.Qty = fqty.Quantity; } } else { fi.Qty++; } } else { if (fi.Qty > 0) { fi.Qty -= 1; } } if (fi.Qty > 0) { lblDescription.Text = fi.Description; lblAmount.Text = fi.Amount.ToString(); lblQuantity.Text = fi.Qty.ToString(); } else { mReceipt.RemovePurchasedItem(fi); lblDescription.Text = ""; lblAmount.Text = "0.00"; lblQuantity.Text = ""; } // tsStatus.Text = "Status: Item Found!"; } else { // tsStatus.Text = "Status: Item Not Found!"; Setup(txtInput.Text.ToUpper()); } UpdateList(); } }
private void btnRemoveInventory_Click(object sender, EventArgs e) { if (txtBarcode.Text.Trim() != "") { string OrigQtValue = txtTotalQty.Text; frmInput input = new frmInput(); input.Title = "Remove Inventory"; input.Caption = "Quantity"; input.IsNumericOnly = true; if (input.ShowDialog() == System.Windows.Forms.DialogResult.OK) { clsProductItem fi = clsProductItem.SearchProduct(txtBarcode.Text); if (Convert.ToDouble(input.Value) <= 0) { MessageBox.Show("Quantity must be more than 0", "Remove Item", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (fi != null && fi.StocksRemainingQty - Convert.ToDouble(input.Value) >= 0) { frmInput inputReason = new frmInput(); inputReason.Title = "Remove Inventory"; inputReason.Caption = "Reason for Removing"; inputReason.Value = "Transfer Inventory"; if (inputReason.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (input.Value.Trim() == "") { MessageBox.Show("Must enter reason for removal of inventory", "Remove Items", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } clsInventory itemIventory = new clsInventory(); itemIventory.BarCode = txtBarcode.Text; itemIventory.Capital = Convert.ToDouble(txtCapital.Text); itemIventory.Quantity = -(Convert.ToDouble(input.Value)); itemIventory.Remarks = inputReason.Value; itemIventory.ExpiryDate = dtInventory.Value; itemIventory.DateAdded = dtInventory.Value; itemIventory.Save(); fi.TotalInventoryQty = clsInventory.GetTotalInventoryQty(fi.BarCode); fi.Save(); UpdateList(txtSearchString.Text); UpdateItemDisplay(fi.BarCode); } } else if (fi == null) { MessageBox.Show(string.Format("Product not found"), "Remove Inventory", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(string.Format("Removing quantity greater than available quantity not allowed"), "Remove Inventory", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }
private void AddItemToGrid(clsProductItem fitem) { int rowidx = dgvPurchase.Rows.Add(); dgvPurchase.Rows[rowidx].Cells[0].Value = fitem.BarCode; dgvPurchase.Rows[rowidx].Cells[1].Value = fitem.Description; dgvPurchase.Rows[rowidx].Cells[2].Value = fitem.Amount; dgvPurchase.Rows[rowidx].Cells[3].Value = fitem.WSAmount; dgvPurchase.Rows[rowidx].Cells[4].Value = fitem.StocksRemainingQty; }
private void AddItemToGrid(clsProductItem fitem) { int rowidx = dgvPurchase.Rows.Add(); dgvPurchase.Rows[rowidx].Cells[0].Value = fitem.BarCode; dgvPurchase.Rows[rowidx].Cells[1].Value = fitem.Description; dgvPurchase.Rows[rowidx].Cells[2].Value = fitem.Capital; dgvPurchase.Rows[rowidx].Cells[3].Value = fitem.Amount; dgvPurchase.Rows[rowidx].Cells[4].Value = fitem.WSAmount; dgvPurchase.Rows[rowidx].Cells[5].Value = fitem.TotalInventoryQty - fitem.QtySold; }
private void UpdateProductDisplay(string prod) { if (prod != "") { clsProductItem proditem = clsProductItem.SearchProduct(prod); if (proditem != null) { txtBarcode.Text = prod; SelectGrid(prod); } } }
private void btnAddInventory_Click(object sender, EventArgs e) { if (txtBarcode.Text.Trim() != "") { try { string barcode = txtBarcode.Text.Trim(); clsProductItem prod = clsProductItem.SearchProduct(barcode); if (prod == null) { MessageBox.Show("Save the item first.", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } frmAddInventory addinventory = new frmAddInventory(); addinventory.Quantity = 0; addinventory.Capital = prod.Capital; addinventory.Retail = prod.Amount; if (addinventory.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (addinventory.Capital <= 0 || addinventory.Quantity <= 0 || addinventory.Retail <= 0) { MessageBox.Show("Capital/Quantity/Retail must be greater than 0", "Add Item", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } clsInventory itemIventory = new clsInventory(); itemIventory.BarCode = barcode; itemIventory.Capital = addinventory.Capital; itemIventory.Quantity = addinventory.Quantity; itemIventory.ExpiryDate = dtInventory.Value; itemIventory.DateAdded = dtInventory.Value; itemIventory.Save(); prod.Capital = addinventory.Capital; prod.TotalInventoryQty = clsInventory.GetTotalInventoryQty(prod.BarCode); prod.Amount = addinventory.Retail; prod.Save(); //SelectItemFromGrid(itemIventory.BarCode); UpdateItemDisplay(barcode); UpdateList(txtSearchString.Text); //SaveProductItem(); // Update Quantity after saving inventory } } catch { } } }
private void AddItemToGrid(clsProductItem fitem) { int rowidx = dgvItemList.Rows.Add(); dgvItemList.Rows[rowidx].Cells[0].Value = fitem.BarCode; dgvItemList.Rows[rowidx].Cells[1].Value = fitem.Description; dgvItemList.Rows[rowidx].Cells[2].Value = fitem.Capital; dgvItemList.Rows[rowidx].Cells[3].Value = fitem.Amount; dgvItemList.Rows[rowidx].Cells[4].Value = fitem.WSAmount; dgvItemList.Rows[rowidx].Cells[5].Value = fitem.TotalInventoryQty; dgvItemList.Rows[rowidx].Cells[6].Value = fitem.Unit; dgvItemList.Rows[rowidx].Cells[7].Value = fitem.StocksRemainingQty; dgvItemList.Rows[rowidx].Cells[8].Value = fitem.Imagepath; dgvItemList.Rows[rowidx].Cells[9].Value = fitem.CriticalLevel; dgvItemList.Rows[rowidx].Cells[10].Value = fitem.Category; }
private void txtBarcode_Leave(object sender, EventArgs e) { if (txtBarcode.Text != "") { string barcode = txtBarcode.Text.Trim(); clsProductItem fi = clsProductItem.SearchProduct(barcode); if (fi != null && fi.BarCode != "") { UpdateItemDisplay(fi.BarCode); } else { ClearFields(true); txtDesc.Focus(); } } }
private void UpdateItemDisplay(string barcode) { clsProductItem fi = clsProductItem.SearchProduct(barcode); if (fi != null) { updateInventoryList(barcode); txtBarcode.Text = fi.BarCode; txtDesc.Text = fi.Description; txtCapital.Text = fi.Capital.ToString("0.00"); txtTotalQty.Text = fi.TotalInventoryQty.ToString(); txtAmount.Text = fi.Amount.ToString("0.00"); txtWSAmount.Text = fi.WSAmount.ToString("0.00"); txtImagePath.Text = fi.Imagepath; txtCriticalLevel.Text = fi.CriticalLevel.ToString(); labelItemsRemaining.Text = "Remaining Items: " + (fi.TotalInventoryQty - fi.QtySold).ToString(fi.Unit == "pc"?"0":"0.0"); picItem.ImageLocation = fi.Imagepath; cboUnit.Text = fi.Unit; cboCategory.SelectedItem = fi.Category; } }
private void AddItemToGrid(clsProductItem fitem) { int rowidx = dgvPurchase.Rows.Add(); dgvPurchase.Rows[rowidx].Cells[0].Value = fitem.BarCode; dgvPurchase.Rows[rowidx].Cells[1].Value = fitem.Description; dgvPurchase.Rows[rowidx].Cells[2].Value = fitem.TotalInventoryQty; dgvPurchase.Rows[rowidx].Cells[3].Value = fitem.CriticalLevel; dgvPurchase.Rows[rowidx].Cells[4].Value = fitem.TotalInventoryQty - fitem.QtySold; //else //{ // dbConnect con = new dbConnect(); // Int32 ret = con.GetSoldItems(fitem.BarCode); // con.Close(); // dgvPurchase.Rows[rowidx].Cells[2].Value = ret; // if (ret > 0) // { // fitem.QtySold = ret; // fitem.Save(); // } //} }
private void btnAddInventory_Click(object sender, EventArgs e) { frmInput input = new frmInput(); input.withDecimal = true; input.IsNumericOnly = false; input.Value = ""; input.Caption = "Enter Supplier/Reference Num"; if (input.ShowDialog() == System.Windows.Forms.DialogResult.Cancel || input.Value == "") { return; } foreach (KeyValuePair <string, clsPurchasedItem> items in m_receipt.PurchasedItems) { clsPurchasedItem prod = items.Value; clsInventory itemIventory = new clsInventory(); itemIventory.BarCode = prod.BarCode; itemIventory.Capital = prod.Capital; itemIventory.Quantity = prod.Qty; itemIventory.Remarks = input.Value; itemIventory.DateAdded = dtInventory.Value; itemIventory.Save(); clsProductItem item = clsProductItem.SearchProduct(prod.BarCode); if (item != null) { item.Capital = prod.Capital; item.TotalInventoryQty += prod.Qty; item.Amount = prod.Amount; item.Save(); } } DialogResult = System.Windows.Forms.DialogResult.OK; }
private void ChangeQuantity() { if (m_receipt.PurchasedItems.Count == 0) { return; } if (txtBarcode.Text.Trim() == "") { txtBarcode.Text = dgvPurchase.SelectedRows[0].Cells[0].Value.ToString(); } if (txtBarcode.Text != "") { clsProductItem prod = clsProductItem.SearchProduct(txtBarcode.Text); if (prod != null && prod.BarCode != "") { if (m_receipt.PurchasedItems.ContainsKey(prod.BarCode)) { if (txtBarcode.Text.Trim() != "") { try { string barcode = txtBarcode.Text.Trim(); frmAddInventory addinventory = new frmAddInventory(); addinventory.Quantity = m_receipt.PurchasedItems[barcode].Qty; addinventory.Capital = m_receipt.PurchasedItems[barcode].Capital; addinventory.Retail = m_receipt.PurchasedItems[barcode].Amount; if (addinventory.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (addinventory.Capital <= 0 || addinventory.Retail <= 0) { MessageBox.Show("Capital/Quantity must be greater than 0", "Add Item", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { m_receipt.PurchasedItems[prod.BarCode].Qty = addinventory.Quantity; m_receipt.PurchasedItems[prod.BarCode].Capital = addinventory.Capital; m_receipt.PurchasedItems[prod.BarCode].Amount = addinventory.Retail; UpdatePurchases(); } } } catch { } } //frmInput input = new frmInput(); //input.Title = "Quantity"; //input.Caption = "Quantity"; //input.Value = m_receipt.PurchasedItems[prod.BarCode].Qty.ToString(); //input.IsNumericOnly = true; //if (input.ShowDialog() == System.Windows.Forms.DialogResult.OK) //{ // double qty = Convert.ToDouble(input.Value); // if (qty > 0) // { // m_receipt.PurchasedItems[prod.BarCode].Qty = Convert.ToDouble(input.Value); // } // else // { // m_receipt.PurchasedItems.Remove(prod.BarCode); // } // UpdatePurchases(); //} } } } }
private void AddProduct(string barcode) { if (barcode != "") { clsProductItem prod = clsProductItem.SearchProduct(barcode); clsPurchasedItem purchased = null; if (prod != null) { if (m_receipt.PurchasedItems.ContainsKey(prod.BarCode)) { m_receipt.PurchasedItems[prod.BarCode].UserID = m_user.UserId; m_receipt.PurchasedItems[prod.BarCode].Qty += 1; purchased = m_receipt.PurchasedItems[prod.BarCode]; } else { purchased = new clsPurchasedItem(prod); purchased.UserID = m_user.UserId; if (purchased.Description.ToUpper().Contains("NEW ITEM")) { purchased.BarCode = ""; clsProductItem item = new clsProductItem(); frmInput nobarcode = new frmInput(); nobarcode.Title = "No Barcode"; nobarcode.Caption = "Product Description"; nobarcode.IsNumericOnly = false; nobarcode.Value = purchased.Description; if (nobarcode.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (nobarcode.Value != "") { item.Description = nobarcode.Value; if (MessageBox.Show("Item have Barcode?", "New Item", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) { nobarcode = new frmInput(); nobarcode.Title = "No Barcode"; nobarcode.Caption = "Scan Barcode"; nobarcode.IsNumericOnly = false; nobarcode.withDecimal = false; nobarcode.Value = ""; if (nobarcode.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (nobarcode.Value != "") { item.BarCode = nobarcode.Value; clsProductItem proditem = clsProductItem.SearchProduct(item.BarCode); if (proditem != null) { MessageBox.Show("Product already exist!", "New Item", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } } } else { Dictionary <int, string> lstCategories = dbConnect.GetCategories(); int catId = 1; foreach (KeyValuePair <int, string> category in lstCategories) { if (category.Value == purchased.Category) { catId = category.Key; } } item.BarCode = dbConnect.GetNextSKU().ToString(catId.ToString().Trim() + "000000"); } nobarcode = new frmInput(); nobarcode.Title = "No Barcode"; nobarcode.Caption = "Capital Amount"; nobarcode.IsNumericOnly = true; nobarcode.withDecimal = true; nobarcode.Value = "0"; if (nobarcode.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (nobarcode.Value != "") { item.Capital = Convert.ToDouble(nobarcode.Value); nobarcode = new frmInput(); nobarcode.Title = "No Barcode"; nobarcode.Caption = "Retail Amount"; nobarcode.IsNumericOnly = true; nobarcode.withDecimal = true; nobarcode.Value = "0"; if (nobarcode.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (nobarcode.Value != "") { item.Amount = Convert.ToDouble(nobarcode.Value); if (MessageBox.Show("Sold in Wholesale?", "New Item", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { nobarcode = new frmInput(); nobarcode.Title = "WholeSale"; nobarcode.Caption = "Quantity per Set(Box/Case/Rim)"; nobarcode.IsNumericOnly = true; nobarcode.withDecimal = false; nobarcode.Value = ""; if (nobarcode.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (nobarcode.Value != "") { item.WSMinimum = Convert.ToInt32(nobarcode.Value); nobarcode = new frmInput(); nobarcode.Title = "WholeSale"; nobarcode.Caption = "Amount per Set(Box/Case/Rim)"; nobarcode.IsNumericOnly = true; nobarcode.withDecimal = true; nobarcode.Value = ""; if (nobarcode.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (nobarcode.Value != "") { item.WSAmount = Convert.ToDouble(nobarcode.Value) / item.WSMinimum; item.Category = prod.Category; item.CategoryId = prod.CategoryId; item.CriticalLevel = 10; item.Imagepath = ""; item.QtySold = 0; item.TotalInventoryQty = 0; item.Save(); purchased = new clsPurchasedItem(clsProductItem.SearchProduct(item.BarCode)); } } } } } else { item.WSAmount = item.Amount; item.Category = prod.Category; item.CategoryId = prod.CategoryId; item.CriticalLevel = 10; item.Imagepath = ""; item.QtySold = 0; item.TotalInventoryQty = 0; item.WSMinimum = 1; item.Save(); purchased = new clsPurchasedItem(clsProductItem.SearchProduct(item.BarCode)); } } } } } } } } if (purchased.BarCode != "") { m_receipt.PurchasedItems.Add(purchased.BarCode, purchased); } else { return; } } UpdatePurchases(); if (purchased != null && purchased.BarCode != "") { UpdateProductDisplay(purchased.BarCode); } } else { //MessageBox.Show("Barcode/Product Code not found", "Add Item", MessageBoxButtons.OK, MessageBoxIcon.Information); string result = SearchProduct(barcode); txtBarcode.Text = result; if (result != "") { AddProduct(result); } } } txtBarcode.SelectAll(); }
private void SaveProductItem() { try { if (txtBarcode.Text.Trim() != "" && txtDesc.Text.Trim() != "") { clsProductItem proditem = clsProductItem.SearchProduct(txtBarcode.Text); if (proditem == null) { proditem = new clsProductItem(); } proditem.BarCode = txtBarcode.Text.Trim().ToUpper(); proditem.Description = txtDesc.Text.Trim(); proditem.Amount = double.Parse(txtAmount.Text.Trim()); proditem.WSAmount = double.Parse(txtWSAmount.Text.Trim()); proditem.WSMinimum = 0; proditem.TotalInventoryQty = clsInventory.GetTotalInventoryQty(proditem.BarCode); proditem.Capital = double.Parse(txtCapital.Text.Trim()); proditem.Imagepath = txtImagePath.Text.Trim(); proditem.QtySold = clsPurchasedItem.GetTotalQtySold(proditem.BarCode); if (cboUnit.SelectedIndex == -1 && cboUnit.Text == "") { proditem.Unit = "pc"; } else if (cboUnit.SelectedIndex == -1 && cboUnit.Text != "") { proditem.Unit = cboUnit.Text; } else { proditem.Unit = cboUnit.SelectedItem.ToString(); } if (chkInStorage.Checked) { proditem.InStorage = 1; } else { proditem.InStorage = 0; } proditem.CriticalLevel = Int32.Parse(txtCriticalLevel.Text); if (proditem.Capital > proditem.Amount || proditem.Capital > proditem.WSAmount) { MessageBox.Show("Retail/Wholesale Amount cannot be less than the capital", "Setup Product", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else if (proditem.WSAmount > proditem.Amount) { MessageBox.Show("Wholesale Amount cannot be greater than the retail amount.", "Setup Product", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else if (proditem.Capital <= 0) { MessageBox.Show("Capital Amount cannot be zero.", "Setup Product", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (categories != null && categories.ContainsValue(cboCategory.SelectedItem.ToString())) { foreach (KeyValuePair <int, string> str in categories) { if (str.Value == cboCategory.SelectedItem.ToString()) { proditem.CategoryId = str.Key; break; } } } if (proditem.Save()) { UpdateList(proditem.BarCode); SelectItemFromGrid(proditem.BarCode); } } else { MessageBox.Show("Fill-out the form correctly.", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information); txtBarcode.Focus(); } //if (mBarcode != "") this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }