コード例 #1
0
    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);
    }
コード例 #2
0
    public void ShowProduct()
    {
        int    page  = 1;
        string text  = "-1";
        string state = "";

        try
        {
            if (Request.QueryString["page"] != null)
            {
                page = int.Parse(Request.QueryString["page"].ToString());
            }
            if (Request.QueryString["search"] != null)
            {
                text = Request.QueryString["search"].ToString();
            }
            if (Request.QueryString["state"] != null)
            {
                state = Request.QueryString["state"].ToString();
            }
            if (Request.QueryString["viewall"] != null)
            {
                page = 1;
                text = "";
            }
        }
        catch
        {
        }
        CDynamicViewProduct ViewProduct = new CDynamicViewProduct();

        if (Session["SSListProduct"] == null)
        {
            ViewProduct.SetPageSize(10);
            ViewProduct.SetIdType(int.Parse(Application["idtypeproduct"].ToString()));
            if (text.Equals("-1"))
            {
                ViewProduct.BuildWhere();
            }
            else
            {
                ViewProduct.SetTextSearch(text);
                ViewProduct.SetHasImage(state);
                ViewProduct.BuildWhereAdminSearch();
            }
            ViewProduct.SetNumQuickSearch();
            ViewProduct.SetCurrentPage(page);
            Session["SSListProduct"] = ViewProduct;
        }
        else
        {
            ViewProduct = (CDynamicViewProduct)Session["SSListProduct"];
            if (text.Equals("-1"))
            {
                //ViewProduct.BuildWhere();
            }
            else
            {
                ViewProduct.SetTextSearch(text);
                ViewProduct.SetHasImage(state);
                ViewProduct.BuildWhereAdminSearch();
            }
            ViewProduct.SetNumQuickSearch();
            ViewProduct.SetCurrentPage(page);
        }
        if (ViewProduct.GetPages() > 1)
        {
            BuildPage(ViewProduct.GetCurrentPage(), ViewProduct.GetPages());
        }
        DataSet ds = ViewProduct.ProductUploadImageFromTo();

        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ả 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><a href='?menu=updateDes&back=imgpro&id=" + ds.Tables[0].Rows[i - 1]["Id"].ToString() + "'>" + ds.Tables[0].Rows[i - 1]["Name"].ToString() + "</a></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_pro/" + 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>";
            string strdes = "";
            strdes = ds.Tables[0].Rows[i - 1]["Des"].ToString();
            if (strdes.Length > 0)
            {
                strdes = "Phần thông tin mô tả thêm đã được cập nhật";
            }
            strlist += "<td align='left'>" + strdes + "</td>";
            strlist += "</tr>";
        }
        strlist += "</table>";
    }
コード例 #3
0
    public void ShowProduct()
    {
        int    page  = 1;
        string text  = "-1";
        string state = "";

        try
        {
            if (Request.QueryString["page"] != null)
            {
                page = int.Parse(Request.QueryString["page"].ToString());
            }
            if (Request.QueryString["search"] != null)
            {
                text = Request.QueryString["search"].ToString();
            }
            if (Request.QueryString["state"] != null)
            {
                state = Request.QueryString["state"].ToString();
            }
            if (Request.QueryString["viewall"] != null)
            {
                page = 1;
                text = "";
            }
        }
        catch
        {
        }
        try
        {
            CDynamicViewProduct ViewProduct = new CDynamicViewProduct();
            if (Session["SSListmultiImgPro"] == null)
            {
                ViewProduct.SetPageSize(10);
                ViewProduct.SetIdType(int.Parse(Application["idtypeproduct"].ToString()));
                if (text.Equals("-1"))
                {
                    ViewProduct.BuildWhere();
                }
                else
                {
                    ViewProduct.SetTextSearch(text);
                    ViewProduct.SetHasImage(state);
                    ViewProduct.BuildWhereMultiImg();
                }
                ViewProduct.SetNumMultiImg();
                ViewProduct.SetCurrentPage(page);
                Session["SSListmultiImgPro"] = ViewProduct;
            }
            else
            {
                ViewProduct = (CDynamicViewProduct)Session["SSListmultiImgPro"];
                if (text.Equals("-1"))
                {
                    //ViewProduct.BuildWhere();
                }
                else
                {
                    ViewProduct.SetTextSearch(text);
                    ViewProduct.SetHasImage(state);
                    ViewProduct.BuildWhereMultiImg();
                }
                ViewProduct.SetNumMultiImg();
                ViewProduct.SetCurrentPage(page);
            }
            if (ViewProduct.GetPages() > 1)
            {
                BuildPage(ViewProduct.GetCurrentPage(), ViewProduct.GetPages());
            }
            DataSet ds = ViewProduct.ProductMultiImgFromTo();
            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='70'>Ảnh 1</td><td width='70'>Ảnh 2</td><td width='70'>Ảnh 3</td><td width='70'>Ảnh 4</td><td width='70'>Ảnh 5</td><td width='70'>Quảng cáo thêm</td><td width='50'>Mã SP</td><td width='70'>Tên sản phẩm</td><td width='70'>Giá bán</td></tr>";
            for (int i = 1; i <= num; i++)
            {
                //Id,Name,UrlImage,SellingPrice,WarrantyMonth
                strlist += "<tr>";
                //strlist += "<td align='center'>" + ds.Tables[0].Rows[i - 1]["brand"].ToString() + "</td>";
                string img1 = ds.Tables[0].Rows[i - 1]["img1"].ToString();
                if (img1.Length > 0)
                {
                    img1 = "<img class='imgpro' src='../image/multiimg/" + img1 + "' onclick=\"OnChoicePro(" + ds.Tables[0].Rows[i - 1]["Id"].ToString() + ",event,'" + img1 + "','1');\" />";
                }
                else
                {
                    img1 = "<img class='imgpro' src='../image/common/notimgpro.png' onclick=\"OnChoicePro(" + ds.Tables[0].Rows[i - 1]["Id"].ToString() + ",event,'" + img1 + "','1');\" />";
                }
                string img2 = ds.Tables[0].Rows[i - 1]["img2"].ToString();
                if (img2.Length > 0)
                {
                    img2 = "<img class='imgpro' src='../image/multiimg/" + img2 + "' onclick=\"OnChoicePro(" + ds.Tables[0].Rows[i - 1]["Id"].ToString() + ",event,'" + img2 + "','2');\" />";
                }
                else
                {
                    img2 = "<img class='imgpro' src='../image/common/notimgpro.png' onclick=\"OnChoicePro(" + ds.Tables[0].Rows[i - 1]["Id"].ToString() + ",event,'" + img2 + "','2');\" />";
                }
                string img3 = ds.Tables[0].Rows[i - 1]["img3"].ToString();
                if (img3.Length > 0)
                {
                    img3 = "<img class='imgpro' src='../image/multiimg/" + img3 + "' onclick=\"OnChoicePro(" + ds.Tables[0].Rows[i - 1]["Id"].ToString() + ",event,'" + img3 + "','3');\" />";
                }
                else
                {
                    img3 = "<img class='imgpro' src='../image/common/notimgpro.png' onclick=\"OnChoicePro(" + ds.Tables[0].Rows[i - 1]["Id"].ToString() + ",event,'" + img3 + "','3');\" />";
                }
                string img4 = ds.Tables[0].Rows[i - 1]["img4"].ToString();
                if (img4.Length > 0)
                {
                    img4 = "<img class='imgpro' src='../image/multiimg/" + img4 + "' onclick=\"OnChoicePro(" + ds.Tables[0].Rows[i - 1]["Id"].ToString() + ",event,'" + img4 + "','4');\" />";
                }
                else
                {
                    img4 = "<img class='imgpro' src='../image/common/notimgpro.png' onclick=\"OnChoicePro(" + ds.Tables[0].Rows[i - 1]["Id"].ToString() + ",event,'" + img4 + "','4');\" />";
                }
                string img5 = ds.Tables[0].Rows[i - 1]["img5"].ToString();
                if (img5.Length > 0)
                {
                    img5 = "<img class='imgpro' src='../image/multiimg/" + img5 + "' onclick=\"OnChoicePro(" + ds.Tables[0].Rows[i - 1]["Id"].ToString() + ",event,'" + img5 + "','5');\" />";
                }
                else
                {
                    img5 = "<img class='imgpro' src='../image/common/notimgpro.png' onclick=\"OnChoicePro(" + ds.Tables[0].Rows[i - 1]["Id"].ToString() + ",event,'" + img5 + "','5');\" />";
                }
                string img7 = ds.Tables[0].Rows[i - 1]["img7"].ToString();
                if (img7.Length > 0)
                {
                    img7 = "<img class='imgpro' src='../image/multiimg/" + img7 + "' onclick=\"OnChoicePro(" + ds.Tables[0].Rows[i - 1]["Id"].ToString() + ",event,'" + img7 + "','7');\" />";
                }
                else
                {
                    img7 = "<img class='imgpro' src='../image/common/notimgpro.png' onclick=\"OnChoicePro(" + ds.Tables[0].Rows[i - 1]["Id"].ToString() + ",event,'" + img7 + "','7');\" />";
                }
                strlist += "<td align='center'>" + i + "</td>";
                strlist += "<td align='center'>" + img1 + "</td>";
                strlist += "<td align='center'>" + img2 + "</td>";
                strlist += "<td align='center'>" + img3 + "</td>";
                strlist += "<td align='center'>" + img4 + "</td>";
                strlist += "<td align='center'>" + img5 + "</td>";
                strlist += "<td align='center'>" + img7 + "</td>";
                strlist += "<td align='center'>" + ds.Tables[0].Rows[i - 1]["Id"].ToString() + "</td>";
                strlist += "<td><a href='?menu=updateDes&back=imgpro&id=" + ds.Tables[0].Rows[i - 1]["Id"].ToString() + "'>" + ds.Tables[0].Rows[i - 1]["Name"].ToString() + "</a></td>";
                strlist += "<td align='center'>" + ds.Tables[0].Rows[i - 1]["SellingPrice"].ToString() + "</td>";
                strlist += "</tr>";
            }
            strlist += "</table>";
        }
        catch
        {
            strlist = "";
        }
    }