-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
98 lines (76 loc) · 2.98 KB
/
Copy pathForm1.cs
File metadata and controls
98 lines (76 loc) · 2.98 KB
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
89
90
91
92
93
94
95
96
97
98
using System.Data.SqlClient;
namespace FlightReservation
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
button1.Click += button1_Click;
button2.Click += button2_Click;
button3.Click += button3_Click;
}
private void button2_Click(object sender, EventArgs e)
{
string connString = "Server=Eng-SHAHD; Database=FlightReservation; Integrated Security=True;";
using (SqlConnection conn = new SqlConnection(connString))
{
try
{
conn.Open();
Console.WriteLine("Connected");
MessageBox.Show("Connection Successful...");
string sqlQueryInsert = "INSERT INTO User_ (UserID , Fname , Lname ,PassportNum,phone,Passenger,Admin_) " +
" VALUES (@UserID, @Fname,@Lname,@PassportNum,@phone,@Passenger,@Admin_ )";
SqlCommand command = new SqlCommand(sqlQueryInsert, conn);
command.Parameters.AddWithValue("@UserID", Convert.ToInt32(textBox2.Text));
command.Parameters.AddWithValue("@Fname", textBox3.Text);
command.Parameters.AddWithValue("@Lname", textBox4.Text);
command.Parameters.AddWithValue("@PassportNum", textBox5.Text);
command.Parameters.AddWithValue("@phone", textBox6.Text);
command.Parameters.AddWithValue("@Passenger", radioButton2.Checked ? "1" : "0");
command.Parameters.AddWithValue("@Admin_", radioButton1.Checked ? "1" : "0");
MessageBox.Show("Executing Query...");
int rowsAffected = command.ExecuteNonQuery();
if (rowsAffected > 0)
{
MessageBox.Show("SignUp Successfully!");
}
else
{
MessageBox.Show("Fail To SignUp!");
}
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}
}
}
private void button1_Click(object sender, EventArgs e)
{
if (radioButton2.Checked) {
Form13 form13 = new Form13();
form13.Show();
this.Hide();
}
else
{
MessageBox.Show("Sorry! Not Allow For You!");
}
}
private void button3_Click(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
Form12 form12 = new Form12();
form12.Show();
this.Hide();
}
else
{
MessageBox.Show("Sorry! Not Allow For You!");
}
}
}
}