public string ShowProductSearch() { CdymanicViewCom ViewSearch; int currentpage = 0; int size = 20; try { currentpage = int.Parse(Request.QueryString["page"].ToString()); size = int.Parse(Request.QueryString["size"].ToString()); if (size > 40 || size < 10) { size = 20; } } catch { } if (Session["SSQSComponent"] == null) { ViewSearch = new CdymanicViewCom(); ViewSearch.SetTextSearch(text); ViewSearch.SetIdType((int)Application["idtypeproduct"]); ViewSearch.BuildWhere(); ViewSearch.SetNumComQuickSearch(); ViewSearch.SetPageSize(size); if (currentpage > 0) { ViewSearch.SetCurrentPage(currentpage); } else { ViewSearch.SetCurrentPage(); } Session["SSQSComponent"] = ViewSearch; } else { ViewSearch = (CdymanicViewCom)Session["SSQSComponent"]; ViewSearch.SetPageSize(size); if (!text.Equals(ViewSearch.GetTextSearch())) { ViewSearch.SetTextSearch(text); ViewSearch.BuildWhere(); ViewSearch.SetNumComQuickSearch(); } if (currentpage > 0) { ViewSearch.SetCurrentPage(currentpage); } else { ViewSearch.SetCurrentPage(); } } blpro = string.Format(blpro, "<u>" + ViewSearch.GetNumberRecord() + "</u>"); Component_data product = ViewSearch.ComponentQuickSearchFromTo(); DataTable table = product.Tables[Component_data._table]; int numPro = table.Rows.Count; Boolean iseven = true; if (ViewSearch.GetPages() > 1) { strpage1 = CreatePage(ViewSearch.GetCurrentPage(), ViewSearch.GetPages(), ViewSearch.GetPageSize(), 1); strpage2 = CreatePage(ViewSearch.GetCurrentPage(), ViewSearch.GetPages(), ViewSearch.GetPageSize(), 2); } else if (ViewSearch.GetPages() == 1) { strpage1 = ButtonCompare(true); strpage2 = ButtonCompare(false); } string strProMain = "<table cellpadding='0' cellspacing='0' border='0' width='100%'>"; strProMain += "<tr height='5'><td colspan='3'></td></tr>"; string id = ""; string name = ""; string url = ""; string price = ""; float rate = (float)Application["ratepromain"]; float price1 = 1; string price2 = ""; string warranty = ""; string brand = ""; string note = ""; for (int i = 0; i < numPro; i++) { id = table.Rows[i][Component_data._id].ToString(); name = table.Rows[i][Component_data._name].ToString(); url = table.Rows[i][Component_data._urlImage].ToString(); brand = table.Rows[i][Component_data._brand].ToString(); note = table.Rows[i][Component_data._note].ToString(); string namepro = name; namepro = namepro.Replace("/", ""); namepro = namepro.Replace("#", ""); namepro = namepro.Replace(":", ""); namepro = namepro.Replace("\"", ""); if (note.Length > 0) { note = note.Replace("\"", ""); note = note.Replace('\r', ' '); note = note.Replace('\n', ' '); } else { note = name; } if (url.Length > 0) { url = "image/img_com/" + url; } else { url = "image/common/notimgpro.png"; } price2 = table.Rows[i][Component_data._sellingPrice].ToString(); price1 = float.Parse(table.Rows[i][Component_data._sellingPrice].ToString()); price1 = price1 * rate; price = price1.ToString("N").Split('.')[0]; warranty = table.Rows[i][Component_data._warrantyMonth].ToString(); if (iseven) { strProMain += "<tr><td width='272'>"; strProMain += "<table cellpadding='0' cellspacing='0' border='0' width='100%'>"; strProMain += "<tr><td rowspan='2' width='100'><a href='" + namepro + "-dc-" + id + ".html'><img class='border_img' src='" + url + "'/></a></td>"; strProMain += "<td colspan='2' valign='top' class='text_title'><a href='" + namepro + "-dc-" + id + ".html' onmouseover=\"ShowSpeccom('" + note + "',event);\" onmouseout='OnMOut(event)'>" + name + "</a></td></tr>"; strProMain += "<tr><td height='70'>" + tbrand + ": <span class='price'>" + brand + "</span><br />"; strProMain += tprice + ": <span class='price'>"; if (price.Equals("0")) { strProMain += tupdate + "</span><br />"; } else { if (unitPrice.Equals("$")) { strProMain += price + " VND</span><br />"; strProMain += "<font color='#FFFFFF'>" + tprice + ": </font><span class='price'>" + price2 + "</span><br />"; } else if (unitPrice.Equals("$$")) { strProMain += price + " VND</span><br />"; strProMain += "<font color='#FFFFFF'>" + tprice + ": </font><span class='price'>" + price2 + " USD</span><br />"; } else { strProMain += price + " " + unitPrice + "</span><br />"; } strProMain += "<span class='tvat'>" + strMVAT + "</span><br />"; } strProMain += twarranty + ": <span class='price'>" + warranty + " " + tmonth + "</span></td>"; strProMain += "<td><input type='checkbox' id='c" + id + "' name='cp'/></td></tr>"; //strProMain += "<tr><td colspan='3' height='32' align='center'><div class='button3' onclick='AddCart(" + id + ",2);'>" + torder + "</div></td></tr>"; strProMain += "</table></td>"; iseven = false; if (i + 1 == numPro) { strProMain += "<td class='bg_line4' width='11'></td>"; strProMain += "<td width='272'> </td>"; strProMain += "</tr>"; } } else { strProMain += "<td class='bg_line4' width='11'></td>"; strProMain += "<td width='272'>"; strProMain += "<table cellpadding='0' cellspacing='0' border='0' width='100%'>"; strProMain += "<tr><td rowspan='2' width='100'><a href='" + namepro + "-dc-" + id + ".html'><img class='border_img' src='" + url + "'/></a></td>"; strProMain += "<td colspan='2' valign='top' class='text_title'><a href='" + namepro + "-dc-" + id + ".html' onmouseover=\"ShowSpeccom('" + note + "',event);\" onmouseout='OnMOut(event)'>" + name + "</a></td></tr>"; strProMain += "<tr><td height='70'>" + tbrand + ": <span class='price'>" + brand + "</span><br />"; strProMain += tprice + ": <span class='price'>"; if (price.Equals("0")) { strProMain += tupdate + "</span><br />"; } else { if (unitPrice.Equals("$")) { strProMain += price + " VND</span><br />"; strProMain += "<font color='#FFFFFF'>" + tprice + ": </font><span class='price'>" + price2 + "</span><br />"; } else if (unitPrice.Equals("$$")) { strProMain += price + " VND</span><br />"; strProMain += "<font color='#FFFFFF'>" + tprice + ": </font><span class='price'>" + price2 + " USD</span><br />"; } else { strProMain += price + " " + unitPrice + "</span><br />"; } strProMain += "<span class='tvat'>" + strMVAT + "</span><br />"; } strProMain += twarranty + ": <span class='price'>" + warranty + " " + tmonth + "</span></td>"; strProMain += "<td><input type='checkbox' id='c" + id + "' name='cp'/></td></tr>"; //strProMain += "<tr><td colspan='3' height='32' align='center'><div class='button3' onclick='AddCart(" + id + ",2);'>" + torder + "</div></td></tr>"; strProMain += "</table></td></tr>"; if (i + 1 < numPro) { strProMain += "<tr><td class='bg_line3'></td><td></td><td class='bg_line3'></td></tr>"; } iseven = true; } } if (numPro == 0) { strProMain += "<tr><td colspan='3' align='center'>" + tnotpro + "</td></tr>"; } strProMain += "<tr height='5'><td colspan='3'></td></tr>"; strProMain += "</table>"; return(strProMain); }
public void ShowProduct() { int page = 1; string text = "-1"; string hasImage = ""; try { page = int.Parse(Request.QueryString["page"].ToString()); } catch { try { text = Request.QueryString["search"].ToString(); hasImage = Request.QueryString["img"].ToString(); } catch { text = ""; hasImage = ""; } } CdymanicViewCom ViewProduct = new CdymanicViewCom(); if (Session["SSListComponent"] == null) { ViewProduct.SetPageSize(10); ViewProduct.SetIdType(int.Parse(Application["idtypeproduct"].ToString())); if (text.Equals("-1")) { ViewProduct.BuildWhere(); } else { ViewProduct.SetTextSearch(text); ViewProduct.SetHasImage(hasImage); ViewProduct.BuildWhereAdminSearch(); } ViewProduct.SetNumComQuickSearch(); ViewProduct.SetCurrentPage(page); Session["SSListComponent"] = ViewProduct; } else { ViewProduct = (CdymanicViewCom)Session["SSListComponent"]; if (text.Equals("-1")) { //ViewProduct.BuildWhere(); } else { ViewProduct.SetTextSearch(text); ViewProduct.SetHasImage(hasImage); ViewProduct.BuildWhereAdminSearch(); } ViewProduct.SetNumComQuickSearch(); ViewProduct.SetCurrentPage(page); } if (ViewProduct.GetPages() > 1) { BuildPage(ViewProduct.GetCurrentPage(), ViewProduct.GetPages()); } DataSet ds = ViewProduct.ComponentQuickSearchFromTo(); if (ds.Tables.Count == 0) { strlist = "Lỗi kết nối SQL. Không thể hiển thị dữ liệu"; return; } int num = ds.Tables[0].Rows.Count; strlist = "<table border='1' cellpadding='1' cellspacing='0' width='100%' bordercolor='#DFDFDF' style='border-collapse:collapse;'>"; strlist += "<tr class='tlist'><td width='30'>STT</td><td width='50'>Mã SP</td><td width='95'>Tên sản phẩm</td><td width='60'>Nhãn hiệu</td><td width='70'>Ảnh sản phẩm</td><td width='55'>Giá bán</td><td>Mô tản sản phẩm</td></tr>"; for (int i = 1; i <= num; i++) { //Id,Name,UrlImage,SellingPrice,WarrantyMonth strlist += "<tr>"; strlist += "<td align='center'>" + i + "</td>"; strlist += "<td align='center'>" + ds.Tables[0].Rows[i - 1]["Id"].ToString() + "</td>"; strlist += "<td>" + ds.Tables[0].Rows[i - 1]["Name"].ToString() + "</td>"; strlist += "<td align='center'>" + ds.Tables[0].Rows[i - 1]["brand"].ToString() + "</td>"; string nameImage = ds.Tables[0].Rows[i - 1]["UrlImage"].ToString(); string url = nameImage; if (nameImage.Length == 0) { nameImage = "noimage"; } if (url.Length > 0) { url = "<img class='imgpro' src='../image/img_com/" + url + "' onclick=\"OnChoicePro(" + ds.Tables[0].Rows[i - 1]["Id"].ToString() + ",event,'" + nameImage + "','" + ds.Tables[0].Rows[i - 1]["Name"].ToString() + "');\" />"; } else { url = "<img class='imgpro' src='../image/common/notimgpro.png' onclick=\"OnChoicePro(" + ds.Tables[0].Rows[i - 1]["Id"].ToString() + ",event,'" + nameImage + "','" + ds.Tables[0].Rows[i - 1]["Name"].ToString() + "');\" />"; } strlist += "<td align='center'>" + url + "</td>"; strlist += "<td align='center'>" + ds.Tables[0].Rows[i - 1]["SellingPrice"].ToString() + "</td>"; strlist += "<td align='left'>" + ds.Tables[0].Rows[i - 1]["Note"].ToString() + "</td>"; strlist += "</tr>"; } strlist += "</table>"; }