/
Directory.aspx.cs
174 lines (158 loc) · 5.83 KB
/
Directory.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
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GlobalLogistics.BLL;
using System.Data;
namespace GlobalLogistics.WebSite.Arabic
{
public partial class Directory : System.Web.UI.Page
{
public int PageIndex
{
get
{
object o = this.ViewState["_CurrentPage"];
if (o == null)
return 0;
else
return (int)o;
}
set
{
this.ViewState["_CurrentPage"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
}
private void BindData()
{
int catid = 0;
if (Request.QueryString["cid"] != null)
{
try
{
catid = Convert.ToInt32(Request.QueryString["cid"].ToString());
}
catch (Exception ex)
{
catid = 0;
}
}
int subcatid = 0;
if (Request.QueryString["scid"] != null)
{
try
{
subcatid = Convert.ToInt32(Request.QueryString["scid"].ToString());
}
catch (Exception ex)
{
subcatid = 0;
}
}
string searchfor = "";
if (Request.QueryString["f"] != null)
{
try
{
searchfor = Request.QueryString["f"].ToString();
}
catch (Exception ex)
{
searchfor = "";
}
}
PagedDataSource dt = new PagedDataSource();
Companies objData = new Companies();
if(!string.IsNullOrEmpty(searchfor ) && searchfor == "sh")
objData.SearchCompaniesForShipping(subcatid);
else if (!string.IsNullOrEmpty(searchfor) && searchfor == "off")
{
objData.SearchCompaniesForOffers(catid, subcatid);
}
else
{
objData.SearchCompanies("", 0, catid, subcatid);
}
Categories cat = new Categories();
cat.LoadByPrimaryKey(catid);
SubCategories subcat = new SubCategories();
subcat.LoadByPrimaryKey(subcatid);
dt.DataSource = objData.DefaultView;
dt.AllowPaging = true;
dt.PageSize = 10;
dt.CurrentPageIndex = PageIndex;
if (objData.RowCount > 0 && dt != null)
{
if (cat.RowCount > 0)
uiLabelTitle.Text = " - " + cat.ArName;
if (subcat.RowCount > 0)
uiLabelTitle.Text += " -> " + subcat.ArName;
uiRepeaterResults.DataSource = dt;
uiRepeaterResults.DataBind();
uiLinkButtonPrev.Enabled = !dt.IsFirstPage;
uiLinkButtonNext.Enabled = !dt.IsLastPage;
uiLabelPages.Text = "صفحة " + (PageIndex + 1).ToString() + " من " + dt.PageCount.ToString() + " صفحات";
uiPanelNoResults.Visible = false;
uiPanelResults.Visible = true;
}
else
{
uiPanelNoResults.Visible = true;
uiPanelResults.Visible = false;
}
}
protected void uiRepeaterResults_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DataRowView row = (DataRowView)e.Item.DataItem;
Label cityname = (Label)e.Item.FindControl("uiLabelCityName");
Cities city = new Cities();
city.LoadByPrimaryKey(Convert.ToInt32(row["CityID"].ToString()));
cityname.Text = city.ArName;
HyperLink linkName = (HyperLink)e.Item.FindControl("CompanyLink");
linkName.NavigateUrl = "CompanyProfile.aspx?cid=" + row["CompanyID"].ToString();
System.Web.UI.HtmlControls.HtmlGenericControl Name = (System.Web.UI.HtmlControls.HtmlGenericControl)e.Item.FindControl("CompanyName");
System.Web.UI.HtmlControls.HtmlGenericControl offersDiv = (System.Web.UI.HtmlControls.HtmlGenericControl)e.Item.FindControl("OffersDiv");
Services ser = new Services();
ser.GetServicesByCompanyIDAndTypeID(Convert.ToInt32(row["CompanyID"].ToString()), 1);
if (ser.RowCount > 0)
{
offersDiv.Visible = true;
}
else
{
offersDiv.Visible = false;
}
if (!string.IsNullOrEmpty(row["PackageTypeID"].ToString()) && row["PackageTypeID"].ToString() != "1")
{
linkName.Visible = true;
Name.Visible = false;
}
else
{
linkName.Visible = false;
Name.Visible = true;
}
}
}
protected void uiLinkButtonPrev_Click(object sender, EventArgs e)
{
PageIndex -= 1;
BindData();
}
protected void uiLinkButtonNext_Click(object sender, EventArgs e)
{
PageIndex += 1;
BindData();
}
}
}