コード例 #1
0
        public Component_data ComponentQuickSearchFromTo(string where, int from, int to)
        {
            Component_data ds = new Component_data();

            try
            {
                //w_product_for_quick_search
                string sqlselect   = "";
                int    num_Row_Get = to - from;
                sqlselect = "SELECT * FROM ( ";
                sqlselect = sqlselect + "SELECT TOP " + num_Row_Get.ToString();
                sqlselect = sqlselect + " * FROM( SELECT TOP " + to.ToString() + " Id,Name,Brand,UrlImage,SellingPrice,WarrantyMonth,Note FROM v_web_component_all " + where;
                sqlselect = sqlselect + " order by SellingPrice asc) as t1 ";
                sqlselect = sqlselect + " order by SellingPrice desc) as t2 ";
                sqlselect = sqlselect + " order by SellingPrice asc ";
                SqlConnection  con = new SqlConnection(dataaccess.configsql.strcon);
                SqlDataAdapter da  = new SqlDataAdapter(sqlselect, con);
                da.Fill(ds, Component_data._table);
                con.Close();
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return(ds);
        }
コード例 #2
0
        public Component_data ComponantGroupFromTo(int idtype, int idgroup, int from, int to)
        {
            Component_data ds = new Component_data();

            try
            {
                string sqlselect   = "";
                int    num_Row_Get = to - from;
                sqlselect = "SELECT * FROM ( ";
                sqlselect = sqlselect + "SELECT TOP " + num_Row_Get.ToString();
                sqlselect = sqlselect + " * FROM( SELECT TOP " + to.ToString() + " Id,Name,Brand,UrlImage,SellingPrice,WarrantyMonth,Note FROM v_web_component_all where ProductTypeId=" + idtype + " and ComponentTypeId=" + idgroup + " and CanSales=1";
                sqlselect = sqlselect + " order by SellingPrice asc) as t1 ";
                sqlselect = sqlselect + " order by SellingPrice desc) as t2 ";
                sqlselect = sqlselect + " order by SellingPrice asc ";
                SqlConnection  con = new SqlConnection(dataaccess.configsql.strcon);
                SqlDataAdapter da  = new SqlDataAdapter(sqlselect, con);
                da.Fill(ds, Component_data._table);
                con.Close();
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return(ds);
        }
コード例 #3
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);
    }
コード例 #4
0
    public string ShowProductSearch()
    {
        CdymanicViewCom ViewSearch;
        int             currentpage = 0;
        int             size        = 20;

        try
        {
            currentpage = int.Parse(Request.QueryString["page"].ToString());
            size        = int.Parse(Request.QueryString["size"].ToString());
            if (size > 40 || size < 10)
            {
                size = 20;
            }
        }
        catch
        {
        }
        if (Session["SSQSComponent"] == null)
        {
            ViewSearch = new CdymanicViewCom();
            ViewSearch.SetTextSearch(text);
            ViewSearch.SetIdType((int)Application["idtypeproduct"]);
            ViewSearch.BuildWhere();
            ViewSearch.SetNumComQuickSearch();
            ViewSearch.SetPageSize(size);
            if (currentpage > 0)
            {
                ViewSearch.SetCurrentPage(currentpage);
            }
            else
            {
                ViewSearch.SetCurrentPage();
            }
            Session["SSQSComponent"] = ViewSearch;
        }
        else
        {
            ViewSearch = (CdymanicViewCom)Session["SSQSComponent"];
            ViewSearch.SetPageSize(size);
            if (!text.Equals(ViewSearch.GetTextSearch()))
            {
                ViewSearch.SetTextSearch(text);
                ViewSearch.BuildWhere();
                ViewSearch.SetNumComQuickSearch();
            }
            if (currentpage > 0)
            {
                ViewSearch.SetCurrentPage(currentpage);
            }
            else
            {
                ViewSearch.SetCurrentPage();
            }
        }
        blpro = string.Format(blpro, "<u>" + ViewSearch.GetNumberRecord() + "</u>");
        Component_data product = ViewSearch.ComponentQuickSearchFromTo();
        DataTable      table   = product.Tables[Component_data._table];
        int            numPro  = table.Rows.Count;
        Boolean        iseven  = true;

        if (ViewSearch.GetPages() > 1)
        {
            strpage1 = CreatePage(ViewSearch.GetCurrentPage(), ViewSearch.GetPages(), ViewSearch.GetPageSize(), 1);
            strpage2 = CreatePage(ViewSearch.GetCurrentPage(), ViewSearch.GetPages(), ViewSearch.GetPageSize(), 2);
        }
        else if (ViewSearch.GetPages() == 1)
        {
            strpage1 = ButtonCompare(true);
            strpage2 = ButtonCompare(false);
        }
        string strProMain = "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";

        strProMain += "<tr height='5'><td colspan='3'></td></tr>";
        string id     = "";
        string name   = "";
        string url    = "";
        string price  = "";
        float  rate   = (float)Application["ratepromain"];
        float  price1 = 1;
        string price2 = "";

        string warranty = "";
        string brand    = "";
        string note     = "";

        for (int i = 0; i < numPro; i++)
        {
            id    = table.Rows[i][Component_data._id].ToString();
            name  = table.Rows[i][Component_data._name].ToString();
            url   = table.Rows[i][Component_data._urlImage].ToString();
            brand = table.Rows[i][Component_data._brand].ToString();
            note  = table.Rows[i][Component_data._note].ToString();
            string namepro = name;
            namepro = namepro.Replace("/", "");
            namepro = namepro.Replace("#", "");
            namepro = namepro.Replace(":", "");
            namepro = namepro.Replace("\"", "");
            if (note.Length > 0)
            {
                note = note.Replace("\"", "");
                note = note.Replace('\r', ' ');
                note = note.Replace('\n', ' ');
            }
            else
            {
                note = name;
            }
            if (url.Length > 0)
            {
                url = "image/img_com/" + url;
            }
            else
            {
                url = "image/common/notimgpro.png";
            }

            price2 = table.Rows[i][Component_data._sellingPrice].ToString();
            price1 = float.Parse(table.Rows[i][Component_data._sellingPrice].ToString());
            price1 = price1 * rate;
            price  = price1.ToString("N").Split('.')[0];

            warranty = table.Rows[i][Component_data._warrantyMonth].ToString();
            if (iseven)
            {
                strProMain += "<tr><td width='272'>";
                strProMain += "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
                strProMain += "<tr><td rowspan='2' width='100'><a href='" + namepro + "-dc-" + id + ".html'><img class='border_img' src='" + url + "'/></a></td>";
                strProMain += "<td colspan='2' valign='top' class='text_title'><a href='" + namepro + "-dc-" + id + ".html' onmouseover=\"ShowSpeccom('" + note + "',event);\" onmouseout='OnMOut(event)'>" + name + "</a></td></tr>";

                strProMain += "<tr><td height='70'>" + tbrand + ": <span class='price'>" + brand + "</span><br />";

                strProMain += tprice + ": <span class='price'>";
                if (price.Equals("0"))
                {
                    strProMain += tupdate + "</span><br />";
                }
                else
                {
                    if (unitPrice.Equals("$"))
                    {
                        strProMain += price + " VND</span><br />";
                        strProMain += "<font color='#FFFFFF'>" + tprice + ": </font><span class='price'>" + price2 + "</span><br />";
                    }
                    else if (unitPrice.Equals("$$"))
                    {
                        strProMain += price + " VND</span><br />";
                        strProMain += "<font color='#FFFFFF'>" + tprice + ": </font><span class='price'>" + price2 + " USD</span><br />";
                    }
                    else
                    {
                        strProMain += price + " " + unitPrice + "</span><br />";
                    }
                    strProMain += "<span class='tvat'>" + strMVAT + "</span><br />";
                }

                strProMain += twarranty + ": <span class='price'>" + warranty + " " + tmonth + "</span></td>";

                strProMain += "<td><input type='checkbox' id='c" + id + "' name='cp'/></td></tr>";
                //strProMain += "<tr><td colspan='3' height='32' align='center'><div class='button3' onclick='AddCart(" + id + ",2);'>" + torder + "</div></td></tr>";
                strProMain += "</table></td>";
                iseven      = false;
                if (i + 1 == numPro)
                {
                    strProMain += "<td class='bg_line4' width='11'></td>";
                    strProMain += "<td width='272'>&nbsp;</td>";
                    strProMain += "</tr>";
                }
            }
            else
            {
                strProMain += "<td class='bg_line4' width='11'></td>";
                strProMain += "<td width='272'>";
                strProMain += "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
                strProMain += "<tr><td rowspan='2' width='100'><a href='" + namepro + "-dc-" + id + ".html'><img class='border_img' src='" + url + "'/></a></td>";
                strProMain += "<td colspan='2' valign='top' class='text_title'><a href='" + namepro + "-dc-" + id + ".html' onmouseover=\"ShowSpeccom('" + note + "',event);\" onmouseout='OnMOut(event)'>" + name + "</a></td></tr>";

                strProMain += "<tr><td height='70'>" + tbrand + ": <span class='price'>" + brand + "</span><br />";

                strProMain += tprice + ": <span class='price'>";
                if (price.Equals("0"))
                {
                    strProMain += tupdate + "</span><br />";
                }
                else
                {
                    if (unitPrice.Equals("$"))
                    {
                        strProMain += price + " VND</span><br />";
                        strProMain += "<font color='#FFFFFF'>" + tprice + ": </font><span class='price'>" + price2 + "</span><br />";
                    }
                    else if (unitPrice.Equals("$$"))
                    {
                        strProMain += price + " VND</span><br />";
                        strProMain += "<font color='#FFFFFF'>" + tprice + ": </font><span class='price'>" + price2 + " USD</span><br />";
                    }
                    else
                    {
                        strProMain += price + " " + unitPrice + "</span><br />";
                    }
                    strProMain += "<span class='tvat'>" + strMVAT + "</span><br />";
                }



                strProMain += twarranty + ": <span class='price'>" + warranty + " " + tmonth + "</span></td>";

                strProMain += "<td><input type='checkbox' id='c" + id + "' name='cp'/></td></tr>";
                //strProMain += "<tr><td colspan='3' height='32' align='center'><div class='button3' onclick='AddCart(" + id + ",2);'>" + torder + "</div></td></tr>";
                strProMain += "</table></td></tr>";
                if (i + 1 < numPro)
                {
                    strProMain += "<tr><td class='bg_line3'></td><td></td><td class='bg_line3'></td></tr>";
                }
                iseven = true;
            }
        }
        if (numPro == 0)
        {
            strProMain += "<tr><td colspan='3' align='center'>" + tnotpro + "</td></tr>";
        }
        strProMain += "<tr height='5'><td colspan='3'></td></tr>";
        strProMain += "</table>";
        return(strProMain);
    }