-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSepetim.aspx.cs
More file actions
81 lines (80 loc) · 2.57 KB
/
Sepetim.aspx.cs
File metadata and controls
81 lines (80 loc) · 2.57 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;
public partial class Sepetim : System.Web.UI.Page
{
sepetkomutlar sk = new sepetkomutlar();
veritabani vt = new veritabani();
protected void Page_Load(object sender, EventArgs e)
{
if (Session["uye_ad"] == null)
{
Response.Redirect("default.aspx");
}
else
{
SepetGetir();
}
if (DataList1.Items.Count > 0)
{
Panel1.Visible = true;
}
else
{
Panel1.Visible = false;
}
}
int fiyat;
private void SepetGetir()
{
if (Session["sepet"] != null)
{
DataTable dt = new DataTable();
dt = (DataTable)Session["sepet"];
DataList1.DataSource = dt.DefaultView;
DataList1.DataBind();
lblToplam.Text = "Toplam : " + sk.SepetToplam().ToString() + " TL.";
}
}
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName.ToString() == "sil")
{
sk.Sil(e.CommandArgument.ToString());//yazdığımız sil methoduna o anki ürünün id değerini gönderiyoruz
SepetGetir();
}
}
protected void btn_siparis_Click(object sender, EventArgs e)
{
if (Session["uye_ad"] != null)
{
vt.baglan();
string uye_ad = Session["uye_ad"].ToString();
Button basilanButon = (Button)sender;
int ucret = Convert.ToInt32(sk.SepetToplam().ToString());
DataRow drKategori = vt.getDataRow("select * from uyeler where uye_ad ='" + uye_ad + "'");
string y = drKategori["uye_bakiye"].ToString();
int bakiye = Convert.ToInt32(y);
if (ucret <= bakiye)
{
int yenibakiye = bakiye - ucret;
vt.komut("update uyeler set uye_bakiye=" + yenibakiye + " where uye_ad ='" + uye_ad + "'");
double q = Convert.ToDouble(Session["uye_bakiye"].ToString());
Session["uye_bakiye"] = Convert.ToDouble(q - ucret);
Page.Response.Redirect(Page.Request.Url.ToString(), true);
SepetGetir();
}
else
{
lblUyari.Visible = true;
lblUyari.ForeColor = System.Drawing.Color.Red;
lblUyari.Text = "Yetersiz Bakiye!";
}
}
}
}