protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["ProductInCart"] != null) { ManagerCart = (ManagerProcart)Session["ProductInCart"]; } try { string id = Request.QueryString["id"].ToString(); string type = Request.QueryString["type"].ToString(); if (type.Equals("1") || type.Equals("3") || type.Equals("4")) { if (id.Length > 0) { ProductSystem Product = new ProductSystem(); DataSet ds = Product.ProductToCart(id,""); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { proIncart.type = int.Parse(type); proIncart.name = ds.Tables[0].Rows[0]["Name"].ToString() + " " + ds.Tables[0].Rows[0]["state"].ToString(); proIncart.urlImage = ds.Tables[0].Rows[0]["UrlImage"].ToString(); string strPrice = ds.Tables[0].Rows[0]["SellingPrice"].ToString(); if (strPrice.Length > 0) { proIncart.price = float.Parse(strPrice); } string strwarranty = ds.Tables[0].Rows[0]["WarrantyMonth"].ToString(); if (strwarranty.Length > 0) { proIncart.warranty = int.Parse(strwarranty); } proIncart.id = int.Parse(id); proIncart.number = 1; proIncart.currency = ds.Tables[0].Rows[0]["currency"].ToString(); proIncart.rate = float.Parse(ds.Tables[0].Rows[0]["rate"].ToString()); proIncart.setTotal(); ManagerCart.AddNewPro(proIncart); Session["ProductInCart"] = ManagerCart; } } } } else if(type.Equals("2")) { //add component: ComponentProductSystem Compoent = new ComponentProductSystem(); DataSet ds = Compoent.ComponenttoCart(id, Application["idtypeproduct"].ToString()); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { proIncart.type = 2; proIncart.name = ds.Tables[0].Rows[0]["Name"].ToString(); proIncart.urlImage = ds.Tables[0].Rows[0]["UrlImage"].ToString(); string strPrice = ds.Tables[0].Rows[0]["SellingPrice"].ToString(); if (strPrice.Length > 0) { proIncart.price = float.Parse(strPrice); } string strwarranty = ds.Tables[0].Rows[0]["WarrantyMonth"].ToString(); if (strwarranty.Length > 0) { proIncart.warranty = int.Parse(strwarranty); } proIncart.id = int.Parse(id); proIncart.number = 1; proIncart.currency = ds.Tables[0].Rows[0]["currency"].ToString(); proIncart.rate = float.Parse(ds.Tables[0].Rows[0]["rate"].ToString()); proIncart.setTotal(); ManagerCart.AddNewPro(proIncart); Session["ProductInCart"] = ManagerCart; } } } else if (type.Equals("11") || type.Equals("13") || type.Equals("14")) { //delete product: if (id.Length > 0) { proIncart.id = int.Parse(id); if (type.Equals("11")) { proIncart.type = 1; } else if(type.Equals("13")) { proIncart.type = 3; } else if (type.Equals("14")) { proIncart.type = 4; } ManagerCart.DeletePro(proIncart); Session["ProductInCart"] = ManagerCart; } } else if (type.Equals("12")) { //delete com: if (id.Length > 0) { proIncart.id = int.Parse(id); proIncart.type = 2; ManagerCart.DeletePro(proIncart); Session["ProductInCart"] = ManagerCart; } } } catch { } } Response.Redirect("Default.aspx?menu=shoppingcart"); }
protected void Page_Load(object sender, EventArgs e) { if (Session["ProductInCart"] != null) { ManagerCart = (ManagerProcart)Session["ProductInCart"]; } if (ManagerCart.getLengList() > 0) { } else { Response.Redirect("?menu=shoppingcart"); } //Getlang: try { currentAccess += ": <a href='?menu=home'>" + lhome + "</a> » " + tblOrder; } catch { } plhTop.Controls.Add(Page.LoadControl("block/ShoppingCart.ascx")); if (Session["infoUser"] != null) { tmessageinfo = "Xin bạy hãy chỉnh sửa thông tin liên hệ, nếu cần thiết"; } if (!IsPostBack) { divErrors.Disabled = true; //Get Pos: DataSet dsPos = ManagerUser.PosSelectAllForOrderProduct(); int numPos = dsPos.Tables[0].Rows.Count; ListItem Item = new ListItem(tPleaseChoiceWhere, "0"); slPos.Items.Add(Item); for (int i = 0; i < numPos; i++) { Item=new ListItem(dsPos.Tables[0].Rows[i]["Name"].ToString(),dsPos.Tables[0].Rows[i]["Id"].ToString()); slPos.Items.Add(Item); } if(Session["infoUser"] != null) { string[] arrInfo =(string[])Session["infoUser"]; DataSet ds=ManagerUser.GetUserInformation(int.Parse(arrInfo[0])); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { txtname.Value = ds.Tables[0].Rows[0]["ContactName"].ToString(); txtaddess.Value = ds.Tables[0].Rows[0]["ShippingAddress"].ToString(); txtemail.Value = ds.Tables[0].Rows[0]["Email1"].ToString(); txtmobile.Value = ds.Tables[0].Rows[0]["MobilePhone"].ToString(); txthome.Value = ds.Tables[0].Rows[0]["HomePhone"].ToString(); } } } } }
protected void btorder_ServerClick(object sender, EventArgs e) { try { if (Session["infoUser"] != null) { string name = txtname.Value.Trim(); string address = txtaddess.Value.Trim(); string email = txtemail.Value.Trim(); string mobile = txtmobile.Value.Trim(); string homephone = txthome.Value.Trim(); int idPost = int.Parse(slPos.Value); int NumDay = int.Parse(slNumberDay.Value); string City=""; string Zipcode=""; string Country=""; name = name.Replace('<', ' '); name = name.Replace('>', ' '); address = address.Replace('<', ' '); address = address.Replace('>', ' '); mobile = mobile.Replace('<', ' '); mobile = mobile.Replace('>', ' '); homephone = homephone.Replace('<', ' '); homephone = homephone.Replace('>', ' '); string note=""; if (homephone.Length > 0) { mobile += ", " + homephone; } CManageError error = Validate(name, address, email, mobile,idPost); if (error.GetNumberErr() > 0) { divErrors.Disabled = false; divErrors.InnerHtml = "<br /><div class='diverror'>" + error.GetAllError() + "</div>"; } else { DateTime timeNow=new DateTime(); timeNow=DateTime.Now; string[] arrInfo = (string[])Session["infoUser"]; int idCurrency=0; float Rate=0; //InsertValue: string codenumber = ManagerUser.getOrderNumber(); DataSet dsInfo = ManagerUser.SelectInformationForOrder(int.Parse(arrInfo[0]), Application["currency"].ToString()); try { if (dsInfo.Tables.Count > 0) { if (dsInfo.Tables[0].Rows.Count > 0) { City = dsInfo.Tables[0].Rows[0]["ShippingCity"].ToString(); Zipcode = dsInfo.Tables[0].Rows[0]["ShippingZipcode"].ToString(); Country = dsInfo.Tables[0].Rows[0]["ShippingCountry"].ToString(); } } } catch { } try { if (dsInfo.Tables.Count > 0) { if (dsInfo.Tables[1].Rows.Count > 0) { idCurrency = int.Parse(dsInfo.Tables[1].Rows[0]["id"].ToString()); Rate = float.Parse(dsInfo.Tables[1].Rows[0]["Rate"].ToString()); } } } catch { } int Idorder=ManagerUser.OrderInsertNew(codenumber, 0, timeNow, 0, int.Parse(arrInfo[0]), idPost, 1, 4, NumDay, 0, "", 0, idCurrency, Rate, name, address, City, Zipcode, Country, mobile, email, note); if (Idorder>0) { ArrayList listvalue = new ArrayList(); ManagerCart = (ManagerProcart)Session["ProductInCart"]; int Num = ManagerCart.getLengList(); for (int i = 0; i < Num; i++) { string[] arrvalue = new string[6]; proIncart = (ProInCart)ManagerCart.GetProIndex(i); arrvalue[0] = proIncart.id.ToString(); if (proIncart.type == 2) { arrvalue[1] = "0"; } else { arrvalue[1] = "1"; } //seri: arrvalue[2] = ""; arrvalue[3] = proIncart.number.ToString(); arrvalue[4] = proIncart.price.ToString(); arrvalue[5] = proIncart.rate.ToString(); listvalue.Add(arrvalue); } float discount=0; float tax=0; Boolean test= ManagerUser.InsertOrderDetail(Idorder, Rate, discount, tax, listvalue); if (test) { Session["ProductInCart"] = null; Session["ssListOrder"] = null; Response.Redirect("Default.aspx?menu=yesorder"); } else { divErrors.Disabled = false; divErrors.InnerHtml = "<br /><div class='diverror'>" + terrOrder + "</div>"; } } else { divErrors.Disabled = false; divErrors.InnerHtml = "<br /><div class='diverror'>" + terrOrder + "</div>"; } } } else { divErrors.Disabled = false; divErrors.InnerHtml = "<br /><div class='diverror'>" + tmessageinfo + "</div>"; } } catch { } }
protected void Page_Load(object sender, EventArgs e) { if (Session["ProductInCart"] != null) { ManagerCart = (ManagerProcart)Session["ProductInCart"]; numberincart = ManagerCart.getLengList().ToString(); } try { Hashtable hash = (Hashtable)Application[Session["langcurrent"].ToString()]; currentAccess = hash["currentpage"].ToString(); thome = hash["home"].ToString(); blCart = hash["blcart"].ToString(); nohave = hash["mnothave"].ToString(); tnumber = hash["mnumber"].ToString(); tTatal = hash["mtotal"].ToString(); twarranty=hash["twarranty"].ToString(); tmonth = hash["tmonth"].ToString(); tprice = hash["tprice"].ToString(); tinfopro = hash["tinfop"].ToString(); bcon = hash["bcon"].ToString(); bupdate = hash["bupdate"].ToString(); btUpdate.Value = bupdate; torder = hash["torder"].ToString(); currentAccess += ": <a href='?menu=home'>" + thome + "</a> » " + blCart; } catch { } if (!IsPostBack) { tablePro = ShowCart(); if (numberincart.Equals("0")) { divbutton.Visible = false; } } }