Exemplo n.º 1
0
    private void LoadData()
    {
        DataAccess da = new DataAccess();

        DataSet ds = da.SelectByQuery("Select * from viewcuahang order by loaicuahangID");
        //ds.Tables[0].Select("LoaiCuaHang <> " + type);
        grdGianHang.DataSource = ds.Tables[0];
        grdGianHang.DataBind();
    }
Exemplo n.º 2
0
    private void ShowGianHangDamBao()
    {
        DataAccess da = new DataAccess();
        string strSql = "Select * from viewsanpham where sanphamid <>" + int.Parse(ViewState["SanPhamID"].ToString())
                        +
                        (ddlKhuVuc.SelectedIndex == 0
                             ? ""
                             : " and KhuVucID=" + ddlKhuVuc.Items[ddlKhuVuc.SelectedIndex].Value)
                        + " AND sanphammauid=" + int.Parse(0 + ViewState["SanPhamMauID"].ToString()) +
                        " AND BaoDam <> 0 ORDER BY BaoDam desc, GiaSanPham, Diem DESC, TenCuaHang ";

        DataSet ds = da.SelectByQuery(strSql);

        tblGianHangDuocDamBao.Rows.Clear();

        if (ds.Tables[0].Rows.Count > 0)
        {
            divGianHangDamBao.Style.Add("height", "100px");
            lblGianHangDamBao.Visible = false;
            for (int index = 0; index < ds.Tables[0].Rows.Count; index++)
            {
                lblGianHangDamBao.Visible = false;
                DataRow dr = ds.Tables[0].Rows[index];
                HtmlTableRow str = new HtmlTableRow();
                HtmlTableCell std1 = new HtmlTableCell();
                HtmlTableCell std2 = new HtmlTableCell();
                HtmlTableCell std3 = new HtmlTableCell();
                HtmlTableCell std4 = new HtmlTableCell();
                HtmlTableCell std5 = new HtmlTableCell();

                std1.Align = "center";
                std1.Width = "5%";
                std2.Align = "left";
                std2.Style.Add("padding-left", "15px");
                std2.Width = "13%";
                std3.Width = "47%";
                std3.Align = "Center";
                std3.Style.Add("padding-right", "10px");

                std4.Width = "20%";
                std4.Align = "center";
                std5.Width = "16%";
                std5.Align = "center";

                std1.Style.Add("border-right", "1pt solid");
                std1.Style.Add("border-bottom", "1pt solid");
                std2.Style.Add("border-right", "1pt solid");
                std2.Style.Add("border-bottom", "1pt solid");
                std3.Style.Add("border-right", "1pt solid");
                std3.Style.Add("border-bottom", "1pt solid");
                std4.Style.Add("border-right", "1pt solid");
                std4.Style.Add("border-bottom", "1pt solid");
                std5.Style.Add("border-right", "1pt solid");
                std5.Style.Add("border-bottom", "1pt solid");

                std1.InnerHtml = (index + 1).ToString();
                std2.InnerHtml = "<img src=\"http://opi.yahoo.com/online?u=" + dr["YM"] + "&t=1\" border=\"0\">";

                std3.InnerHtml = "<a href=\"./estore.aspx?sid=" + dr["CuaHangID"] + "\">" + dr["TenCuaHang"] +
                                 "(" + dr["TenKhuVuc"] + ")</a>";

                std4.InnerHtml = "<b>" +
                                 String.Format("{0:0,0}", decimal.Parse("0" + dr["GiaSanPham"])).Replace(",", ".") +
                                 " VNĐ </b>";
                std5.InnerHtml = "<a href=\"./shoppingcart.aspx?spid=" + dr["SanPhamID"] +
                                 "\"><img border=\"0\" src=\"./images/muahang.jpg\"></a>";

                str.Cells.Add(std1);
                str.Cells.Add(std2);
                str.Cells.Add(std3);
                str.Cells.Add(std4);
                str.Cells.Add(std5);

                tblGianHangDuocDamBao.Rows.Add(str);
            }
        }
        else
        {
            divGianHangDamBao.Style.Add("height", "40px");
            lblGianHangDamBao.Visible = true;
        }
    }
Exemplo n.º 3
0
    private void LoadTabContent02()
    {
        tblTraGiaContent.Visible = false;
        tblHoiDap.Visible = false;
        tblHoiDapContent.Visible = false;
        tblCacCuaHang.Visible = true;
        tblContent.Rows.Clear();

        DataAccess da = new DataAccess();
        string strSql = "Select * from viewsanpham where (sanphamid <>" + int.Parse(ViewState["SanPhamID"].ToString())
                        +
                        (ddlKhuVuc.SelectedIndex == 0
                             ? ""
                             : " and KhuVucID=" + ddlKhuVuc.Items[ddlKhuVuc.SelectedIndex].Value)
                        + " AND sanphammauid<>0 AND sanphammauid=" + int.Parse(0 + ViewState["SanPhamMauID"].ToString())
                        + " OR (Lower(TenSanPham) = (select Lower(TenSanPham) from sanpham where sanphamid=" +
                        int.Parse(ViewState["SanPhamID"].ToString())
                        + " AND NhomSanPhamID=(select nhomsanphamid from sanpham where sanphamid=" +
                        int.Parse(ViewState["SanPhamID"].ToString())
                        + ")))) ORDER BY GiaSanPham, Diem DESC, TenCuaHang ";

        DataSet ds = da.SelectByQuery(strSql);

        if (ds.Tables[0].Rows.Count > 0)
        {
            lblCuaHangBan.Visible = false;
            //string strThongTin = sds.Tables[0].Rows[0]["ThongTinSanPham"].ToString();
            int countrow = tblcontencuahang.Rows.Count;
            for (int j = 1; j < countrow; j++)
            {
                tblcontencuahang.Rows.Remove(tblcontencuahang.Rows[1]);
            }

            for (int index = 0; index < ds.Tables[0].Rows.Count; index++)
            {
                string GiaThapNhat = ds.Tables[0].Rows[0]["GiaSanPham"].ToString();
                DataRow dr = ds.Tables[0].Rows[index];
                string GiaHienTai = dr["GiaSanPham"].ToString();
                HtmlTableRow str = new HtmlTableRow();
                HtmlTableCell std1 = new HtmlTableCell();
                HtmlTableCell std2 = new HtmlTableCell();
                HtmlTableCell std3 = new HtmlTableCell();
                HtmlTableCell std4 = new HtmlTableCell();
                HtmlTableCell std5 = new HtmlTableCell();

                std1.Align = "center";
                std2.Align = "left";
                std2.Style.Add("padding-left", "15px");
                std3.Align = "right";
                std3.Style.Add("padding-right", "10px");
                std4.Align = "center";
                std5.Align = "center";

                std1.Style.Add("border-right", "1pt solid");
                std1.Style.Add("border-bottom", "1pt solid");
                std2.Style.Add("border-right", "1pt solid");
                std2.Style.Add("border-bottom", "1pt solid");
                std3.Style.Add("border-right", "1pt solid");
                std3.Style.Add("border-bottom", "1pt solid");
                std4.Style.Add("border-right", "1pt solid");
                std4.Style.Add("border-bottom", "1pt solid");
                std5.Style.Add("border-right", "1pt solid");
                std5.Style.Add("border-bottom", "1pt solid");

                std1.InnerHtml = (index + 1).ToString();

                std2.InnerHtml = "<a href=\"./estore.aspx?sid=" + dr["CuaHangID"] + "\">" + dr["TenCuaHang"] + "</a>" +
                                 "<br><a href=\"./shoppingcart.aspx?spid=" + dr["SanPhamID"] +
                                 "\"><img border=\"0\" src=\"./images/muahang.jpg\"></a>" +
                                 "<a href=\"ymsgr:sendIM?" + dr["YM"] + "\"><img src=\"http://opi.yahoo.com/online?u=" +
                                 dr["YM"] + "&t=1\" border=\"0\"></a>";

                std3.InnerHtml = "<b>" +
                                 String.Format("{0:0,0}", decimal.Parse("0" + dr["GiaSanPham"])).Replace(",", ".") +
                                 " VNĐ </b>";
                if (GiaHienTai == GiaThapNhat)
                    std3.InnerHtml += "<br><font color=red>Giá thấp nhất</font>";
                if (dr["NgayCapNhat"].ToString() != "")
                {
                    std3.InnerHtml += "<br><b> Cập nhật: " +
                                      DateTime.Parse(dr["NgayCapNhat"].ToString()).ToString("dd/MM/yyyy") +
                                      " Lúc: " + DateTime.Parse(dr["NgayCapNhat"].ToString()).ToString("hh:mm") + "</b>";
                }
                else if (dr["NgayThemSanPham"].ToString() != "")
                {
                    std3.InnerHtml += "<br><b> Cập nhật: " +
                                      DateTime.Parse(dr["NgayThemSanPham"].ToString()).ToString("dd/MM/yyyy") +
                                      " Lúc: " + DateTime.Parse(dr["NgayThemSanPham"].ToString()).ToString("hh:mm") +
                                      "</b>";
                }

                //std4.InnerHtml = dr["diem"].ToString();

                int sodiem = (int)decimal.Parse("0" + dr["diem"]);
                for (int i = 0; i < sodiem; i++)
                {
                    std4.InnerHtml += "<img align=\"absmiddle\" border=\"0\" src=\"./images/star1.gif\">";
                }

                for (int i = 10; i > sodiem; i--)
                {
                    std4.InnerHtml += "<img align=\"absmiddle\" border=\"0\" src=\"./images/star0.gif\">";
                }

                std4.InnerHtml += string.Format("{0:0.0}", decimal.Parse("0" + dr["diem"]));
                std4.InnerHtml += "<br><a href=#><img border=0 src=\"./images/poll.gif\">Đánh giá</a>";

                std5.InnerHtml = dr["DiaChi"] + "<b>(" + dr["TenKhuVuc"] + "</b>)<br><b> Tel: </b>" +
                                 dr["DienThoaiDiDong"];

                str.Cells.Add(std1);
                str.Cells.Add(std2);
                str.Cells.Add(std3);
                str.Cells.Add(std4);
                str.Cells.Add(std5);

                tblcontencuahang.Rows.Add(str);
            }
        }
        else
        {
            lblCuaHangBan.Visible = true;
        }
    }
Exemplo n.º 4
0
    private void LoadData()
    {
        try
        {
            SanPham sanpham = new SanPham();
            DataSet dsSanPham = sanpham.SelectByID(int.Parse(ViewState["SanPhamID"].ToString()));

            if (dsSanPham.Tables[0].Rows.Count > 0)
            {
                DataRow drSanPham = dsSanPham.Tables[0].Rows[0];
                string filename = Server.MapPath(drSanPham["AnhSanPham"].ToString());
                Image image;
                if (File.Exists(filename))
                {
                    image = Image.FromFile(filename);

                    int srcWidth = image.Width;
                    int srcHeight = image.Height;
                    if (image.Width > 323)
                    {
                        Decimal sizeRatio = ((Decimal)srcHeight / srcWidth);
                        int thumbHeight = Decimal.ToInt32(sizeRatio * 323);
                        imgSanPham.Width = 323;
                        imgSanPham.Height = thumbHeight;
                    }
                    else if (image.Height > 323)
                    {
                        Decimal sizeRatio = ((Decimal)srcWidth / srcHeight);
                        int thumbWidth = Decimal.ToInt32(sizeRatio * 323);
                        imgSanPham.Height = 323;
                        imgSanPham.Width = thumbWidth;
                    }
                    else
                    {
                        imgSanPham.Height = srcHeight;
                        imgSanPham.Width = srcWidth;
                    }
                }
                imgSanPham.Src = drSanPham["AnhSanPham"].ToString();
                lblTenSanPham.Text = drSanPham["TenSanPham"] + " " + drSanPham["TenSanPhamPhu"];
                Title = lblTenSanPham.Text;
                ViewState["TenGocSanPham"] = drSanPham["TenSanPham"].ToString();
                lblProdName.Text = lblTenSanPham.Text;
                divThongTinSanPham.InnerHtml += drSanPham["MoTaSanPham"].ToString().Replace("\r\n", "<br/>");

                if (bool.Parse(drSanPham["KhuyenMai"].ToString()))
                {
                    tblKhuyenMai.Visible = true;
                    divThongTinKhuyenMai.InnerHtml = drSanPham["MoTaKhuyenMai"].ToString();
                }
                else
                {
                    tblKhuyenMai.Visible = false;
                }

                if (bool.Parse(drSanPham["GiamGia"].ToString()))
                {
                    lbl2.Visible = true;
                    lblGiaMoi.Visible = true;
                    lbl3.Visible = true;
                    lbl1.Text = "Giá cũ: ";
                    lbl2.Text = "Giá mới: ";
                    lblGiaSanPham.Text = String.Format("{0:0,0}", drSanPham["GiaSanPham"]).Replace(",", ".");
                    lblGiaSanPham.Font.Strikeout = true;
                    lblGiaMoi.Text = String.Format("{0:0,0}", drSanPham["GiaKhuyenMai"]).Replace(",", ".");
                    lblGiaSanPhamTraGia.Text = String.Format("{0:0,0}", drSanPham["GiaKhuyenMai"]).Replace(",", ".");
                }
                else
                {
                    lbl1.Text = "Giá sản phẩm";
                    lblGiaSanPham.Text = String.Format("{0:0,0}", drSanPham["GiaSanPham"]).Replace(",", ".");
                    lblGiaSanPhamTraGia.Text = String.Format("{0:0,0}", drSanPham["GiaSanPham"]).Replace(",", ".");
                    lbl2.Visible = false;
                    lblGiaMoi.Visible = false;
                    lbl3.Visible = false;
                }

                lblDonViTienTe.Text = "VNĐ";
                lblMaSoSanPham.Text = drSanPham["MaSoSanPham"].ToString();

                ShowLink(int.Parse(drSanPham["NhomSanPhamID"].ToString()));
                ShowAnhSanPham();
                ShowNhaCungCap(int.Parse(drSanPham["NguoiDungID"].ToString()));
                ViewState["NguoiDungID"] = drSanPham["NguoiDungID"].ToString();
                if (drSanPham["SanPhamMauID"].ToString() != "")
                    ViewState["SanPhamMauID"] = drSanPham["SanPhamMauID"].ToString();
                ViewState["NhomSanPhamID"] = drSanPham["NhomSanPhamID"].ToString();
                LoadSanPhamCungLoai(int.Parse(drSanPham["NhomSanPhamID"].ToString()));

                if (!Page.IsPostBack)
                {
                    AddSanPhamDaXem(dsSanPham.Tables[0]);
                    // bak3 la truong dung de luu so lan xem san pham
                    sanpham.UpdateFields(int.Parse(ViewState["SanPhamID"].ToString()), null, null, null, null,
                                         null, null, null, null, null, null, null, null, null, null, null, null, null,
                                         null, null, null, null, null, null, null, null,
                                         int.Parse(drSanPham["bak3"].ToString()) + 1
                                         , null, null, null, null, null, null, null);
                }

                ShowGianHangDamBao();

                DataAccess da = new DataAccess();
                string strSql =
                    "Select count(distinct cuahangid) as soluong from viewsanpham where ((Lower(TenSanPham) = (select Lower(TenSanPham) from sanpham where sanphamid=" +
                    int.Parse(ViewState["SanPhamID"].ToString()) +
                    ")) OR ((sanphammauid <>0) and (sanphammauid=" + int.Parse(0 + ViewState["SanPhamMauID"].ToString()) +
                    ")))";
                DataSet dssch = da.SelectByQuery(strSql);

                lblSoCuaHang.Text = dssch.Tables[0].Rows[0]["soluong"].ToString() != "0" ? dssch.Tables[0].Rows[0]["soluong"].ToString() : "1";
            }
        }
        catch (Exception ex)
        {
            //Response.Redirect("Message.aspx?msg=" + ex.Message.Replace("\r\n"," "), false);
            Response.Write(ex.ToString());
        }
    }
Exemplo n.º 5
0
    /*
        private void SelectSanPhamData()
        {
            int intSanPhamID = int.Parse(ViewState["SanPhamID"].ToString());
            SanPham sp = new SanPham();
            DataSet ds = sp.SelectByID(intSanPhamID);
            string strThongTinSP = ds.Tables[0].Rows[0]["ThongTinSanPham"].ToString();

            NhanXetSanPham nx = new NhanXetSanPham();
            DataTable dtNhanXet = nx.SelectBySanPhamID(intSanPhamID).Tables[0];

            HoiDapSanPham hd = new HoiDapSanPham();
            DataTable dtHoiDap = hd.SelectBySanPhamID(intSanPhamID).Tables[0];

            TableRow tr = new TableRow();
            TableCell td = new TableCell();

            if (hidTabId.Value.Trim().Length > 0)
            {
                string content = "";
                switch (hidTabId.Value)
                {
                    case "1":
                        content += "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
                        content +=
                            "<tr><td width=\"12\"><img src=\"./images/left_tab.jpg\" width=\"12\" height=\"27\" /></td>";
                        content += "<td style=\"background-color:#AFAFAF;\" class=\"tab_active\">Thông tin sản phẩm</td>";
                        content +=
                            "<td width=\"12\"><img src=\"./images/right_tab.jpg\" width=\"12\" height=\"27\" /></td></tr></table>";
                        td.VerticalAlign = VerticalAlign.Bottom;
                        td.Text = content;
                        tr.Cells.Add(td);
                        //lblTab.Text = "Thông tin sản phẩm";

                        TableRow str = new TableRow();
                        TableCell std = new TableCell();
                        string scontent = "";
                        scontent = "";
                        scontent +=
                            "<table class=\"product\" width=\"100%\" border=\"0\" cellspacing=\"4\" cellpadding=\"0\">";
                        scontent += "<tr><td align=\"center\">" + strThongTinSP;
                        scontent += "</td></tr></table>";

                        std.Text = scontent;
                        std.Width = Unit.Percentage(16);
                        str.Cells.Add(std);

                        tblContent.Rows.Add(str);

                        break;
                    case "2":
                        content = "";
                        content += "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
                        content +=
                            "<tr><td width=\"12\"><img src=\"./images/left_tab.jpg\" width=\"12\" height=\"27\" /></td>";
                        content += "<td style=\"background-color:#AFAFAF;\" class=\"tab_active\">Các cửa hàng bán</td>";
                        content +=
                            "<td width=\"12\"><img src=\"./images/right_tab.jpg\" width=\"12\" height=\"27\" /></td></tr></table>";
                        td.VerticalAlign = VerticalAlign.Bottom;
                        td.Text = content;
                        tr.Cells.Add(td);
                        //lblTab.Text = "Hỏi Đáp";

                        break;
                    case "3":
                        content = "";
                        content += "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
                        content +=
                            "<tr><td width=\"12\"><img src=\"./images/left_tab.jpg\" width=\"12\" height=\"27\" /></td>";
                        content += "<td style=\"background-color:#AFAFAF;\" class=\"tab_active\">Hỏi đáp, phản hồi</td>";
                        content +=
                            "<td width=\"12\"><img src=\"./images/right_tab.jpg\" width=\"12\" height=\"27\" /></td></tr></table>";
                        td.VerticalAlign = VerticalAlign.Bottom;
                        td.Text = content;
                        tr.Cells.Add(td);
                        //lblTab.Text = "Nhận xét sản phẩm";
                        break;
                    case "4":
                        content = "";
                        content += "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
                        content +=
                            "<tr><td width=\"12\"><img src=\"./images/left_tab.jpg\" width=\"12\" height=\"27\" /></td>";
                        content += "<td style=\"background-color:#AFAFAF;\" class=\"tab_active\">Trả giá</td>";
                        content +=
                            "<td width=\"12\"><img src=\"./images/right_tab.jpg\" width=\"12\" height=\"27\" /></td></tr></table>";
                        td.VerticalAlign = VerticalAlign.Bottom;
                        td.Text = content;
                        tr.Cells.Add(td);
                        //lblTab.Text = "Nhận xét sản phẩm";
                        break;
                }
            }
            else
            {
                td.Text = "Selected Tab parameter is misisng!";
                tr.Cells.Add(td);
            }

            tblTab.Rows.Add(tr);
        }
    */
    private void ShowNhaCungCap(int id)
    {
        try
        {
            DataAccess da = new DataAccess();
            string strSql = "Select * from viewcuahang where nguoidungid =" + id;

            DataSet ds = da.SelectByQuery(strSql);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow dr = ds.Tables[0].Rows[0];
                lblNguoiBan.Text = dr["HoVaTen"].ToString();
                //LoaiCuaHangID = dr["LoaiCuaHangID"];
                lblNhaCungCap.Text = dr["TenCuaHang"].ToString();
                lblDienThoaiCoDinh.Text = dr["DienThoaiCoDinh"].ToString();
                lblDienThoaiDiDong.Text = dr["DienThoaiDiDong"].ToString();
                lblDiemDanhGia.Text = string.Format("{0:0.0}", decimal.Parse("0" + dr["Diem"])).Replace(".", ",")
                                      + "(" + int.Parse("0" + dr["Solandanhgia"]) + ")";
                //bak1 = YM
                ViewState["YM"] = dr["YM"].ToString();
                int DamBao = int.Parse("0" + dr["BaoDam"]);
                pnlDamBao.Controls.Clear();
                for (int i = 0; i < DamBao; i++)
                {
                    HtmlImage img = new HtmlImage();
                    img.Src = "./images/kc.jpg";
                    img.Border = 0;
                    pnlDamBao.Controls.Add(img);
                }
                //CuaHang cuahang = new CuaHang();
                //DataSet dsCuaHang = cuahang.SelectByNguoiDungID(id);
                ViewState["CuaHangID"] = dr["CuaHangID"].ToString();
                if (dr["LoaiCuaHangID"].ToString() == LoaiGianHang)
                {
                    hrefLinkGianHang.HRef = "NewEstore.aspx?sid=" + ViewState["CuaHangID"].ToString();
                }
                else
                {
                    hrefLinkGianHang.HRef = "Estore.aspx?sid=" + ViewState["CuaHangID"].ToString();
                }

            }
        }
        catch (Exception ex)
        {
            //Response.Redirect("Message.aspx?msg=" + ex.Message.Replace("\r\n", " "), false);
            Response.Write(ex.ToString());
        }
    }
Exemplo n.º 6
0
    private void LoadThongTinCuaHang(int id)
    {
        try
        {
            pnlDamBao.Controls.Clear();
            DataAccess da = new DataAccess();
            string strSql = "Select * from viewcuahang where nguoidungid =" + id;

            DataSet ds = da.SelectByQuery(strSql);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow dr = ds.Tables[0].Rows[0];
                lblDiemDanhGia.Text = string.Format("{0:0.0}", decimal.Parse("0" + dr["Diem"])).Replace(".", ",")
                                      + "(" + int.Parse("0" + dr["Solandanhgia"]) + ")";

                int DamBao = int.Parse("0" + dr["BaoDam"]);
                for (int i = 0; i < DamBao; i++)
                {
                    HtmlImage img = new HtmlImage();
                    img.Src = "./images/kc.jpg";
                    img.Border = 0;
                    pnlDamBao.Controls.Add(img);
                }
            }
        }
        catch (Exception ex)
        {
            //Response.Redirect("Message.aspx?msg=" + ex.Message.Replace("\r\n", " "), false);
            Response.Write(ex.ToString());
        }
    }