private void timer1_Tick(object sender, EventArgs e) { pbBicycle.Show(); pbCap.Show(); pbCharger.Show(); pbCamera.Show(); dataHelper = new Mysql(); lbCameraPrice.Text = dataHelper.GetPrdouctPrice("Camera").ToString() + "€"; lbBicyclePrice.Text = dataHelper.GetPrdouctPrice("Bicycle").ToString() + "€"; lbChargerPrice.Text = dataHelper.GetPrdouctPrice("Charger").ToString() + "€"; lbGogglesPrice.Text = dataHelper.GetPrdouctPrice("Googgles").ToString() + "€"; lbCameraPrice.Show(); lbBicyclePrice.Show(); lbChargerPrice.Show(); lbGogglesPrice.Show(); bicycle_quantity = dataHelper.GetStockQuantityOfBicycle(); camera_quantity = dataHelper.GetStockQuantityOfCamera(); googles_quantiy = dataHelper.GetStockQuantityOfGooggles(); charger_quantity = dataHelper.GetStockQuantityOfCharger(); if (bicycle_quantity < 1) { lbBicycleQuantity.Text = " Currently out of the stock"; bicycle_quantity = 0; } else { lbchargrQuan.Text = bicycle_quantity + "LEFT"; } if (camera_quantity < 1) { lbCameraQuantity.Text = " Currently out od the stock"; camera_quantity = 0; } else { lbCameraQuantity.Text = camera_quantity + " LEFT"; } if (googles_quantiy < 1) { lbGogglesQuantity.Text = " Currently out of the stock"; googles_quantiy = 0; } else { lbGogglesQuantity.Text = googles_quantiy + " LEFT"; } if (charger_quantity < 1) { lbchargrQuan.Text = " Currently out of the stock"; charger_quantity = 0; } else { lbBicycleQuantity.Text = charger_quantity + " LEFT"; } timer.Stop(); }
private void btnReturn_Click(object sender, EventArgs e) { if (Loaned_Items == true) { problems = tbProblem.Text; if (problems == "") { problems = "no"; } dataHelper = new Mysql(); List <string> itemsToReturn = new List <string>(); foreach (string item in lb_Receipt_info.Items) { itemsToReturn.Add(item); } string status = dataHelper.ReturnItem(rfid_Code, problems, itemsToReturn); if (status == "no user") { lbLoan_Status.Text = "Invalid User!"; lbLoan_Status.ForeColor = Color.Red; lb_Receipt_info.Items.Clear(); } else if (status == "returned") { lbLoan_Status.Text = "Returned Successfully!"; lbLoan_Status.ForeColor = Color.Green; List <string> items = new List <string>(); foreach (string item in lb_Receipt_info.Items) { items.Add(item); } foreach (string item in items) { lb_Receipt_info.SelectedItem = item; if (item.Contains("Charger")) { charger_quantity++; } else if (item.Contains("Bicycle")) { bicycle_quantity++; } else if (item.Contains("Googgles")) { googles_quantiy++; } else if (item.Contains("Camera")) { camera_quantity++; } btnRemove.PerformClick(); } } tbProblem.Text = ""; gbProblemBox.Enabled = false; lbPrice.Text = ""; lbRfid_Status.Text = ""; total_Price = 0; } else { lbLoan_Status.Text = "This user has nothing to return !"; lbLoan_Status.ForeColor = Color.Red; } }
private void btnLoad_Click(object sender, EventArgs e) { //first check if we have enough qty if (charger_quantity < 0) { lbLoan_Status.Text = "Excuse! this item is out of stock !"; lbLoan_Status.ForeColor = Color.Red; } else if (camera_quantity < 0) { lbLoan_Status.Text = " Excuse! this item is out of stock !"; lbLoan_Status.ForeColor = Color.Red; } else if (googles_quantiy < 0) { lbLoan_Status.Text = "Excuse! this item is out of stock !"; lbLoan_Status.ForeColor = Color.Red; } else if (bicycle_quantity < 0) { lbLoan_Status.Text = "Excuse! this item is out of stock !"; lbLoan_Status.ForeColor = Color.Red; } else { try { if (lbRfid_Status.Text != "") { dataHelper = new Mysql(); List <string> itemsToLoan = new List <string>(); foreach (string item in lb_Receipt_info.Items) { itemsToLoan.Add(item); } string status = dataHelper.LoanItemToVisitor(rfid_Code, itemsToLoan, total_Price); if (status == "Check your balance") { lbLoan_Status.Text = "Not enough balance !"; lbLoan_Status.ForeColor = Color.Red; List <string> items = new List <string>(); foreach (string item in lb_Receipt_info.Items) { items.Add(item); } foreach (string item in items) { lb_Receipt_info.SelectedItem = item; btnRemove.PerformClick(); } } else if (status == "There is no user") { lbLoan_Status.Text = "Invalid User !"; lbLoan_Status.ForeColor = Color.Red; List <string> items = new List <string>(); foreach (string item in lb_Receipt_info.Items) { items.Add(item); } foreach (string item in items) { lb_Receipt_info.SelectedItem = item; btnRemove.PerformClick(); } } else if (status == "added") { lblLoanStatus.Text = "Successfully Loaned!"; //MessageBox.Show("Successfully Loaned!"); lblLoanStatus.ForeColor = Color.Green; lb_Receipt_info.Items.Clear(); //MessageBox.Show(" sellected item has successfully loaned"); } else { // string status = dataHelper.LoanItemToVisitor(rfid_Code, itemsToLoan, total_Price); MessageBox.Show($"{status}"); lblLoanStatus.Text = "Something happened , please try again !"; lblLoanStatus.ForeColor = Color.Red; } lbRfid_Status.Text = ""; total_Price = 0; lbPrice.Text = ""; } else { lblLoanStatus.Text = "Please Scan the Visitor's RFID Chip first !"; lblLoanStatus.ForeColor = Color.Red; } } catch (Exception) { throw; } } }
private void btnRemove_Click(object sender, EventArgs e) { try { dataHelper = new Mysql(); if (lb_Receipt_info.SelectedItem.ToString() == "Bicycle - 20€") { lb_Receipt_info.Items.Remove(lb_Receipt_info.SelectedItem); if (bicycle_quantity < 0) { bicycle_quantity = 1; } else { bicycle_quantity++; } lbBicycleQuantity.Text = bicycle_quantity + "LEFT"; total_Price -= dataHelper.GetPrdouctPrice("Bicycle"); lbPrice.Text = total_Price.ToString() + "€"; } else if (lb_Receipt_info.SelectedItem.ToString() == "Googgles - 10€") { lb_Receipt_info.Items.Remove(lb_Receipt_info.SelectedItem); if (googles_quantiy < 0) { googles_quantiy = 1; } else { googles_quantiy++; } lbGogglesQuantity.Text = googles_quantiy + "LEFT"; total_Price -= dataHelper.GetPrdouctPrice("Googgles"); lbPrice.Text = total_Price.ToString() + "€"; } else if (lb_Receipt_info.SelectedItem.ToString() == "Camera - 20€") { lb_Receipt_info.Items.Remove(lb_Receipt_info.SelectedItem); if (camera_quantity < 0) { camera_quantity = 1; } else { camera_quantity++; } lbCameraQuantity.Text = camera_quantity + "LEFT"; total_Price -= dataHelper.GetPrdouctPrice("Camera"); lbPrice.Text = total_Price.ToString() + "€"; } else if (lb_Receipt_info.SelectedItem.ToString() == "Charger - 5€") { lb_Receipt_info.Items.Remove(lb_Receipt_info.SelectedItem); if (charger_quantity < 0) { charger_quantity = 1; } else { charger_quantity++; } lbchargrQuan.Text = charger_quantity + "LEFT"; total_Price -= dataHelper.GetPrdouctPrice("Charger"); lbPrice.Text = total_Price.ToString() + "€"; } } catch (NullReferenceException) { lbLoan_Status.Text = "Please first select the item you want to remove !"; lbLoan_Status.ForeColor = Color.Red; } }