using BiskLog_Point_Of_Sale.Invoice; using BiskLog_Point_Of_Sale.Multiple_Login; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Point_Of_Sale_Managment { public partial class quantityInvoice : Form { AddInvoice addInvoice; string codeOfProduct = ""; public quantityInvoice(AddInvoice invoice,string productCode = null) { InitializeComponent(); addInvoice = invoice; codeOfProduct = productCode; } private void txtqty_TextChanged(object sender, EventArgs e) { } private async void quantityManual_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { int quantity = int.Parse(txtqty.Text); Task task = new Task(() => { int result = addInvoice.AddToList(quantity, codeOfProduct); return result; }); task.Start(); int finalResult = await task; if (finalResult == 1) { this.Close(); } else if(finalResult == 2) { string title = "Product is out of stock"; string message = "Sorry you do not have enough quantity of the item available"; NoAction noAction = new NoAction(title,message); noAction.BringToFront(); noAction.ShowDialog(); } else { string title = "Sorry an error has occured"; string message = "Sorry, there was an error while adding the item to the invoice"; NoAction noAction = new NoAction(title, message); noAction.BringToFront(); noAction.ShowDialog(); this.Close(); } } } private void Txtqty_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 8) { } else if ((e.KeyChar < 48) || (e.KeyChar > 57)) { e.Handled = true; } } } }