private void button5_Click(object sender, EventArgs e) { try { if (textBox1.Text == "") { MessageBox.Show("Please enter plate"); } customer c = new customer(); guest_add g = new guest_add(); string plate = textBox1.Text; DataTable t = g.learn_subtype(plate); string t2 = t.Rows[0]["sub_payment"].ToString(); if (t2 == "guest") { double hour; g.Date_out = DateTime.Now; string a = t.Rows[0]["date_in"].ToString(); DateTime d = DateTime.Parse(a.ToString()); TimeSpan tspn = g.Date_out - d; hour = double.Parse(tspn.TotalHours.ToString()); int pay = Convert.ToInt16(hour) * 5; textBox7.Text = pay.ToString() + "$"; c.PlateNo = textBox1.Text; c.exit_user(c.PlateNo); c.delete_customer(c.PlateNo); MessageBox.Show("Succesfully Exit"); } else { textBox7.Text = "Subscriber"; c.PlateNo = textBox1.Text; c.exit_user(c.PlateNo); MessageBox.Show("Succesfully Exit"); } textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox7.Text = ""; } catch (Exception ex) { MessageBox.Show("There is an error"); } }
private void button1_Click(object sender, EventArgs e) { int adition = 0; try { string plate = textBox1.Text; DateTime dateTime = DateTime.Now; guest_add g = new guest_add(); g.Date_in = dateTime; g.PlateNo = plate; adition = g.addguest(g); if (adition != 0) { MessageBox.Show("Succesfully added."); } } catch (Exception ex) { MessageBox.Show("There is An error!" + ex.Message); } }