-
Notifications
You must be signed in to change notification settings - Fork 1
/
Route_Front_End.cs
101 lines (87 loc) · 3.38 KB
/
Route_Front_End.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
89
90
91
92
93
94
95
96
97
98
99
100
101
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace OOP_Front_End
{
public partial class Route_Front_End : Form
{
Route rt = new Route();
public Route_Front_End()
{
InitializeComponent();
}
private void Route_Front_End_Load(object sender, EventArgs e)
{
}
private void textBoxrtid_TextChanged(object sender, EventArgs e)
{
}
private void textBoxrid_TextChanged(object sender, EventArgs e)
{
rt.Route_id = textBoxrid.Text;
}
public void ridfun()
{
string rid = textBoxrid.Text;
Console.WriteLine(rid);
}
private void button1_Click(object sender, EventArgs e)
{
//string dbconnect = "datasource=localhost; username=root; password=; database = oop";
MySqlConnection con = new MySqlConnection("datasource=localhost; username=root; password=; database = oop");
string insertquery = "Insert into oop.route(r_id,stay_time,Des_rt_dis) VALUES('" +rt.Route_id + "','" + rt.Stay_time + "','" + rt.Distance + "') ;";
// string insertquery = ("Insert into umt.info() VALUES(" +textBoxpname.Text + "," + textBoxaddress+ ","+textBoxcnic.Text+","+textBoxage.Text+","+textBoxcionfo.Text+","+comboboxmalefemale.Text+","+textBoxticketno.Text+","+textBoxnoofpassengers.Text+","+textBoxpaymebt.Text+","+textBoxpassport.Text+","+textBoxemail.Text+")");
con.Open();
MySqlCommand comm = new MySqlCommand(insertquery, con);
if (comm.ExecuteNonQuery() == 1)
{
MessageBox.Show("Data Inserted");
}
else
{
MessageBox.Show("Not Inserted");
}
con.Close();
// ridfun();
// Admin_Res ads = new Admin_Res();
//ads.Show();
}
private void textBoxstaytime_TextChanged(object sender, EventArgs e)
{
rt.Stay_time = textBoxstaytime.Text;
}
private void textBoxdistance_TextChanged(object sender, EventArgs e)
{
rt.Distance = textBoxdistance.Text;
}
private void Delete_Click(object sender, EventArgs e)
{
try
{
string MyConnection2 = "datasource=localhost; username=root; password=; database = oop";
string Query = "delete from route where r_id='" + this.textBoxrid.Text + "';";
MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2);
MySqlDataReader MyReader2;
MyConn2.Open();
MyReader2 = MyCommand2.ExecuteReader();
MessageBox.Show("Data Deleted");
while (MyReader2.Read())
{
}
MyConn2.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}