using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Booking
{
public partial class MainForm : Form
{
private double revenue = 0.0;
private const int totalNumOfSeats = 240;
private int numOfReservedSeats = 0;
public MainForm()
{
InitializeComponent();
InitializeGUI();
}
private void InitializeGUI()
{
rbtnReserve.Checked = true;
lstSeats.Items.Clear();
txtName.Text = string.Empty;
}
private bool ReadAndValidateName(out string name)
{
name = "";
if (txtName.Text.Length > 0)
{
name = txtName.Text;
return true;
}
else
{
MessageBox.Show("Enter Letters Only", "Invalid Character", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtName.Focus();
return false;
}
}
private bool ReadAndValidatePrice(out double price)
{
price = 0;
double converted;
converted = Convert.ToDouble(txtPrice.Text);
if (converted >= 0.0)
{
price = Double.Parse(txtPrice.Text);
return true;
}
else
{
MessageBox.Show("Enter Numbers Only", "Invalid Character", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtPrice.Focus();
return false;
}
}
private bool ReadAndValidateInput(out string name ,out double price)
{
return ReadAndValidateName(out name) & ReadAndValidatePrice(out price);
}
private void label1_Click(object sender, EventArgs e)
{
}
private void groupBox2_Enter(object sender, EventArgs e)
{
}
private void txtPrice_TextChanged(object sender, EventArgs e)
{
}
private void btnOK_Click(object sender, EventArgs e)
{
string costumerName = string.Empty;
double seatPrice = 0.0;
bool inputOk = ReadAndValidateInput(out costumerName, out seatPrice);
if (inputOk)
{
numOfReservedSeats++;
revenue += seatPrice;
}
}
private void txtName_TextChanged(object sender, EventArgs e)
{
}
private void lstSeats_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void btnOK_Click_1(object sender, EventArgs e)
{
lstSeats.Items.Add(string.Format("\t\t{0} \t{1}",txtPrice.Text, txtName.Text));
}
private void txtPrice_TextChanged_1(object sender, EventArgs e)
{
}
private void rbtnReserve_CheckedChanged(object sender, EventArgs e)
{
txtName.Enabled = true;
txtPrice.Enabled = true;
btnOK.Enabled = true;
}
private void rbtnCancel_CheckedChanged(object sender, EventArgs e)
{
txtName.Enabled = false;
txtPrice.Enabled = false;
btnOK.Enabled = false;
}
}
}
Hello im a really noob when it com to windows form so i need same help to understand this. How do i get private bool ReadAndValidateName(out string name) and price in to the textboxes. do i need to use samething in to the private void btnOK_Click(object sender, EventArgs e) to get it do show the error message and so on?