-
Notifications
You must be signed in to change notification settings - Fork 0
/
vendorproduct.aspx.cs
175 lines (150 loc) · 6.26 KB
/
vendorproduct.aspx.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
public partial class Companies : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string connStr = ConfigurationManager.ConnectionStrings["MyDbConn"].ToString();
SqlConnection conn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("vendorviewProducts", conn);
cmd.CommandType = CommandType.StoredProcedure;
string username = (string)(Session["field1"]);
//pass parameters to the stored procedure
cmd.Parameters.Add(new SqlParameter("@vendorname", username));
conn.Open(); //we opened connection fast because
//IF the output is a table, then we can read the records one at a time
SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection); // its like buffer in java
while (rdr.Read())
{
//Get the value of the attribute name in the Company table
String serial_no ="";
int x1 = rdr.GetOrdinal("serial_no");
if (!rdr.IsDBNull(x1))
{
serial_no = (rdr.GetInt32(rdr.GetOrdinal("serial_no"))).ToString();
}
string productname = "";
int x2 = rdr.GetOrdinal("product_name");
if (!rdr.IsDBNull(x2))
{
productname = rdr.GetString(rdr.GetOrdinal("product_name"));
}
string cate = "";
int x3 = rdr.GetOrdinal("category");
if (!rdr.IsDBNull(x3))
{
cate = rdr.GetString(rdr.GetOrdinal("category"));
}
string descr = "";
int x4 = rdr.GetOrdinal("category");
if (!rdr.IsDBNull(x4))
{
descr = rdr.GetString(rdr.GetOrdinal("product_description"));
}
String price = "";
int x5 = rdr.GetOrdinal("price");
if (!rdr.IsDBNull(x5))
{
price = (rdr.GetDecimal(rdr.GetOrdinal("price"))).ToString();
}
String final_price = "";
int x6 = rdr.GetOrdinal("final_price");
if (!rdr.IsDBNull(x6))
{
final_price = (rdr.GetDecimal(rdr.GetOrdinal("final_price"))).ToString();
}
string color = "";
int x7 = rdr.GetOrdinal("color");
if (!rdr.IsDBNull(x7))
{
color = rdr.GetString(rdr.GetOrdinal("color"));
}
String available = "";
string available1 = "";
int xend = rdr.GetOrdinal("available");
if (!rdr.IsDBNull(xend))
{
available = (rdr.GetBoolean(rdr.GetOrdinal("available"))).ToString();
if (available=="True")
{
available1 = "1";
}
else
{
available1 = "0";
}
}
String rate = "";
int x9 = rdr.GetOrdinal("rate");
if (!rdr.IsDBNull(x9))
{
rate = (rdr.GetInt32(rdr.GetOrdinal("rate"))).ToString();
}
string vendor_username = rdr.GetString(rdr.GetOrdinal("vendor_username"));
int x8 = rdr.GetOrdinal("vendor_username");
if (!rdr.IsDBNull(x8))
{
vendor_username = rdr.GetString(rdr.GetOrdinal("vendor_username"));
}
String customer_username = "";
int x = rdr.GetOrdinal("customer_username");
if(!rdr.IsDBNull(x))
{
customer_username = rdr.GetString(rdr.GetOrdinal("customer_username"));
}
String customer_order_id = "";
int x11 = rdr.GetOrdinal("customer_order_id");
if (!rdr.IsDBNull(x11))
{
customer_order_id = (rdr.GetInt32(rdr.GetOrdinal("customer_order_id"))).ToString();
}
//Create a new label and add it to the HTML form
Label lbl_pname = new Label();
lbl_pname.Text ="productname->"+ productname + " , ";
form1.Controls.Add(lbl_pname);
Label lablser = new Label();
lablser.Text = "serialno->" + serial_no + " , ";
form1.Controls.Add(lablser);
Label lbl_cat = new Label();
lbl_cat.Text = "categ->" + cate + " , ";
form1.Controls.Add(lbl_cat);
Label lbl_price = new Label();
lbl_price.Text = "price->" + price + " , ";
form1.Controls.Add(lbl_price);
Label lbl_final = new Label();
lbl_final.Text = "final_price->" + final_price + " , ";
form1.Controls.Add(lbl_final);
Label lbl_color = new Label();
lbl_color.Text = "color->" + color + " , ";
form1.Controls.Add(lbl_color);
Label lbl_ava = new Label();
lbl_ava.Text = "available->" + available1 + " , ";
form1.Controls.Add(lbl_ava);
Label lbl_rate = new Label();
lbl_rate.Text = "rate->" + rate + " , ";
form1.Controls.Add(lbl_rate);
Label lbl_custuser = new Label();
lbl_custuser.Text = "customerusername->" + customer_username + " , ";
form1.Controls.Add(lbl_custuser);
Label lbl_custid = new Label();
lbl_custid.Text = "customer_order_id->" + customer_order_id + " , ";
form1.Controls.Add(lbl_custid);
Label lbl_vndrname = new Label();
lbl_vndrname.Text = "vendor_username->" + vendor_username + " , ";
form1.Controls.Add(lbl_vndrname);
Label lbl_desc = new Label();
lbl_desc.Text = " "+ "description->"+descr + " <br /> <br />"; // new line
form1.Controls.Add(lbl_desc);
}
//this is how you retrive data from session variable.
// string field1 = (string)(Session["field1"]); // type casting becuz seession array of objects
// Response.Write(field1);
}
}