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 { } }
public string ShowCart() { string str = ""; int numPro = ManagerCart.getLengList(); if (numPro > 0) { str = "<table border='0' cellpadding='0' cellspacing='0' width='100%'>"; string url = ""; string subsrt = ""; for (int i = 0; i < numPro; i++) { proIncart = (ProInCart)ManagerCart.GetProIndex(i); tCurrentcy = proIncart.currency; url = proIncart.urlImage; if (url.Length > 0) { if (proIncart.type == 1 || proIncart.type == 3 || proIncart.type == 4) { url = "image/img_pro/" + url; } else if (proIncart.type == 2) { url = "image/img_com/" + url; } } else { url = "image/common/notimgpro.png"; } subsrt = "<span class='text_title'>"; if (proIncart.type == 1) { subsrt += "<a href='?menu=dp&id=" + proIncart.id.ToString() + "' class='text_title'>"; } else if (proIncart.type == 3) { subsrt += "<a href='?menu=dpda&id=" + proIncart.id.ToString() + "' class='text_title'>"; } else if (proIncart.type == 4) { subsrt += "<a href='?menu=dother&id=" + proIncart.id.ToString() + "' class='text_title'>"; } else if (proIncart.type == 2) { subsrt += "<a href='?menu=dc&id=" + proIncart.id.ToString() + "' class='text_title'>"; } subsrt += proIncart.name + "</a></span><br />"; subsrt += tprice + ": <span class='price'>" + proIncart.PriceStandard() + " VND</span><br />"; subsrt += twarranty + ": <span class='price'>" + proIncart.warranty.ToString() + " " + tmonth + "</span>"; str += "<tr>"; str += "<td width='110'>"; str += "<img src='" + url + "' width='76' height='65' />"; str += "</td>"; str += "<td valign='top' align='left' width='220'>" + subsrt + "</td>"; str += "<td width='80' align='center'><input class='tnumber' type='text' id='procart" + i.ToString() + "' value='" + proIncart.number.ToString() + "' maxlength='3' /></td>"; str += "<td width='80' align='center' class='price'>" + proIncart.ValueTotal() + "</td>"; if (proIncart.type == 1) { str += "<td align='center'><img src='image/common/icon_delete.bmp' class='idelete' onclick='AddCart(" + proIncart.id.ToString() + ",11);'/></td>"; } else if (proIncart.type == 3) { str += "<td align='center'><img src='image/common/icon_delete.bmp' class='idelete' onclick='AddCart(" + proIncart.id.ToString() + ",13);'/></td>"; } else if (proIncart.type == 4) { str += "<td align='center'><img src='image/common/icon_delete.bmp' class='idelete' onclick='AddCart(" + proIncart.id.ToString() + ",14);'/></td>"; } else if (proIncart.type == 2) { str += "<td align='center'><img src='image/common/icon_delete.bmp' class='idelete' onclick='AddCart(" + proIncart.id.ToString() + ",12);'/></td>"; } str += "</tr>"; if (i < numPro - 1) { str += "<tr><td colspan='5' class='bg_line3'></td></tr>"; } } str += "<tr class='text_b2'><td width='110'></td><td valign='top' align='left' width='220'></td>"; str += "<td width='80' align='center'>" + ManagerCart.GetNumBerPro().ToString() + "</td>"; str += "<td align='left' class='price' colspan='2'>" + ManagerCart.TotalCostVND().ToString("N") + " (VND)</td>"; str += "</tr>"; str += "</table>"; } else { str = "<div style='text-align:center;'>" + nohave + "</div>"; } return(str); }