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
| using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class YourOrder : System.Web.UI.Page
{
private SqlConnection sqlConnection = null;
protected async void Page_Load(object sender, EventArgs e)
{
string connectionString = ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;
sqlConnection = new SqlConnection(connectionString);
await sqlConnection.OpenAsync();
HttpCookie login = Request.Cookies["login"];
HttpCookie sign = Request.Cookies["sign"];
HttpCookie signrule = Request.Cookies["signrule"];
HttpCookie rulecookie = Request.Cookies["rulecookie"];
HttpCookie id = Request.Cookies["id"];
HttpCookie signid = Request.Cookies["signid"];
if (login != null && sign != null)
{
if (sign.Value == SignGenerator.GetSign(login.Value + "bytepp") && signrule.Value == SignGenerator.GetSign(rulecookie.Value + "bytepp") /*&& signid.Value == SignGenerator.GetSign(id.Value + "bytepp")*/)
{
SqlCommand UserID = new SqlCommand("SELECT [id] FROM [Drivers] WHERE [login] ='" + login.Value + "'", sqlConnection);
int userid = Convert.ToInt32(UserID.ExecuteScalar());
SqlCommand CarCount = new SqlCommand("SELECT COUNT(*) FROM [Orders] WHERE [driver] = " + userid, sqlConnection);
int count = Convert.ToInt32(CarCount.ExecuteScalar());
if (count == 0)
{
Response.Redirect("TakeOrder.aspx");
}
else
{
SqlDataReader OrderReader = null;
SqlCommand GetCarcmd = new SqlCommand("SELECT * FROM [Orders] WHERE [driver]=" + userid, sqlConnection);
OrderReader = await GetCarcmd.ExecuteReaderAsync();
while (await OrderReader.ReadAsync())
{
Label6.Text = OrderReader["id"].ToString();
Label8.Text = OrderReader["wherepoint"].ToString();
Label9.Text = OrderReader["frompoint"].ToString();
//////////////////////////////////////////////////
}
OrderReader.Close();
SqlCommand OrderCount = new SqlCommand("SELECT COUNT(*) FROM [Status] WHERE [orderid] = " + Convert.ToInt32(Label6.Text), sqlConnection);
int ordercount = Convert.ToInt32(CarCount.ExecuteScalar());
SqlCommand GetOrder = new SqlCommand("SELECT * FROM [StatusView] WHERE [orderid]=" + Convert.ToInt32(Label6.Text), sqlConnection);
SqlDataReader r = null;
r = GetOrder.ExecuteReader();
while (r.Read())
{
string[] OrderList = new string[ordercount];
for (int i = 1; i <= ordercount; i++)
{
OrderList[i - 1] = r.GetString(0);
}
for (int i = 0; i < OrderList.Length; i++)
{
ListBox1.Items.Add(OrderList[i].ToString());
}
}
r.Close();
SqlCommand cmd = new SqlCommand("SELECT * FROM [Statustable]", sqlConnection);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
DropDownList1.DataTextField = "name";
DropDownList1.DataValueField = "id";
DropDownList1.DataSource = dt;
DropDownList1.DataBind();
}
return;
}
}
Response.Redirect("~/LoginSite.aspx", false);
}
protected async void Button1_Click(object sender, EventArgs e)
{
//UserID = new SqlCommand("SELECT [id] FROM [Drivers] WHERE [login] = '" + login.Value + "'", sqlConnection);
//userid = Convert.ToInt32(UserID.ExecuteScalar());
SqlCommand statid = new SqlCommand("SELECT [id] FROM [Statustable] WHERE [name] = '"+ DropDownList1.SelectedItem +"'", sqlConnection);
int status = Convert.ToInt32(statid.ExecuteScalar());
SqlCommand regcar = new SqlCommand("INSERT INTO [Statuses] (status, time, orderid) VALUES (@status, @time, @orderid)", sqlConnection);
regcar.Parameters.AddWithValue("status", status);
regcar.Parameters.AddWithValue("orderid", Label6.Text.ToString());
regcar.Parameters.AddWithValue("time", DateTime.Now.ToString("dd MMMM yyyy | HH:mm:ss"));
await regcar.ExecuteNonQueryAsync();
Response.Redirect("YourOrder.aspx", false);
}
} |