コード例 #1
0
    public string ShowComGroup()
    {
        CdymanicViewCom ViewProduct;
        int             currentpage = 0;
        int             size        = 20;
        int             idgroup     = 0;
        string          nameGroup   = "";

        try
        {
            idgroup     = int.Parse(Request.QueryString["id"].ToString());
            currentpage = int.Parse(Request.QueryString["page"].ToString());
            size        = int.Parse(Request.QueryString["size"].ToString());
            if (size > 40 || size < 10)
            {
                size = 20;
            }
        }
        catch
        {
        }
        if (Session["SSComponentGroup"] != null)
        {
            ViewProduct = (CdymanicViewCom)Session["SSComponentGroup"];
            ViewProduct.SetPageSize(size);
            if (idgroup != ViewProduct.GetIdGroup())
            {
                ViewProduct.setIdGroup(idgroup);
                ViewProduct.SetNumComGroup();
            }
            if (currentpage > 0)
            {
                ViewProduct.SetCurrentPage(currentpage);
            }
            else
            {
                ViewProduct.SetCurrentPage();
            }
        }
        else
        {
            ViewProduct = new CdymanicViewCom();
            ViewProduct.SetIdType((int)Application["idtypeproduct"]);
            ViewProduct.setIdGroup(idgroup);
            ViewProduct.SetNumComGroup();
            ViewProduct.SetPageSize(size);
            if (currentpage > 0)
            {
                ViewProduct.SetCurrentPage(currentpage);
            }
            else
            {
                ViewProduct.SetCurrentPage();
            }
            Session["SSComponentGroup"] = ViewProduct;
        }
        nameGroup = ViewProduct.GetNameGroup();
        if (nameGroup.Length > 0)
        {
            tCurrentAccess += " &raquo; " + nameGroup;
        }
        blpro = string.Format(blpro, "<u>" + ViewProduct.GetNumberRecord() + "</u>");
        Component_data product = ViewProduct.ComponentGroupFromTo();
        DataTable      table   = product.Tables[Component_data._table];
        int            numPro  = table.Rows.Count;
        Boolean        iseven  = true;

        if (ViewProduct.GetPages() > 1)
        {
            strpage1 = CreatePage(idgroup, ViewProduct.GetCurrentPage(), ViewProduct.GetPages(), ViewProduct.GetPageSize(), 1);
            strpage2 = CreatePage(idgroup, ViewProduct.GetCurrentPage(), ViewProduct.GetPages(), ViewProduct.GetPageSize(), 2);
        }
        else if (ViewProduct.GetPages() == 1)
        {
            strpage1 = ButtonCompare(true);
            strpage2 = ButtonCompare(false);
        }
        string strProMain = "";

        if (numPro > 0)
        {
            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 = "";
            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();
                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";
                }
                price    = table.Rows[i][Component_data._sellingPrice].ToString();
                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='?menu=dc&id=" + id + "'><img class='border_img' src='" + url + "'/></a></td>";
                    strProMain += "<td colspan='2' valign='top' class='text_title'><a href='?menu=dc&id=" + id + "' onmouseover=\"ShowSpeccom('" + note + "',event);\" onmouseout='OnMOut(event)'>" + name + "</a></td></tr>";
                    strProMain += "<tr><td>" + tbrand + ": <span class='price'>" + brand + "</span><br />" + tprice + ": <span class='price'>" + price + " " + unitPrice + "</span><br />" + 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='29' 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='?menu=dc&id=" + id + "'><img class='border_img' src='" + url + "'/></a></td>";
                    strProMain += "<td colspan='2' valign='top' class='text_title'><a href='?menu=dc&id=" + id + "' onmouseover=\"ShowSpeccom('" + note + "',event);\" onmouseout='OnMOut(event)'>" + name + "</a></td></tr>";
                    strProMain += "<tr><td>" + tbrand + ": <span class='price'>" + brand + "</span><br />" + tprice + ": <span class='price'>" + price + " " + unitPrice + "</span><br />" + 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='29' 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;
                }
            }
            strProMain += "<tr height='5'><td colspan='3'></td></tr>";
            strProMain += "</table>";
        }
        else
        {
            strProMain = "Không có sản phẩm nào.";
        }
        return(strProMain);
    }