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;
 }
 public void ShowProduct()
 {
     int page = 1;
     try
     {
         page = int.Parse(Request.QueryString["page"].ToString());
     }
     catch
     {
     }
     CDynamicViewProduct ViewProduct = new CDynamicViewProduct();
     if (Session["SSListotherPro"] == null)
     {
         ViewProduct.SetPageSize(10);
         string listIdtype = "(" + Application["idtypeproduct"].ToString() + "," + Application["apppda"].ToString() + ")";
         string strwhere = " where producttypeid not in " + listIdtype + " and cansales=1";
         ViewProduct.SetWhere(strwhere);
         ViewProduct.SetNumQuickSearch();
         ViewProduct.SetCurrentPage(page);
         Session["SSListotherPro"] = ViewProduct;
     }
     else
     {
         ViewProduct = (CDynamicViewProduct)Session["SSListotherPro"];
         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>" + 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_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>";
         strlist += "<td align='left'>" + ds.Tables[0].Rows[i - 1]["Note"].ToString() + "</td>";
         strlist += "</tr>";
     }
     strlist += "</table>";
 }
    public void ViewPage()
    {
        try
        {
            int page = 1;
            int size = 30;
            CDynamicViewProduct Products = new CDynamicViewProduct();
            if (Request.QueryString["advance"] != null)
            {
                if (Session["ssadvancesearchpro"] == null)
                {
                    Response.Redirect("Default.aspx?menu=asp");
                }
                try
                {
                    if (Request.QueryString["page"] != null)
                    {
                        page = int.Parse(Request.QueryString["page"].ToString());
                        if (page < 1)
                        {
                            page = 1;
                        }
                    }
                    if (Request.QueryString["size"] != null)
                    {
                        size = int.Parse(Request.QueryString["size"].ToString());
                        if (size > 40 || size < 10)
                        {
                            size = 30;
                        }
                    }
                }
                catch
                {

                }
                Products = (CDynamicViewProduct)Session["ssadvancesearchpro"];
                Products.SetPageSize(size);
                Products.SetCurrentPage(page);
            }
            else
            {
                string where = "";
                string location = "";
                string brand = "";
                float price1 = 0;
                float price2 = 0;
                string cpu = "";
                string hdd = "";
                string ram = "";
                string screen = "";
                string color = "";
                string txtsearch = "";
                string urlPage = Request.RawUrl;
                string proState = "";
                if (Request.QueryString["address"] != null)
                {
                    location = Request.QueryString["address"].ToString();
                    if (location.Length > 0)
                    {
                        where += " and Id in (select ProductId from v_web_product_warehouse where WareHouseId in (" + location + ") Group By ProductId)";
                    }
                }
                if (Request.QueryString["state"] != null)
                {
                    proState = Request.QueryString["state"].ToString();
                    if (proState.Length > 0)
                    {
                        where += " and StateId in (" + proState + ")";
                    }
                }
                if (Request.QueryString["brand"] != null)
                {
                    brand = Request.QueryString["brand"].ToString();
                    if (brand.Length > 0)
                    {
                        where += " and idbrand=" + brand;
                    }
                }
                if (Request.QueryString["price1"] != null)
                {
                    try
                    {
                        price1 = float.Parse(Request.QueryString["price1"].ToString());
                        if (Application["currency"].Equals("VND") || Application["currency"].Equals("$"))
                        {
                            price1 = price1 * 1000000;
                            price1 = price1 / (float)Application["ratepromain"];
                        }
                    }
                    catch
                    {

                    }
                    if (price1 > 0)
                    {
                        where += " and SellingPrice>=" + price1;
                    }
                }
                if (Request.QueryString["price2"] != null)
                {
                    try
                    {
                        price2 = float.Parse(Request.QueryString["price2"].ToString());
                        if (Application["currency"].Equals("VND") || Application["currency"].Equals("$"))
                        {
                            price2 = price2 * 1000000;
                            price2 = price2 / (float)Application["ratepromain"];
                        }
                    }
                    catch
                    { }
                    if (price2 > 0)
                    {
                        where += " and SellingPrice<=" + price2;
                    }
                }
                if (Request.QueryString["cpu"] != null)
                {
                    cpu = Request.QueryString["cpu"].ToString();
                    string[] arrvalue = cpu.Split(',');
                    int num = arrvalue.Length;
                    if (num > 7)
                    {
                        num = 7;
                    }
                    string sub = "";
                    for (int i = 0; i < num - 1; i++)
                    {
                        if (arrvalue[i].Length > 0)
                        {
                            sub += "note like '%" + arrvalue[i] + " ghz%' or ";
                        }
                    }
                    if (arrvalue[num - 1].Length > 0)
                    {
                        sub += "note like '%" + arrvalue[num - 1] + " ghz%'";
                    }
                    if (sub.Length > 0)
                    {
                        where += " and (" + sub + ")";
                    }
                }
                if (Request.QueryString["hdd"] != null)
                {
                    hdd = Request.QueryString["hdd"].ToString();
                    string[] arrvalue = hdd.Split(',');
                    int num = arrvalue.Length;
                    if (num > 7)
                    {
                        num = 7;
                    }
                    string sub = "";
                    for (int i = 0; i < num - 1; i++)
                    {
                        if (arrvalue[i].Length > 0)
                        {
                            sub += "note like '%" + arrvalue[i] + " gb%' or ";
                        }
                    }
                    if (arrvalue[num - 1].Length > 0)
                    {
                        sub += "note like '%" + arrvalue[num - 1] + " gb%'";
                    }
                    if (sub.Length > 0)
                    {
                        where += " and (" + sub + ")";
                    }
                }
                if (Request.QueryString["ram"] != null)
                {
                    ram = Request.QueryString["ram"].ToString();
                    string[] arrvalue = ram.Split(',');
                    int num = arrvalue.Length;
                    if (num > 7)
                    {
                        num = 7;
                    }
                    string sub = "";
                    for (int i = 0; i < num - 1; i++)
                    {
                        if (arrvalue[i].Length > 0)
                        {
                            sub += "note like '%, " + arrvalue[i] + " mb%' or ";
                        }
                    }
                    if (arrvalue[num - 1].Length > 0)
                    {
                        sub += "note like '%, " + arrvalue[num - 1] + " mb%'";
                    }
                    if (sub.Length > 0)
                    {
                        where += " and (" + sub + ")";
                    }
                }
                if (Request.QueryString["screen"] != null)
                {
                    screen = Request.QueryString["screen"].ToString();
                    string[] arrvalue = screen.Split(',');
                    int num = arrvalue.Length;
                    if (num > 7)
                    {
                        num = 7;
                    }
                    string sub = "";
                    for (int i = 0; i < num - 1; i++)
                    {
                        if (arrvalue[i].Length > 0)
                        {
                            sub += "note like '%" + arrvalue[i] + "\"%' or ";
                        }
                    }
                    if (arrvalue[num - 1].Length > 0)
                    {
                        sub += "note like '%" + arrvalue[num - 1] + "\"%'";
                    }
                    if (sub.Length > 0)
                    {
                        where += " and (" + sub + ")";
                    }
                }
                if (Request.QueryString["color"] != null)
                {
                    color = Request.QueryString["color"].ToString();
                    string[] arrvalue = color.Split(',');
                    int num = arrvalue.Length;
                    if (num > 7)
                    {
                        num = 7;
                    }
                    string sub = "";
                    for (int i = 0; i < num - 1; i++)
                    {
                        if (arrvalue[i].Length > 0)
                        {
                            sub += "note like N'%" + arrvalue[i] + "%' or ";
                        }
                    }
                    if (arrvalue[num - 1].Length > 0)
                    {
                        sub += "note like N'%" + arrvalue[num - 1] + "%'";
                    }
                    if (sub.Length > 0)
                    {
                        where += " and (" + sub + ")";
                    }
                }
                if (Request.QueryString["text"] != null)
                {
                    txtsearch = Request.QueryString["text"].ToString();
                    txtsearch = txtsearch.Replace("\"", "");
                    txtsearch = txtsearch.Replace("'", "");
                    if (txtsearch.Length > 0)
                    {
                        if (brand.Length > 0)
                        {
                            where += " and (Name like N'%" + txtsearch + "%' or note like N'%" + txtsearch + "%')";
                        }
                        else
                        {
                            where += " and (Name like N'%" + txtsearch + "%' or brand like N'%" + txtsearch + "%' or note like N'%" + txtsearch + "%')";
                        }
                    }
                }
                //strProduct = where;
                Products.SetPageSize(size);
                Products.SetIdType((int)Application["idtypeproduct"]);
                Products.SetAdvance(where);
                Products.SetWhere();
                Products.SetNumAdvanceSearch();
                Products.SetCurrentPage();
                Session["ssadvancesearchpro"] = Products;
            }
            blSearchPro = string.Format(blSearchPro, "<u>" + Products.GetNumberRecord() + "</u>");
            Product_data product = Products.ProductAdvanceSearchFromTo();
            DataTable table = product.Tables[Product_data._table];
            int numPro = table.Rows.Count;
            Boolean iseven = true;
            if (Products.GetPages() > 1)
            {
                strpage1 = CreatePage(Products.GetCurrentPage(), Products.GetPages(), Products.GetPageSize(), 1);
                strpage2 = CreatePage(Products.GetCurrentPage(), Products.GetPages(), Products.GetPageSize(), 2);
            }
            else if (Products.GetPages() == 1)
            {
                strpage1 = ButtonCompare(true);
                strpage2 = ButtonCompare(false);
            }
            strproduct = "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
            strproduct += "<tr height='5'><td colspan='3'></td></tr>";
            string id = "";
            string name = "";
            string url = "";
            string price = "";
            string warranty = "";
            Boolean istest = false;
            ArrayList list = new ArrayList();
            float rate = (float)Application["ratepromain"];
            float price11 = 1;
            string price22 = "";
            string substring = "";
            string madein = "";
            string isspec = "";
            if (Products.GetCurrentPage() == 1)
            {
                istest = true;
            }
            for (int i = 0; i < numPro; i++)
            {
                id = table.Rows[i][Product_data._id].ToString();
                name = table.Rows[i][Product_data._name].ToString() + " " + table.Rows[i][Product_data._state].ToString();
                url = table.Rows[i][Product_data._urlImage].ToString();
                string namepro = table.Rows[i][Product_data._name].ToString();
                namepro = namepro.Replace("/", "");
                namepro = namepro.Replace("#", "");
                namepro = namepro.Replace(":", "");
                namepro = namepro.Replace("\"", "");
                if (url.Length > 0)
                {
                    url = "image/img_pro/" + url;
                }
                else
                {
                    url = "image/common/notimgpro.png";
                }
                price22 = table.Rows[i][Product_data._price].ToString();
                price11 = float.Parse(table.Rows[i][Product_data._price].ToString());
                price11 = price11 * rate;
                price = price11.ToString("N").Split('.')[0];
                warranty = table.Rows[i][Product_data._WarrantyMonth].ToString();
                madein = table.Rows[i][Product_data._shortnote].ToString();
                isspec = table.Rows[i][Product_data._ispec].ToString();
                if (istest == true && price.Equals("0"))
                {
                    substring = "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
                    substring += "<tr><td rowspan='2' width='88' align='center' valign='top'>";
                    if (table.Rows[i][Product_data._ispromotion].ToString().Length > 0)
                    {
                        substring += "<img src='image/common/khuyenmai.gif' style='cursor:pointer;' onmouseover='showDivMessage(2," + id + "," + i + ",event);' onmouseout='OnMOut(event)'/><br />";
                    }
                    substring += "<a href='" + namepro + "-dp-" + id + ".html'><img class='img1' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)' src='" + url + "'/></a></td>";
                    substring += "<td colspan='2' valign='top' class='text_title'><a href='" + namepro + "-dp-" + id + ".html' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)'>" + name + "</a></td></tr>";
                    substring += "<tr><td valign='middle' width='165' height='48'>" + tprice + ": <span class='price'>";
                    substring += tupdate + "</span><br />";
                    substring += twarranty + ": <span class='price'>" + warranty + " " + tmonth + "</span>";
                    //if (madein.Length > 0)
                    //{
                    //    substring += "<br /><span class='text_title'>" + madein + "</span>";
                    //}
                    substring += "</td><td width='25' align='right'><input type='checkbox' id='c" + id + "' name='cp'/></td></tr>";

                    if (madein.Length > 0)
                    {
                        substring += "<tr><td colspan='3' class='text_title' align='center'>" + madein + "</td></tr>";
                    }
                    //strProMain += "<tr><td colspan='3' align='center' height='32'><div class='button3' onclick='AddCart(" + id + ",1);'>" + torder + "</div></td></tr>";
                    substring += "</table>";
                    list.Add(substring);
                    continue;
                }
                if (iseven)
                {
                    if (isspec.Equals("1"))
                    {
                        strproduct += "<tr><td width='278' class='cl1'>";
                    }
                    else
                    {
                        strproduct += "<tr><td width='278'>";
                    }
                    strproduct += "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
                    strproduct += "<tr><td rowspan='2' width='88' align='center' valign='top'>";
                    if (table.Rows[i][Product_data._ispromotion].ToString().Length > 0)
                    {
                        strproduct += "<img src='image/common/khuyenmai.gif' style='cursor:pointer;' onmouseover='showDivMessage(2," + id + "," + i + ",event);' onmouseout='OnMOut(event)'/><br />";
                    }
                    strproduct += "<a href='" + namepro + "-dp-" + id + ".html'><img class='img1' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)' src='" + url + "'/></a></td>";
                    strproduct += "<td colspan='2' valign='top' class='text_title'><a href='" + namepro + "-dp-" + id + ".html' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)'>" + name + "</a></td></tr>";
                    strproduct += "<tr><td valign='middle' width='165' height='48'>" + tprice + ": <span class='price'>";
                    if (price.Equals("0"))
                    {
                        strproduct += tupdate + "</span><br />";
                    }
                    else
                    {
                        if (unitPrice.Equals("$"))
                        {
                            strproduct += price + " VND</span><br />";
                            strproduct += "<font color='#FFFFFF'>" + tprice + ": </font><span class='price'>" + price22 + "</span><br />";
                        }
                        else if (unitPrice.Equals("$$"))
                        {
                            strproduct += price + " VND</span><br />";
                            strproduct += "<font color='#FFFFFF'>" + tprice + ": </font><span class='price'>" + price22 + " USD</span><br />";
                        }
                        else
                        {
                            strproduct += price + " " + unitPrice + "</span><br />";
                        }
                    }
                    strproduct += "<span class='tvat'>" + strMVAT + "</span><br />";
                    strproduct += twarranty + ": <span class='price'>" + warranty + " " + tmonth + "</span>";
                    //if (madein.Length > 0)
                    //{
                    //    strproduct += "<br /><span class='text_title'>" + madein + "</span>";
                    //}
                    strproduct += "</td><td width='25' align='right'><input type='checkbox' id='c" + id + "' name='cp'/></td></tr>";
                    //strproduct += "<tr><td colspan='3' height='32' align='center'><div class='button3' onclick='AddCart(" + id + ",1);'>" + torder + "</div></td></tr>";
                    if (madein.Length > 0)
                    {
                        strproduct += "<tr><td colspan='3' class='text_title' align='center'>" + madein + "</td></tr>";
                    }

                    strproduct += "</table></td>";
                    strproduct += "<td class='bg_line4'></td>";
                    iseven = false;
                    if (i + 1 == numPro)
                    {

                        if (list.Count == 0)
                        {
                            strproduct += "<td width='278'>&nbsp;</td>";
                            strproduct += "</tr>";
                        }
                    }
                }
                else
                {
                    if (isspec.Equals("1"))
                    {
                        strproduct += "<td width='278' class='cl1'>";
                    }
                    else
                    {
                        strproduct += "<td width='278'>";
                    }
                    strproduct += "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
                    strproduct += "<tr><td rowspan='2' width='88' align='center' valign='top'>";
                    if (table.Rows[i][Product_data._ispromotion].ToString().Length > 0)
                    {
                        strproduct += "<img src='image/common/khuyenmai.gif' style='cursor:pointer;' onmouseover='showDivMessage(2," + id + "," + i + ",event);' onmouseout='OnMOut(event)'/><br />";
                    }
                    strproduct += "<a href='" + namepro + "-dp-" + id + ".html'><img class='img1' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)' src='" + url + "'/></a></td>";
                    strproduct += "<td colspan='2' valign='top' class='text_title'><a href='" + namepro + "-dp-" + id + ".html' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)'>" + name + "</a></td></tr>";
                    strproduct += "<tr><td valign='middle' width='165' height='48'>" + tprice + ": <span class='price'>";
                    if (price.Equals("0"))
                    {
                        strproduct += tupdate + "</span><br />";
                    }
                    else
                    {
                        if (unitPrice.Equals("$"))
                        {
                            strproduct += price + " VND</span><br />";
                            strproduct += "<font color='#FFFFFF'>" + tprice + ": </font><span class='price'>" + price22 + "</span><br />";
                        }
                        else if (unitPrice.Equals("$$"))
                        {
                            strproduct += price + " VND</span><br />";
                            strproduct += "<font color='#FFFFFF'>" + tprice + ": </font><span class='price'>" + price22 + " USD</span><br />";
                        }
                        else
                        {
                            strproduct += price + " " + unitPrice + "</span><br />";
                        }
                    }
                    strproduct += "<span class='tvat'>" + strMVAT + "</span><br />";
                    strproduct += twarranty + ": <span class='price'>" + warranty + " " + tmonth + "</span>";
                    //if (madein.Length > 0)
                    //{
                    //    strproduct += "<br /><span class='text_title'>" + madein + "</span>";
                    //}
                    strproduct += "</td><td width='25' align='right'><input type='checkbox' id='c" + id + "' name='cp'/></td></tr>";
                    //strproduct += "<tr><td colspan='3' height='32' align='center'><div class='button3' onclick='AddCart(" + id + ",1);'>" + torder + "</div></td></tr>";

                    if (madein.Length > 0)
                    {
                        strproduct += "<tr><td colspan='3' class='text_title' align='center'>" + madein + "</td></tr>";
                    }

                    strproduct += "</table></td></tr>";
                    if (i + 1 < numPro)
                    {
                        strproduct += "<tr><td class='bg_line3'></td><td></td><td class='bg_line3'></td></tr>";
                    }
                    iseven = true;
                }
            }
            int numpro = list.Count;
            for (int i = 0; i < numpro; i++)
            {
                if (iseven)
                {
                    strproduct += "<tr><td width='278'>";
                    strproduct += list[i].ToString();
                    strproduct += "</td><td class='bg_line4'></td>";
                    iseven = false;
                    if (i + 1 == numpro)
                    {
                        strproduct += "<td width='278'>&nbsp;</td>";
                        strproduct += "</tr>";
                    }
                }
                else
                {
                    strproduct += "<td width='278'>";
                    strproduct += list[i].ToString();
                    strproduct += "</td></tr>";
                    if (i + 1 < numPro)
                    {
                        strproduct += "<tr><td class='bg_line3'></td><td></td><td class='bg_line3'></td></tr>";
                    }
                    iseven = true;
                }
            }
            strproduct += "<tr height='5'><td colspan='3'></td></tr>";
            strproduct += "</table>";
        }
        catch
        {

        }
    }
 public string ShowProductAll()
 {
     CDynamicViewProduct ViewProduct;
     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["SSProductOther"] != null)
     {
         ViewProduct = (CDynamicViewProduct)Session["SSProductOther"];
         ViewProduct.SetPageSize(size);
         if (currentpage > 0)
         {
             ViewProduct.SetCurrentPage(currentpage);
         }
         else
         {
             ViewProduct.SetNumberOther();
             ViewProduct.SetCurrentPage();
         }
     }
     else
     {
         ViewProduct = new CDynamicViewProduct();
         string where = "WHERE producttypeid NOT In (" + Application["idtypeproduct"].ToString() +
             "," + Application["apppda"].ToString() + "," + Application["idtypemobile"].ToString()
             + ") and Cansales = 1 AND ProductTypeId IN (SELECT Id FROM tbl_ProductType WHERE Cansales =1)";
         ViewProduct.SetWhere(where);
         ViewProduct.SetNumberOther();
         ViewProduct.SetPageSize(size);
         if (currentpage > 0)
         {
             ViewProduct.SetCurrentPage(currentpage);
         }
         else
         {
             ViewProduct.SetCurrentPage();
         }
         Session["SSProductOther"] = ViewProduct;
     }
     blpro = string.Format(blpro, "<u>" + ViewProduct.GetNumberRecord() + "</u>");
     DataSet product = ViewProduct.ProductOtherFromTo();
     DataTable table = product.Tables[0];
     int numPro = table.Rows.Count;
     if (ViewProduct.GetPages() > 1)
     {
         strpage1 = CreatePage(ViewProduct.GetCurrentPage(), ViewProduct.GetPages(), ViewProduct.GetPageSize(), 1);
         strpage2 = CreatePage(ViewProduct.GetCurrentPage(), ViewProduct.GetPages(), ViewProduct.GetPageSize(), 2);
     }
     string strProMain="";
     if (numPro > 0)
     {
         string id = "";
         string name = "";
         string url = "";
         string price = "";
         string warranty = "";
         string note = "";
         string brand = "";
         strProMain = "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
         for (int i = 0; i < numPro; i++)
         {
             id = table.Rows[i]["Id"].ToString();
             name = table.Rows[i]["Name"].ToString();
             url = table.Rows[i]["UrlImage"].ToString();
             note = table.Rows[i]["Note"].ToString();
             if (url.Length > 0)
             {
                 url = "image/img_pro/" + url;
             }
             else
             {
                 url = "image/common/notimgpro.png";
             }
             price = table.Rows[i]["SellingPrice"].ToString();
             warranty = table.Rows[i]["WarrantyMonth"].ToString();
             brand = table.Rows[i]["brand"].ToString();
             strProMain += "<tr><td width='300'>";
             strProMain += "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
             strProMain += "<tr><td rowspan='2' width='80' align='center'><a href='?menu=dother&id=" + id + "'><img class='img1' src='" + url + "'/></a></td>";
             strProMain += "<td class='text_title'><a href='?menu=dother&id=" + id + "'>" + name + "</a></td></tr>";
             strProMain += "<tr><td>" + tbrand + ": <span class='price'>" + brand + "</span><br />" + tprice + ": <span class='price'>" + price + " " + table.Rows[i]["currency"].ToString() + "</span><br />" + twarranty + ": <span class='price'>" + warranty + " " + tmonth + "</span>";
             if (table.Rows[i]["promotion"].ToString().Length > 0)
             {
                 strProMain += "<br /><img src='image/common/khuyenmai.gif' style='cursor:pointer;' onmouseover='showDivMessage(2," + id + "," + i + ",event);' onmouseout='OnMOut(event)'/>";
             }
             strProMain += "</td></tr>";
             strProMain += "<tr><td colspan='2' align='center'><div class='button3' onclick='AddCart(" + id + ",4);'>" + torder + "</div></td></tr>";
             strProMain += "</table></td>";
             strProMain += "<td>" + note + "</td></tr>";
             if (i < numPro - 1)
             {
                 strProMain += "<tr><td colspan='2' class='bg_line3'></td></tr>";
             }
         }
         strProMain += "</table>";
     }
     return strProMain;
 }
Exemplo n.º 5
0
 public string ShowProductAll()
 {
     CDynamicViewProduct ViewProduct;
     int currentpage=0;
     int size = 30;
     try
     {
         currentpage =int.Parse(Request.QueryString["page"].ToString());
         size = int.Parse(Request.QueryString["size"].ToString());
         if (size > 40 || size < 10)
         {
             size = 30;
         }
     }
     catch
     {
     }
     if (Session["SSMobileAll"] != null)
     {
         ViewProduct = (CDynamicViewProduct)Session["SSMobileAll"];
         ViewProduct.SetPageSize(size);
         if (currentpage > 0)
         {
             ViewProduct.SetCurrentPage(currentpage);
         }
         else
         {
             ViewProduct.SetNumProduct();
             ViewProduct.SetCurrentPage();
         }
     }
     else
     {
         ViewProduct = new CDynamicViewProduct();
         ViewProduct.SetIdType((int)Application["idtypemobile"]);
         ViewProduct.SetNumProduct();
         ViewProduct.SetPageSize(size);
         if (currentpage > 0)
         {
             ViewProduct.SetCurrentPage(currentpage);
         }
         else
         {
             ViewProduct.SetCurrentPage();
         }
         Session["SSMobileAll"] = ViewProduct;
     }
     blpro = string.Format(blpro, "<u>" + ViewProduct.GetNumberRecord() + "</u>");
     Product_data product = ViewProduct.ProductIdTypeFromTo();
     DataTable table = product.Tables[Product_data._table];
     int numPro = table.Rows.Count;
     Boolean iseven = true;
     if (ViewProduct.GetPages() > 1)
     {
         strpage1 = CreatePage(ViewProduct.GetCurrentPage(), ViewProduct.GetPages(), ViewProduct.GetPageSize(), 1);
         strpage2 = CreatePage(ViewProduct.GetCurrentPage(), ViewProduct.GetPages(), ViewProduct.GetPageSize(), 2);
     }
     else if(ViewProduct.GetPages() == 1)
     {
         strpage1 = ButtonCompare(true);
         strpage2 = ButtonCompare(false);
     }
     string strProMain = "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
     string id = "";
     string name = "";
     string url = "";
     string price = "0";
     float rate =(float)Application["ratepromain"];
     float price1 = 1;
     string warranty = "";
     Boolean istest = false;
     ArrayList list = new ArrayList();
     string substring = "";
     string madein = "";
     string isSpec = "";
     if (ViewProduct.GetCurrentPage() == 1)
     {
         istest = true;
     }
     for (int i = 0; i < numPro; i++)
     {
         id = table.Rows[i][Product_data._id].ToString();
         name = table.Rows[i][Product_data._name].ToString() + " " + table.Rows[i][Product_data._state].ToString();
         url = table.Rows[i][Product_data._urlImage].ToString();
         isSpec = table.Rows[i][Product_data._ispec].ToString();
         if (url.Length > 0)
         {
             url = "image/img_pro/" + url;
         }
         else
         {
             url = "image/common/notimgpro.png";
         }
         price1 = float.Parse(table.Rows[i][Product_data._price].ToString());
         price1 = price1 * rate;
         price = price1.ToString("N").Split('.')[0];
         warranty = table.Rows[i][Product_data._WarrantyMonth].ToString();
         madein = table.Rows[i][Product_data._shortnote].ToString();
         if (istest == true && price.Equals("0"))
         {
             substring = "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
             substring += "<tr><td rowspan='2' width='95' align='center'>";
             substring += "<a href='?menu=dp&id=" + id + "'><img class='img2' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)' src='" + url + "'/></a></td>";
             substring += "<td class='txt2' colspan='2'><a href='?menu=dp&id=" + id + "' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)'>" + name + "</a></td></tr>";
             substring += "<tr valign='top'><td width='159'>" + tprice + ": <span class='txt4'>";
             substring += tupdate + "</span><br />";
             substring += twarranty + ": <span class='txt4'>" + warranty + " " + tmonth + "</span><br />";
             if (table.Rows[i][Product_data._ispromotion].ToString().Length > 0)
             {
                 substring += "<img src='image/common/khuyenmai.gif' style='cursor:pointer;' onmouseover='showDivMessage(2," + id + "," + i + ",event);' onmouseout='OnMOut(event)'/><br />";
             }
             substring += "</td><td width='25'><input type='checkbox' id='c" + id + "' name='cp'/></td></tr>";
             //strProMain += "<tr><td colspan='3' align='center' height='32'><div class='button3' onclick='AddCart(" + id + ",1);'>" + torder + "</div></td></tr>";
             substring += "</table>";
             list.Add(substring);
             continue;
         }
         if (iseven)
         {
             if (isSpec.Equals("1"))
             {
                 strProMain += "<tr><td width='279' class='bgcl8'>";
             }
             else
             {
                 strProMain += "<tr><td width='279'>";
             }
             strProMain += "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
             strProMain += "<tr><td rowspan='2' width='95' align='center'>";
             strProMain += "<a href='?menu=dp&id=" + id + "'><img class='img2' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)' src='" + url + "'/></a></td>";
             strProMain += "<td class='txt2' colspan='2'><a href='?menu=dp&id=" + id + "' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)'>" + name + "</a></td></tr>";
             strProMain += "<tr valign='top'><td width='159'>" + tprice + ": <span class='txt4'>";
             if(price.Equals("0"))
             {
                 strProMain += tupdate + "</span><br />";
             }else
             {
                 strProMain += price + " " + unitPrice + "</span><br />";
             }
             strProMain += twarranty + ": <span class='txt4'>" + warranty + " " + tmonth + "</span><br />";
             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 += "</td><td width='25'><input type='checkbox' id='c" + id + "' name='cp'/></td></tr>";
             //strProMain += "<tr><td colspan='3' align='center' height='32'><div class='button3' onclick='AddCart(" + id + ",1);'>" + torder + "</div></td></tr>";
             strProMain += "</table></td>";
             strProMain += "<td class='line2'></td>";
             iseven = false;
             if (i + 1 == numPro)
             {
                 if (list.Count == 0)
                 {
                     strProMain += "<td width='279'>&nbsp;</td>";
                     strProMain += "</tr>";
                 }
             }
         }
         else
         {
             if (isSpec.Equals("1"))
             {
                 strProMain += "<td width='279' class='bgcl8'>";
             }
             else
             {
                 strProMain += "<td width='279'>";
             }
             strProMain += "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
             strProMain += "<tr><td rowspan='2' width='95' align='center'>";
             strProMain += "<a href='?menu=dp&id=" + id + "'><img class='img2' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)' src='" + url + "'/></a></td>";
             strProMain += "<td class='txt2' colspan='2'><a href='?menu=dp&id=" + id + "' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)'>" + name + "</a></td></tr>";
             strProMain += "<tr valign='top'><td width='159'>" + tprice + ": <span class='txt4'>";
             if (price.Equals("0"))
             {
                 strProMain += tupdate + "</span><br />";
             }
             else
             {
                 strProMain += price + " " + unitPrice + "</span><br />";
             }
             strProMain += twarranty + ": <span class='txt4'>" + warranty + " " + tmonth + "</span><br />";
             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 += "</td><td width='25'><input type='checkbox' id='c" + id + "' name='cp'/></td></tr>";
             //strProMain += "<tr><td colspan='3' align='center' height='32'><div class='button3' onclick='AddCart(" + id + ",1);'>" + torder + "</div></td></tr>";
             strProMain += "</table></td></tr>";
             if (i + 1 < numPro)
             {
                 strProMain += "<tr><td class='line1'></td><td></td><td class='line1'></td></tr>";
             }
             iseven = true;
         }
     }
     int numpro = list.Count;
     for (int i = 0; i < numpro; i++)
     {
         if (iseven)
         {
             strProMain += "<tr><td width='279'>";
             strProMain += list[i].ToString();
             strProMain += "</td><td class='line2'></td>";
             iseven = false;
             if (i + 1 == numpro)
             {
                 strProMain += "<td width='279'>&nbsp;</td>";
                 strProMain += "</tr>";
             }
         }
         else
         {
             strProMain += "<td width='279'>";
             strProMain += list[i].ToString();
             strProMain += "</td></tr>";
             if (i + 1 < numPro)
             {
                 strProMain += "<tr><td class='line1'></td><td></td><td class='line1'></td></tr>";
             }
             iseven = true;
         }
     }
     strProMain += "</table>";
     return strProMain;
 }
 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>";
 }
Exemplo n.º 7
0
    public string ShowProductAll()
    {
        CDynamicViewProduct ViewProduct;
        int currentpage = 0;
        int size = 30;
        try
        {
            currentpage = int.Parse(Request.QueryString["page"].ToString());
            size = int.Parse(Request.QueryString["size"].ToString());
            if (size > 40 || size < 10)
            {
                size = 30;
            }
        }
        catch
        {
        }
        if (Session["SSProductAll"] != null)
        {
            ViewProduct = (CDynamicViewProduct)Session["SSProductAll"];
            ViewProduct.SetPageSize(size);
            if (currentpage > 0)
            {
                ViewProduct.SetCurrentPage(currentpage);
            }
            else
            {
                ViewProduct.SetNumProduct();
                ViewProduct.SetCurrentPage();
            }
        }
        else
        {
            ViewProduct = new CDynamicViewProduct();
            ViewProduct.SetIdType((int)Application["idtypeproduct"]);
            ViewProduct.SetNumProduct();
            ViewProduct.SetPageSize(size);
            if (currentpage > 0)
            {
                ViewProduct.SetCurrentPage(currentpage);
            }
            else
            {
                ViewProduct.SetCurrentPage();
            }
            Session["SSProductAll"] = ViewProduct;
        }
        blpro = string.Format(blpro, "<u>" + ViewProduct.GetNumberRecord() + "</u>");
        Product_data product = ViewProduct.ProductIdTypeFromTo();
        DataTable table = product.Tables[Product_data._table];
        int numPro = table.Rows.Count;
        Boolean iseven = true;
        if (ViewProduct.GetPages() > 1)
        {
            strpage1 = CreatePage(ViewProduct.GetCurrentPage(), ViewProduct.GetPages(), ViewProduct.GetPageSize(), 1);
            strpage2 = CreatePage(ViewProduct.GetCurrentPage(), ViewProduct.GetPages(), ViewProduct.GetPageSize(), 2);
        }
        else if (ViewProduct.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 = "0";
        string price2 = "";
        float rate = (float)Application["ratepromain"];
        float price1 = 1;
        string warranty = "";
        Boolean istest = false;
        ArrayList list = new ArrayList();
        string substring = "";
        string madein = "";
        string isSpec = "";
        if (ViewProduct.GetCurrentPage() <= 2)
        {
            istest = true;
        }
        string StateId = "1";
        for (int i = 0; i < numPro; i++)
        {

            id = table.Rows[i][Product_data._id].ToString();
            name = table.Rows[i][Product_data._name].ToString() + " " + table.Rows[i][Product_data._state].ToString();
            url = table.Rows[i][Product_data._urlImage].ToString();
            isSpec = table.Rows[i][Product_data._ispec].ToString();
            string namepro = table.Rows[i][Product_data._name].ToString();
            namepro = namepro.Replace("/", "");
            namepro = namepro.Replace("#", "");
            namepro = namepro.Replace(":", "");
            namepro = namepro.Replace("\"", "");
            if (url.Length > 0)
            {
                url = "image/img_pro/" + url;
            }
            else
            {
                url = "image/common/notimgpro.png";
            }
            price2 = table.Rows[i][Product_data._price].ToString();
            price1 = float.Parse(table.Rows[i][Product_data._price].ToString());
            price1 = price1 * rate;
            price = price1.ToString("N").Split('.')[0];
            warranty = table.Rows[i][Product_data._WarrantyMonth].ToString();
            madein = table.Rows[i][Product_data._shortnote].ToString();
            StateId = table.Rows[i][Product_data._stateid].ToString();
            if (StateId.Equals("2") || StateId.Equals("3") || StateId.Equals("5"))
            {
                StateId = "2";
            }
            if (istest == true && (price.Equals("0") || StateId.Equals("2")))
            {
                substring = "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
                substring += "<tr><td rowspan='2' width='88' align='center' valign='top'>";
                if (table.Rows[i][Product_data._ispromotion].ToString().Length > 0)
                {
                    substring += "<img src='image/common/khuyenmai.gif' style='cursor:pointer;' onmouseover='showDivMessage(2," + id + "," + i + ",event);' onmouseout='OnMOut(event)'/><br />";
                }
                substring += "<a href='" + namepro + "-dp-" + id + ".html'><img class='img1' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)' src='" + url + "'/></a></td>";
                substring += "<td colspan='2' valign='top' class='text_title'><a href='" + namepro + "-dp-" + id + ".html' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)'>" + name + "</a></td></tr>";

                substring += "<tr><td valign='middle' width='165' height='48'>" + tprice + ": <span class='price'>";

                if (price.Equals("0"))
                {
                    substring += tupdate + "</span><br />";
                }
                else
                {
                    if (unitPrice.Equals("$"))
                    {
                        substring += price + " VND</span><br />";
                        substring += "<font color='#FFFFFF'>" + tprice + ": </font><span class='price'>" + price2 + "</span><br />";
                    }
                    else if (unitPrice.Equals("$$"))
                    {
                        substring += price + " VND</span><br />";
                        substring += "<font color='#FFFFFF'>" + tprice + ": </font><span class='price'>" + price2 + " USD</span><br />";
                    }
                    else
                    {
                        substring += price + " " + unitPrice + "</span><br />";
                    }
                    substring += "<span class='tvat'>" + strMVAT + "</span><br />";
                }
                substring += twarranty + ": <span class='price'>" + warranty + " " + tmonth + "</span>";
                //if (madein.Length > 0)
                //{
                //    substring += "<br /><span class='text_title'>" + madein + "</span>";
                //}
                substring += "</td><td width='25' align='right'><input type='checkbox' id='c" + id + "' name='cp'/></td></tr>";

                if (madein.Length > 0)
                {
                    substring += "<tr><td colspan='3' class='text_title' align='center'>" + madein + "</td></tr>";
                }

                //strProMain += "<tr><td colspan='3' align='center' height='32'><div class='button3' onclick='AddCart(" + id + ",1);'>" + torder + "</div></td></tr>";
                substring += "</table>";
                list.Add(substring);
                continue;
            }
            if (iseven)
            {
                if (isSpec.Equals("1"))
                {
                    strProMain += "<tr><td width='278' class='cl1'>";
                }
                else
                {
                    strProMain += "<tr><td width='278'>";
                }
                strProMain += "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
                strProMain += "<tr><td rowspan='2' width='88' align='center' valign='top'>";
                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='" + namepro + "-dp-" + id + ".html'><img class='img1' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)' src='" + url + "'/></a></td>";
                strProMain += "<td colspan='2' valign='top' class='text_title'><a href='" + namepro + "-dp-" + id + ".html' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)'>" + name + "</a></td></tr>";
                strProMain += "<tr><td valign='middle' width='165' height='48'>" + 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>";
                //if (madein.Length > 0)
                //{
                //    strProMain += "<br /><span class='text_title'>" + madein + "</span>";
                //}
                strProMain += "</td><td width='25' align='right'><input type='checkbox' id='c" + id + "' name='cp'/></td></tr>";

                if (madein.Length > 0)
                {
                    strProMain += "<tr><td colspan='3' class='text_title' align='center'>" + madein + "</td></tr>";
                }

                //strProMain += "<tr><td colspan='3' align='center' height='32'><div class='button3' onclick='AddCart(" + id + ",1);'>" + torder + "</div></td></tr>";
                strProMain += "</table></td>";
                strProMain += "<td class='bg_line4'></td>";
                iseven = false;
                if (i + 1 == numPro)
                {
                    if (list.Count == 0)
                    {
                        strProMain += "<td width='278'>&nbsp;</td>";
                        strProMain += "</tr>";
                    }
                }
            }
            else
            {
                if (isSpec.Equals("1"))
                {
                    strProMain += "<td width='278' class='cl1'>";
                }
                else
                {
                    strProMain += "<td width='278'>";
                }
                strProMain += "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
                strProMain += "<tr><td rowspan='2' width='88' align='center' valign='top'>";
                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='" + namepro + "-dp-" + id + ".html'><img class='img1' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)' src='" + url + "'/></a></td>";
                strProMain += "<td colspan='2' valign='top' class='text_title'><a href='" + namepro + "-dp-" + id + ".html' onmouseover='showDivMessage(1," + id + "," + i + ",event);' onmouseout='OnMOut(event)'>" + name + "</a></td></tr>";
                strProMain += "<tr><td valign='middle' width='165' height='48'>" + 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>";
                //if (madein.Length > 0)
                //{
                //    strProMain += "<br /><span class='text_title'>" + madein + "</span>";
                //}
                strProMain += "</td><td width='25' align='right'><input type='checkbox' id='c" + id + "' name='cp'/></td></tr>";
                if (madein.Length > 0)
                {
                    strProMain += "<tr><td colspan='3' class='text_title' align='center'>" + madein + "</td></tr>";
                }

                //strProMain += "<tr><td colspan='3' align='center' height='32'><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;
            }
        }
        int numlist = list.Count;
        for (int i = numlist - 1; i >= 0; i--)
        {
            if (iseven)
            {
                strProMain += "<tr><td width='278'>";
                strProMain += list[i].ToString();
                strProMain += "</td><td class='bg_line4'></td>";
                iseven = false;
                if (i==0)
                {
                    strProMain += "<td width='278'>&nbsp;</td>";
                    strProMain += "</tr>";
                }
            }
            else
            {
                strProMain += "<td width='278'>";
                strProMain += list[i].ToString();
                strProMain += "</td></tr>";
                if (i > 0)
                {
                    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>";
        return strProMain;
    }
 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 = "";
     }
 }