protected void btnThanhToan_Click(object sender, EventArgs e) { if (rdoNgay.Checked) { double amountVND = Convert.ToDouble(Session["Total"]); string itemInfo = "Cart Item"; string name = "hb"; string phone = "01688469370"; string email = "*****@*****.**"; string currency = "USD"; PayWithPayPal(amountVND.ToString(), itemInfo, name, phone, email, currency); } else { if (Session["CurCus"] != null) { Customer c = (Customer)Session["CurCus"]; Order O = new Order(); O.CustomerID = c.CustomerID; O.DateBuy = DateTime.Now; O.EmployeeID = null; O.Status = 1; O.Payments = "Thanh toan ngay"; helpers.cCart cart = CurrentContext.getCart(); foreach (helpers.cCartItem item in cart.Items) { Product p = db.Products.SingleOrDefault(q => q.ProductID == item.ProID); OrderDetail del = new OrderDetail(); del.ProductID = p.ProductID; del.Quantity = item.Quantity; del.UnitPrice = p.UnitPrice; del.TotalMoney = Convert.ToDouble(del.Quantity * del.UnitPrice); O.OrderDetails.Add(del); } O.TotalMoney = O.OrderDetails.Sum(m => m.TotalMoney); db.Orders.Add(O); db.SaveChanges(); cart.Items.Clear(); Response.Redirect("~/Default.aspx?sucess=1"); } } }
protected void txtAddToCart_ServerClick(object sender, EventArgs e) { if (CurrentContext.IsLogged()) { int proID = Convert.ToInt32(Request.QueryString["procID"]); cCartItem cartItem = new cCartItem() { ProID = proID, Quantity = Convert.ToInt32(txtQuantity.Value) }; CurrentContext.getCart().Add(cartItem); ((Site)this.Master).updateLinkCart(); } else { string url = "~/Login.aspx?retUrl=Product-details.aspx?procID=" + Request.QueryString["procID"]; Response.Redirect(url); } }
protected void Page_Load(object sender, EventArgs e) { if (CurrentContext.IsLogged()) { pnLogged.Visible = true; pnNotLogged.Visible = false; if (CurrentContext.getCustomer() != null) { lnkUserName.Text = string.Format("<i class='fa fa-user'></i><b>{0}</b>", CurrentContext.getCustomer().FullName); } else if (CurrentContext.getEmployee() != null) { lnkUserName.Text = string.Format("<i class='fa fa-user'></i><b>{0}</b>", CurrentContext.getEmployee().FullName); } else { lnkUserName.Text = string.Format("<i class='fa fa-user'></i><b>{0}</b>", CurrentContext.getAdmin()); } updateLinkCart(); } else { pnLogged.Visible = false; pnNotLogged.Visible = true; } if (!IsPostBack) { cbbChoose.DataSource = db.Suppliers.ToList(); cbbChoose.DataTextField = "CompanyName"; cbbChoose.DataValueField = "SupplierID"; cbbChoose.DataBind(); cbbChoose.Items.Insert(0, new ListItem("- -Nhà sản xuất- -", "0")); } }
protected void Page_Load(object sender, EventArgs e) { if (!CurrentContext.IsLogged()) { if (Request.QueryString["email"] != null && Request.QueryString["pass"] != null) { string email = Request.QueryString["email"]; string pass = Request.QueryString["pass"]; Account account = db.Accounts.SingleOrDefault(acc => acc.UserName.Equals(email)); if (account != null) { string pMD5 = helpers.StringUltils.MD5(pass); account.PassWord = pMD5; db.SaveChanges(); } } else { Response.Redirect("~/Default.aspx"); } } }
public void updateLinkCart() { lnkCart.Text = string.Format("<i class='fa fa-shopping-cart'></i>{0}", CurrentContext.getCart().getCountItems()); }
protected void btnLogout_Click(object sender, EventArgs e) { CurrentContext.desTroy(); Response.Redirect(Request.Url.AbsoluteUri); }