private void btnUpdate_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtItemName.Text)) { throw new Exception("Item name Can't be empty"); } set.SetSellinPrice(txtSellingPrice.Text); set.SetQuantity(txtquantity.Text); var amount = Int32.Parse(txtAmount.Text); if (set.getItemID() == 0) { throw new Exception("No record is selected, Select a record and try again"); } //MODIFY THE COHER var newQty = oldQty + set.GetQuantity(); set.UpdateSaleItems(set.getItemID(), txtItemName.Text, newQty, set.GetSellingPrice().ToString(), amount.ToString(), dateTimeAdded); Clear(); infor = 10; Infortimer.Start(); btnRefresh.ForeColor = Color.Blue; } catch (Exception ex) { MessageBox.Show(ex.Message, "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void Infortimer_Tick(object sender, EventArgs e) { if (success > 0) { lblinfor.Visible = true; success--; } else { lblinfor.Visible = false; Infortimer.Stop(); } }
private void btnSave_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtItemName.Text)) { throw new Exception("item name is empty"); } set.SetItemName(txtItemName.Text); set.SetSellinPrice(txtSellingPrice.Text); set.SetQuantity(txtquantity.Text); set.RecordSaleItems(set.GetItemName(), set.GetQuantity(), set.GetSellingPrice().ToString(), txtAmount.Text, dateTimeAdded); infor = 10; Infortimer.Start(); Clear(); btnRefresh.ForeColor = Color.Blue; }catch (Exception ex) { MessageBox.Show(ex.Message, "Save Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnDelete_Click(object sender, EventArgs e) { try { if (set.getItemID() == 0) { throw new Exception("No record is selected, Select a record and try again"); } else if (MessageBox.Show("This will delete all sales record for selected item\nDo you want to continue ?", "Confim Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { set.Delete(set.getItemID()); Clear(); infor = 10; Infortimer.Start(); btnRefresh.ForeColor = Color.Blue; dataAccess.Description = "Deleted " + txtItemName.Text; dataAccess.Activities(); } }catch (Exception ex) { MessageBox.Show(ex.Message, "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnSubmit2_Click(object sender, EventArgs e) { try { if (checkCredit.Checked == true) { //operation creditor.SetFirstname(txtFirstname.Text); creditor.SetLasttname(txtLastname.Text); if (string.IsNullOrEmpty(txtContact.Text)) { if (MessageBox.Show("Creditor's Contact is empty\ncontinue ?", "Contact Error", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { creditor.SetContact(""); } else { throw new Exception("Please provide contact infor and continue"); } } else { if (txtContact.Text.Length < 11 || txtContact.Text.Length > 11) { throw new Exception("Creditor's Contact has Invalid length of digits"); } creditor.SetContact(txtContact.Text); } setsales.SetQuantity(txtquantity.Text); setsales.SetSellinPrice(txtSelingPrice.Text); if (setsales.getItemID() <= 0) { throw new Exception("Item Not found, Select and item"); } var qtyAvailable = 0; var qtySold = 0; qtyAvailable = ItemSales.checkItemQuantity(setsales.getItemID()); qtySold = ItemSales.checkItemQuantitySold(setsales.getItemID()); if (qtyAvailable <= qtySold) { throw new Exception("Item Selected is not available in Stock\nsales could not completed"); } if (qtyAvailable < qtySold + setsales.GetQuantity()) { throw new Exception("Quantity entered is greater than available Stock\nsales could not completed"); } if (checkAddstudentName.Checked == true && NameID == null) { throw new Exception("Student name is NOT Selected"); } if (string.IsNullOrEmpty(txtTotal.Text) | txtTotal.Text == "0") { throw new Exception("Total cost not provided Renter Quantity"); } var discount = txtPercent.Text; var NewQty = qtyAvailable - (qtySold + setsales.GetQuantity()); ItemSales.makeSale(setsales.getItemID(), NewQty, setsales.GetQuantity().ToString(), txtAmount.Text, txtTotal.Text, dateTimeAdded, discount, 1, NameID); Clear(); success = 10; Infortimer.Start(); } else { //TO INSERT setsales.SetQuantity(txtquantity.Text); setsales.SetSellinPrice(txtSelingPrice.Text); var qtyAvail = 0; var qtySold = 0; if (setsales.getItemID() <= 0) { throw new Exception("Item Not found, Select and item"); } qtyAvail = ItemSales.checkItemQuantity(setsales.getItemID()); qtySold = ItemSales.checkItemQuantitySold(setsales.getItemID()); if (qtyAvail <= qtySold) { throw new Exception("Selected item is not available in Stock\nsales could not completed"); } if (qtyAvail < qtySold + setsales.GetQuantity()) { throw new Exception("Selected item Quantity is greater than available Stock\nsales could not completed"); } if (checkAddstudentName.Checked == true && NameID == null) { throw new Exception("Student name is NOT Selected"); } if (string.IsNullOrEmpty(txtTotal.Text) | txtTotal.Text == "0") { throw new Exception("Total cost not provided Renter Quantity"); } var discount = txtPercent.Text; var NewQty = qtyAvail - (qtySold + setsales.GetQuantity()); ItemSales.makeSale(setsales.getItemID(), NewQty, setsales.GetQuantity().ToString(), txtAmount.Text, txtTotal.Text, dateTimeAdded, discount, 0, NameID); Clear(); success = 10; Infortimer.Start(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Sales Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } }