public string ShowProductSearch()
    {
        CDynamicViewProduct 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
        {
        }
        try
        {
            text = Request.QueryString["text"].ToString();
            text = text.Replace('"', ' ');
            text = text.Trim();
            if (text.Length > 0)
            {
                if (text.Length > 30)
                {
                    text = text.Substring(0, 30);
                }
            }
        }
        catch
        {
            Response.Redirect("?menu=product");
        }
        if (Session["SSQSProduct"] == null)
        {
            ViewSearch = new CDynamicViewProduct();
            ViewSearch.SetTextSearch(text);
            ViewSearch.SetIdType((int)Application["idtypeproduct"]);
            ViewSearch.BuildWhere();
            ViewSearch.SetNumQuickSearch();
            ViewSearch.SetPageSize(size);
            if (currentpage > 0)
            {
                ViewSearch.SetCurrentPage(currentpage);
            }
            else
            {
                ViewSearch.SetCurrentPage();
            }
            Session["SSQSProduct"] = ViewSearch;
        }
        else
        {
            ViewSearch = (CDynamicViewProduct)Session["SSQSProduct"];
            ViewSearch.SetPageSize(size);
            if (!text.Equals(ViewSearch.GetTextSearch()))
            {
                ViewSearch.SetTextSearch(text);
                ViewSearch.BuildWhere();
                ViewSearch.SetNumQuickSearch();
            }
            if (currentpage > 0)
            {
                ViewSearch.SetCurrentPage(currentpage);
            }
            else
            {
                ViewSearch.SetCurrentPage();
            }
        }
        blpro = string.Format(blpro, ViewSearch.GetNumberRecord());
        Product_data product = ViewSearch.ProductQuickSearchFromTo();
        DataTable    table   = product.Tables[Product_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    = "";
        string warranty = "";

        for (int i = 0; i < numPro; i++)
        {
            id   = table.Rows[i][Product_data._id].ToString();
            name = table.Rows[i][Product_data._name].ToString();
            url  = table.Rows[i][Product_data._urlImage].ToString();
            if (url.Length > 0)
            {
                url = "image/img_pro/" + url;
            }
            else
            {
                url = "image/common/notimgpro.png";
            }
            price    = table.Rows[i][Product_data._price].ToString();
            warranty = table.Rows[i][Product_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' height='90' align='center'>";
                if (table.Rows[i][Product_data._ispromotion].ToString().Length > 0)
                {
                    strProMain += "<img src='image/common/khuyenmai.gif' style='cursor:pointer;' onmouseover='showDivMessage(2," + id + "," + i + ",event);' onmouseout='OnMOut(event)'/><br />";
                }
                strProMain += "<a href='?menu=dp&id=" + id + "'><img class='border_img' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)' src='" + url + "'/></a></td>";
                strProMain += "<td colspan='2' valign='top' class='text_title'><a href='?menu=dp&id=" + id + "' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)'>" + name + "</a></td></tr>";
                strProMain += "<tr><td>" + tprice + ": <span class='price'>" + price + " " + unitPrice + "</span><br />" + twarranty + ": <span class='price'>" + warranty + " " + tmonth + "</span>";
                strProMain += "</td><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 + ",1);'>" + 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'>&nbsp;</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' height='90' align='center'>";
                if (table.Rows[i][Product_data._ispromotion].ToString().Length > 0)
                {
                    strProMain += "<img src='image/common/khuyenmai.gif' style='cursor:pointer;' onmouseover='showDivMessage(2," + id + "," + i + ",event);' onmouseout='OnMOut(event)'/><br />";
                }
                strProMain += "<a href='?menu=dp&id=" + id + "'><img class='border_img' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)' src='" + url + "'/></a></td>";
                strProMain += "<td colspan='2' valign='top' class='text_title'><a href='?menu=dp&id=" + id + "' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)'>" + name + "</a></td></tr>";
                strProMain += "<tr><td>" + tprice + ": <span class='price'>" + price + " " + unitPrice + "</span><br />" + twarranty + ": <span class='price'>" + warranty + " " + tmonth + "</span>";
                strProMain += "</td><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 + ",1);'>" + 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);
    }
Ejemplo n.º 2
0
    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'>&nbsp;</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);
    }