-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDefault.aspx.cs
125 lines (96 loc) · 3.37 KB
/
Default.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Domain;
using Access;
using AccessBd;
using System.Security.Cryptography.X509Certificates;
namespace SalesSystem
{
public partial class _Default : Page
{
//the list has to be a property of the page to be accessed from the aspx
public List<Article> list { get; set; }
public int IdArticle { get; set; }
public void refreshList()
{
ArticleAccess access = new ArticleAccess();
list = access.listArticle();
Session.Add("listarticle", list);
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
refreshList();
if (Request.QueryString["IdFav"] != null)
{
FavoritesAccess fAccess = new FavoritesAccess();
Users user = (Users)Session["user"];
int idart = int.Parse(Request.QueryString["idFav"].ToString());
fAccess.AddFavorite(user.Id, idart);
}
}
else
{
refreshList();
}
}
protected void chkfilter_CheckedChanged(object sender, EventArgs e)
{
txtsearch.Enabled = !chkfilter.Checked;
ArticleAccess access = new ArticleAccess();
list = access.listArticle();
//probably here is the problem
if (chkfilter.Checked)
{
if (ddlby.Text == "Brand")
{
ddlCritery.Items.Add("Starts with : ");
ddlCritery.Items.Add("Ends with : ");
ddlCritery.Items.Add("Contains : ");
}
}
}
protected void txtsearch_TextChanged(object sender, EventArgs e)
{
list = (List<Article>)Session["listarticle"];
list = list.FindAll(x => x.Name.ToUpper().Contains(txtsearch.Text.ToUpper()) ||
x.Description.ToUpper().Contains(txtsearch.Text.ToUpper()));
}
protected void ddlby_SelectedIndexChanged(object sender, EventArgs e)
{
ddlCritery.Items.Clear();
if (ddlby.SelectedItem.ToString() == "Price")
{
ddlCritery.Items.Add("Less than : ");
ddlCritery.Items.Add("Equals to : ");
ddlCritery.Items.Add("More than : ");
}
else
{
ddlCritery.Items.Add("Starts with : ");
ddlCritery.Items.Add("Ends with : ");
ddlCritery.Items.Add("Contains : ");
}
}
protected void btnsearchAdvanced_Click(object sender, EventArgs e)
{
try
{
ArticleAccess access = new ArticleAccess();
list = (List<Article>)Session["listarticle"];
list = access.filter(ddlby.SelectedItem.ToString(), ddlCritery.SelectedItem.ToString(), txtFilterAdvanced.Text);
Session.Add("listarticle", list);
}
catch (Exception ex)
{
Session.Add("error", ex);
Response.Redirect("error.aspx", false);
}
}
}
}