/
checkout.aspx.cs
115 lines (102 loc) · 3.63 KB
/
checkout.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using E3zmni.BLL;
using System.Data;
namespace E3zemni_WebGUI
{
public partial class checkout : System.Web.UI.Page
{
public int EnverlopID
{
get
{
if (Request.QueryString["eid"] != null)
{
try
{
return int.Parse(Request.QueryString["eid"].ToString());
}
catch (Exception ex)
{
return 0;
}
}
else
{
return 0;
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["UserPayment"] != null)
{
BindOrder();
Master.PageTitle = "Checkout";
Master.Path = "";
Master.ViewPath = true;
}
}
}
private void BindOrder()
{
UserPayement order = new UserPayement();
order = (UserPayement)Session["UserPayment"];
if (EnverlopID != 0)
{
order.EnvelopID = EnverlopID;
order.EnvelopCount = 1;
}
uiRepeaterOrder.DataSource = order.DefaultView;
uiRepeaterOrder.DataBind();
}
protected void uiRepeaterOrder_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
Image envelop = (Image)e.Item.FindControl("uiImageEnvelop");
DataRowView row = (DataRowView)e.Item.DataItem;
if (EnverlopID != 0)
{
Envelops envelopTemp = new Envelops();
envelopTemp.LoadByPrimaryKey(Convert.ToInt32(row["EnvelopID"].ToString()));
envelop.ImageUrl = envelopTemp.ImagePath;
}
}
}
protected void uiLinkButtonCheckout_Click(object sender, EventArgs e)
{
UserPayement order = new UserPayement();
order = (UserPayement)Session["UserPayment"];
foreach (RepeaterItem dli in uiRepeaterOrder.Items)
{
if (dli.ItemType == ListItemType.Item || dli.ItemType == ListItemType.AlternatingItem)
{
TextBox CQty = (TextBox)dli.FindControl("uiTextBoxQty");
TextBox EQty = (TextBox)dli.FindControl("uiTextBoxQty");
order.EnvelopCount = !string.IsNullOrEmpty(EQty.Text) ? Convert.ToInt32(EQty.Text) : 0;
order.CardCount = !string.IsNullOrEmpty(CQty.Text) ? Convert.ToInt32(CQty.Text) : 0;
}
}
Session["UserPayment"] = order;
if (Session["CurrentUser"] != null)
{
UserInfo user = (UserInfo)Session["CurrentUser"];
order.UserID = user.UserID;
order.Save();
Session["UserPayment"] = null;
Response.Redirect("~/browse.aspx");
}
else
{
Response.Redirect("~/login.aspx?url=checkout.aspx");
}
}
}
}