//add item to the list private void addItemToTheList(MDB_ProductModel product) { //create new product MDB_SingleItemSale item = new MDB_SingleItemSale() { id = product.id, item_id = product.id, name = this.getSimpleName(product.name), //product.name,//remove all the app price = product.retail_price, discount = product.discount_amt, //if product is on offer vat = (product.vat_inclusive == 1)? Convert.ToSingle((product.retail_price * 0.18)) : product.vat_amt, //product.vat_amt, vat_inclusive = product.vat_inclusive, qty = 1 }; //MessageBox.Show(item.name); //itemsListForReceipt.Add(item); itemsListForReceipt.Insert(0, item); itemsForReceiptDataGridView.Update(); itemsForReceiptDataGridView.Refresh(); //refresh the list this.do_calculations(); //command the parent form to clear the search for the next scan POSForm pf = (POSForm)this.ParentForm; pf.connect_receipt_2_store_clear_search_Key(); }//
}// #endregion //onclick panel item void Product_Clicked(object sender, EventArgs e, MDB_ProductModel product) { G_POS.POS.Forms.POSForm pf = (G_POS.POS.Forms.POSForm) this.ParentForm; pf.connect_store_n_receipt_send_this_item(product); this.putSearchOnFocus(); connector_in_clear_search(); }
// //update the existing item private void updateTheExistingProduct(MDB_ProductModel product) { /*MessageBox.Show(itemsListForReceipt.Count + " items"); * List<M_ReceiptDataModel> list = itemsListForReceipt.ToList(); * //check if item is present in the list item * M_ReceiptDataModel existing_product = list.Find(i => i.item_id == product.id); * if (existing_product != null) * { * //item already exists * list.Where(i => i.item_id == existing_product.item_id).ToList().ForEach(s => s.Qty = existing_product.Qty + 1); * itemsListForReceipt = new BindingList<M_ReceiptDataModel>(list); * * itemsForReceiptDataGridView.Update(); * itemsForReceiptDataGridView.Refresh(); //refresh the list * this.do_calculations(); * } * else { MessageBox.Show("Is null"); }*/ /*List<M_ReceiptDataModel> list = itemsListForReceipt.ToList(); * for (int i = 0; i < list.Count; i++) * { * if (Convert.ToInt32(list[i].item_id) == Convert.ToInt32(product.id)) * { * // MessageBox.Show(list.Count + " items f"); * //update * list[i].Qty = list[i].Qty + 1; * itemsListForReceipt = new BindingList<M_ReceiptDataModel>(list);//update entirelist * // break; * } * } * itemsForReceiptDataGridView.Update(); * itemsForReceiptDataGridView.Refresh(); //refresh the list * this.do_calculations();*/ List <MDB_SingleItemSale> list = itemsListForReceipt.ToList(); for (int i = 0; i < itemsListForReceipt.Count; i++) { if (Convert.ToInt32(itemsListForReceipt[i].id) == Convert.ToInt32(product.id)) { //update itemsListForReceipt[i].qty = itemsListForReceipt[i].qty + 1; break; } } itemsForReceiptDataGridView.Update(); itemsForReceiptDataGridView.Refresh(); //refresh the list this.do_calculations(); //command the parent form to clear the search for the next scan POSForm pf = (POSForm)this.ParentForm; pf.connect_receipt_2_store_clear_search_Key(); }
}// //add qty and amount for ready existing item private bool checkIfProductExist(MDB_ProductModel product) { bool truth = false; List <MDB_SingleItemSale> list = itemsListForReceipt.ToList(); for (int i = 0; i < list.Count; i++) { if (Convert.ToInt32(list[i].id) == Convert.ToInt32(product.id)) { truth = true; break; } } return(truth); }//
// //get product prod from given id private MDB_ProductModel getProductObjectFromId(int id) { MDB_ProductModel _model = null; for (var i = 0; i < currentListOfProducts.Count; i++) { if (currentListOfProducts[i].id == id) { //MessageBox.Show(productsList[i].is_raw + ""); _model = currentListOfProducts[i]; } } return(_model); }
public void connector_in_push_item_for_receipt(MDB_ProductModel product) { //check for item already exists or not bool res = checkIfProductExist(product); //** check if negative qty **// /*if (product.current_qty <= 0) { * MessageBox.Show("SORRY ITEM OUT OF STOCK!!\nPlease refer to stock keeper!"); * return; * }*/ if (product.retail_price == 0) { MessageBox.Show("SORRY NO PRICE ITEM DETECTED!! \n DONT SELL THIS ITEM TILL PRICE FIX!!"); return; } //****// if (res == true) { //sound soundHelper.getDefaultTone(); this.updateTheExistingProduct(product); } else { //depend on the size on the receipt if (this.ITEM_COUNTER >= this.MAX_ITEMS_COUNTS) { MessageBox.Show("MAX ITEMS FOR FIRST RECEIPT\nSAVE / PRINT THIS FIRST\nTHEN CLEAR", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { //sound soundHelper.getDefaultTone(); this.addItemToTheList(product); this.ITEM_COUNTER += 1; } } }
public void connect_store_n_receipt_send_this_item(MDB_ProductModel product) { this.receiptGeneratorControl.connector_in_push_item_for_receipt(product); }