Need help in getting the value inputed in the text box to work for if-else.
I also program that the textbox will only alow numeric characters.
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 OrderingSystem
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
hidemenu();
}
private void hidemenu()
{
panelpayment.Visible = false;
}
private void showmenu(Panel subMenu)
{
if (subMenu.Visible == false)
{
hidemenu();
subMenu.Visible = true;
btnAdd1.Enabled = false;
btnAdd2.Enabled = false;
btnAdd3.Enabled = false;
btnAdd4.Enabled = false;
btnAdd5.Enabled = false;
btnAdd6.Enabled = false;
btnAdd7.Enabled = false;
btnAdd8.Enabled = false;
}
else
subMenu.Visible = false;
}
public void totalPrice()
{
int sum = 0;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
sum += Convert.ToInt32(dataGridView1.Rows[i].Cells[2].Value);
}
lblTotal.Text = "₱" + sum.ToString();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void btnAdd1_Click(object sender, EventArgs e)
{
int a = 75;
decimal b = numq1.Value;
decimal price;
price = a * b;
dataGridView1.Rows.Add(b, "1pcs ChickenJoy", price);
totalPrice();
}
private void btnAdd2_Click(object sender, EventArgs e)
{
int a = 50;
decimal b = numq2.Value;
decimal price;
price = a * b;
dataGridView1.Rows.Add(b, "1pcs Burger Stake", price);
totalPrice();
}
private void btnAdd3_Click(object sender, EventArgs e)
{
int a = 33;
decimal b = numq3.Value;
decimal price;
price = a * b;
dataGridView1.Rows.Add(b, "1pcs Burger", price);
totalPrice();
}
private void btnAdd4_Click(object sender, EventArgs e)
{
int a = 40;
decimal b = numq4.Value;
decimal price;
price = a * b;
dataGridView1.Rows.Add(b, "1pc Jolly Crispy Fries", price);
totalPrice();
}
private void btnAdd5_Click(object sender, EventArgs e)
{
int a = 30;
decimal b = numq5.Value;
decimal price;
price = a * b;
dataGridView1.Rows.Add(b, "Peach Mego Pie", price);
totalPrice();
}
private void btnAdd6_Click(object sender, EventArgs e)
{
int a = 27;
decimal b = numq6.Value;
decimal price;
price = a * b;
dataGridView1.Rows.Add(b, "Coke Float", price);
totalPrice();
}
private void btnAdd7_Click(object sender, EventArgs e)
{
int a = 53;
decimal b = numq7.Value;
decimal price;
price = a * b;
dataGridView1.Rows.Add(b, "Jolly Spagetti", price);
totalPrice();
}
private void btnAdd8_Click(object sender, EventArgs e)
{
int a = 29;
decimal b = numq8.Value;
decimal price;
price = a * b;
dataGridView1.Rows.Add(b, "Sundae", price);
totalPrice();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
string cname = dataGridView1.Columns[e.ColumnIndex].Name;
if (cname == "delete")
{
int rowIndex = dataGridView1.CurrentCell.RowIndex;
dataGridView1.Rows.RemoveAt(rowIndex);
totalPrice();
}
}
private void button1_Click(object sender, EventArgs e)
{
showmenu(panelpayment);
}
private void confirmpayment_Click(object sender, EventArgs e)
{
// button to check the payment
// textbox to if loop ????
bool money = bool.Parse(textBox1.Text);
if (money > lblTotal.Text)
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && (e.KeyChar != '.'))
{
e.Handled = true;
}
if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1))
{
e.Handled = true;
}
}
}
}