-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm11.cs
More file actions
80 lines (62 loc) · 2.36 KB
/
Copy pathForm11.cs
File metadata and controls
80 lines (62 loc) · 2.36 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FlightReservation
{
public partial class Form11 : Form
{
public Form11()
{
InitializeComponent();
button1.Click += button1_Click;
button2.Click += button2_Click;
}
private void button1_Click(object sender, EventArgs e)
{
Form13 form13 = new Form13();
form13.Show();
this.Hide();
}
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 = "UPDATE User_ SET UserID = @UserID, Fname = @Fname,Lname =@Lname,PassportNum=@PassportNum,phone=@phone WHERE UserID = @UserID";
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);
MessageBox.Show("Executing Query...");
int rowsAffected = command.ExecuteNonQuery();
if (rowsAffected > 0)
{
MessageBox.Show("Update Details Successfully!");
}
else
{
MessageBox.Show("No Details updated!");
}
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}
}
}
}
}