-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransport.cs
214 lines (201 loc) · 9.33 KB
/
Transport.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
namespace Transport_Management_System
{
class Transport
{
public string DriverName;
public string customerName;
public string customerEmail;
public SqlConnection con;
public SqlCommand cmd;
public SqlDataAdapter adpt;
public DataTable dt;
public Transport(string Con_String)
{
con = new SqlConnection(Con_String);
}
public void signup(string first, string last, string email, string pass, string confpass)
{
con.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO RegistrationForm (First_Name,Last_Name,Email,Pass_Word,Confirm_Password)values(@first,@last,@email,@pass,@confpass)", con);
cmd.Parameters.AddWithValue("@first", first);
cmd.Parameters.AddWithValue("@last", last);
cmd.Parameters.AddWithValue("@email", email);
cmd.Parameters.AddWithValue("@pass", pass);
cmd.Parameters.AddWithValue("@confpass", confpass);
cmd.ExecuteNonQuery();
con.Close();
}
public void Logins(string email, string password)
{
con.Open();
adpt = new SqlDataAdapter("SELECT Email ,Pass_Word FROM RegistrationForm where Email = '" + email + "' and Pass_Word ='" + password + "'", con);
DataTable dt = new DataTable();
adpt.Fill(dt);
if (dt.Rows.Count > 0)
{
MessageBox.Show("Login successfuly", "Login", MessageBoxButtons.OK, MessageBoxIcon.Information);
Login_Form.log = true;
}
else
{
MessageBox.Show("Email or pass is incorrect!");
Login_Form.log = false;
}
con.Close();
}
}
class TransportInfomation : Transport
{
private string slipNo;
private string Date;
private string Factory;
private string VehicalNo;
public string typesofMaterial;
public string transportAmount;
public string AmountPaid;
public TransportInfomation(string Con_String) :base(Con_String)
{
}
public DataTable DisplayData()
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
dt = new DataTable();
adpt = new SqlDataAdapter();
cmd.CommandText = "select * from transportinformation";
cmd.ExecuteNonQuery();
adpt = new SqlDataAdapter(cmd);
adpt.Fill(dt);
con.Close();
return dt;
}
public void Insert(string slip,string date,string factory,string vehicNo,string Material,string driverN,string customerN,string custemail,string tranpAmount,string amountpaid)
{
slipNo = slip;
Date = date;
Factory = factory;
VehicalNo = vehicNo;
typesofMaterial = Material;
DriverName = driverN;
customerName = customerN;
customerEmail = custemail;
transportAmount = tranpAmount;
AmountPaid = amountpaid;
if (slipNo != "" && Date != "" && Factory != "" && VehicalNo != "" && typesofMaterial != "" && DriverName != "" && customerName != "" && customerEmail != "" && transportAmount != "" && AmountPaid != "")
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into transportinformation values('" + slipNo + "','" + Date + "','" + Factory + "','" + VehicalNo + "','" + typesofMaterial + "','" + DriverName + "','" + customerName + "','" + customerEmail + "','" + transportAmount + "','" + AmountPaid + "')";
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Inserted Data ","Successfully",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Please Provide Data","Unsuccessfully",MessageBoxButtons.RetryCancel,MessageBoxIcon.Error);
}
}
public void Update(string slip, string date, string factory, string vehicNo, string Material, string driverN, string customerN, string custemail, string tranpAmount, string amountpaid)
{
slipNo = slip;
Date = date;
Factory = factory;
VehicalNo = vehicNo;
typesofMaterial = Material;
DriverName = driverN;
customerName = customerN;
customerEmail = custemail;
transportAmount = tranpAmount;
AmountPaid = amountpaid;
if (slipNo != "" && Date != "" && Factory != "" && VehicalNo != "" && typesofMaterial != "" && DriverName != "" && customerName != "" && customerEmail != "" && transportAmount != "" && AmountPaid != "")
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "update transportinformation set slipNo='"+slipNo+"',date_d='"+Date+"',factory='"+Factory+"',vehicalNo='"+VehicalNo+"',typesoftransp='"+typesofMaterial+"',driverName='"+DriverName+"',customerName='"+customerName+"',customerEmail='"+customerEmail+"',transportAmount='"+transportAmount+"',amount_paid='"+AmountPaid+"' where slipNo='"+slipNo+"'";
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Updated Data ", "Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Please Provide Data", "Unsuccessfully", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
}
}
public void DeleteData(string slip, string date, string factory, string vehicNo, string Material, string driverN, string customerN, string custemail, string tranpAmount, string amountpaid)
{
slipNo = slip;
Date = date;
Factory = factory;
VehicalNo = vehicNo;
typesofMaterial = Material;
DriverName = driverN;
customerName = customerN;
customerEmail = custemail;
transportAmount = tranpAmount;
AmountPaid = amountpaid;
if (slipNo != "" && Date != "" && Factory != "" && VehicalNo != "" && typesofMaterial != "" && DriverName != "" && customerName != "" && customerEmail != "" && transportAmount != "" && AmountPaid != "")
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "delete from transportinformation where slipNo='" + slipNo + "'";
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Deleted Data ", "Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Please Provide Data", "Unsuccessfully", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
}
}
}
class TransportExpenses : Transport
{
private string date;
private string VehicalNo;
private string DriverWages;
private string Diesel;
private string Punchar;
private string Oil;
private string RoadToken;
private string Repair;
public TransportExpenses(string Con_String) :base(Con_String)
{
}
public void ExpensesData(string da, string v, string dri, string die, string pun, string O, string tok, string rep)
{
date = da;
VehicalNo = v;
DriverWages = dri;
Diesel = die;
Punchar = pun;
Oil = O;
RoadToken = tok;
Repair = rep;
if (date != "" && VehicalNo != "" && DriverWages != "" && Diesel != "" && Punchar != "" && Oil != "" && RoadToken != "" && Repair != "")
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into TransportExpenses values('" + date + "','" + VehicalNo + "','" + DriverWages + "','" + Diesel + "','" + Punchar + "','" + Oil + "','" + RoadToken + "','" + Repair +"')";
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Save Data ", "Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Please Provide Data", "Unsuccessfully", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
}
}
}
}