/// <summary> /// PRIVATE METHOD TO HANDLE TRANSACTION /// </summary> /// private void HandleTransaction() { serviceModel = new ServicesModel(); saleModel = new SalesModel(); pmodel = new ProductModel(); string serviceid = SaleServiceIDtxt.Text; string custname = "unspecified"; string date = SalesServiceDataPicker.Value.ToShortDateString().ToString(); if (SelectedProductsList.Items.Count <= 0) { MessageBox.Show("Please add product to list", "Product List Empty", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (CustomeNametxt.Text != "") { custname = CustomeNametxt.Text; } // try { foreach (ListViewItem item in SelectedProductsList.Items) { serviceController.SaveServiceRecord(utils.PrepareServiceModel(item, date, serviceid)); serviceModel.ProductId = item.SubItems[0].Text; serviceModel.QuantitySold = item.SubItems[2].Text; pmodel = productController.GetProductQntyById(serviceModel.ProductId); var npmodel = utils.FormatProductQuantity(pmodel.ProductQuantity, serviceModel.QuantitySold, "remove"); npmodel.ID = pmodel.ID; productController.UpdateProductByProductId(npmodel); } saleModel = utils.PrepareSalesModel(SaleServiceIDtxt.Text, TotalTransactionCosttxt.Text, date, custname, Usernamelbl.Text); salesController.SaveSaleRecord(saleModel); FillAllProductList(); // MessageBox.Show("Transaction Completed", "Transaction", MessageBoxButtons.OK, MessageBoxIcon.Information); SelectedProductsList.Items.Clear(); ///TODO /// message alert on if the user wants to print the receipt; /// } catch (Exception ex) { MessageBox.Show(ex.Message, "System Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }