-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTicketBookingForm.cs
88 lines (81 loc) · 3.1 KB
/
TicketBookingForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using BusReservationSystem.Classes;
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 BusReservationSystem
{
public partial class TicketBookingForm : Form
{
string bus_no;
string _availBus;
Dashboard _dashboard;
public TicketBookingForm(string no, string availBus, Dashboard d)
{
InitializeComponent();
bus_no = no;
_availBus = availBus;
_dashboard = d;
}
private void TicketBookingForm_Load(object sender, EventArgs e)
{
Bus bus = new Bus();
txtBusNo.Text = bus_no;
txtFrom.Text = LogInfo.user_counter;
txtTicketNo.Text = (bus.CountPessanger(bus_no) + 1).ToString();
lblAvailSeat.Text = "Out of " + _availBus;
cmbDestination.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
cmbDestination.AutoCompleteSource = AutoCompleteSource.ListItems;
cmbDestination.Items.Clear();
Account account = new Account();
cmbDestination.DataSource = bus.GetConters(bus_no);
cmbDestination.ValueMember = "name";
cmbDestination.DisplayMember = "name";
//cmbDestination.DropDownStyle = ComboBoxStyle.Simple;
}
private void BtnBookNow_Click(object sender, EventArgs e)
{
Passenger passenger = new Passenger();
passenger.bus_no = txtBusNo.Text;
passenger.counter = txtFrom.Text;
passenger.start_loc = txtFrom.Text;
passenger.end_loc = cmbDestination.Text;
passenger.full_name = txtFullName.Text;
passenger.phone_no = txtPhoneNo.Text;
/*passenger.seat_length = */int.TryParse(txtSeatLen.Text,out passenger.seat_length);
/*passenger.ticket_no = */int.TryParse(txtTicketNo.Text,out passenger.ticket_no);
if (txtFullName.Text != "" && txtPhoneNo.Text != "" && txtSeatLen.Text != "")
{
Bus bus = new Bus();
bool s = false;
if (MessageBox.Show("৳" + passenger.GetPrice().ToString(), "Price for U!", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
s = bus.SetPassenger(passenger);
}
if (s)
MessageBox.Show("Updated Successfully");
else
MessageBox.Show("Opps Something Worng!");
}
else
MessageBox.Show("Please Fill the form.");
_dashboard.RefreshGrid();
}
private void TicketBookingForm_FormClosing(object sender, FormClosingEventArgs e)
{
_dashboard.RefreshGrid();
}
private void BtnReset_Click(object sender, EventArgs e)
{
foreach (Control item in this.Controls)
{
if (item is TextBox && item.Enabled == true)
item.Text = string.Empty;
}
}
}
}