protected void Page_Load(object sender, EventArgs e)
    {
        string Giatu  = Request.QueryString[0];
        string Giaden = Request.QueryString[1];

        if (Giaden.ToString() == null)
        {
            string c = "SELECT  TenHoa, MaHoa, Hinh, Gia FROM  dbo.SanPhamHoa WHERE Gia >=" + float.Parse(Giatu) + "";
            c = string.Format(c, Giatu, Giaden == "");
            DungChung connect = new DungChung();
            DataTable dt      = connect.DocBang(c);
            DataList1.DataSource = dt;
            DataList1.DataBind();
        }
        if (Giatu.ToString() != "" && Giaden.ToString() != "")
        {
            string c = "SELECT  TenHoa, MaHoa, Hinh, Gia FROM  dbo.SanPhamHoa WHERE Gia >= " + float.Parse(Giatu) + " and Gia <= " + float.Parse(Giaden) + "";
            c = string.Format(c, Giatu, Giaden);
            DungChung connect = new DungChung();
            DataTable dt      = connect.DocBang(c);
            DataList1.DataSource = dt;
            DataList1.DataBind();
        }
        else
        {
            lblThongBao.Text = "Không Có Sản Phẩm Cần Tìm!";
        }
    }
Exemple #2
0
    protected void btDangNhap_Click(object sender, EventArgs e)
    {
        DataTable     dt     = new DataTable();
        DungChung     ketnoi = new DungChung();
        SqlConnection cn     = new SqlConnection(ConfigurationManager.ConnectionStrings["connect"].ConnectionString);
        string        sql    = string.Format("select * from KhachHang where TenTaiKhoan = '{0}' and MatKhau = '{1}'", tbTenDN.Text, tbMatKhau.Text);
        SqlCommand    cmd    = new SqlCommand("select * from KhachHang where TenTaiKhoan='" + tbTenDN.Text + "'and MatKhau ='" + tbMatKhau.Text + "'", cn);

        cmd.CommandType = CommandType.Text;
        cn.Open();
        SqlDataReader rs = cmd.ExecuteReader();

        if (rs.Read())
        {
            string maquyen     = rs["Quyen"].ToString();
            string TenTaiKhoan = rs["TenTaiKhoan"].ToString();
            Session["TenTaiKhoan"] = tbTenDN.Text;
            cmd.Dispose();
            rs.Close();
            SqlCommand cmd2 = new SqlCommand("select * from KhachHang where Quyen=" + maquyen, cn);
            cmd2.CommandType = CommandType.Text;
            SqlDataReader rs2 = cmd2.ExecuteReader();
            if (rs2.Read())
            {
                string nhom1 = rs2["quyen"].ToString();
                switch (nhom1)
                {
                case "2":
                    FormsAuthentication.SetAuthCookie(TenTaiKhoan, false);
                    Response.Redirect("~/Admin/TrangChuAdmin.aspx");
                    break;

                case "1":
                    dt = ketnoi.DocBang(sql);
                    if (dt.Rows.Count > 0)
                    {
                        Session["MaKH"]    = dt.Rows[0]["MaKH"];
                        Session["hoTen"]   = dt.Rows[0]["Ten"];
                        lbLoiChao.Text     = "Chào: " + Session["hoTen"].ToString();
                        pnThoat.Visible    = false;
                        pnDangNhap.Visible = true;
                    }
                    Response.Redirect("TrangChu.aspx");
                    break;
                }
            }
            else
            {
                Response.Redirect("DangNhap.aspx");
            }
        }
        else
        {
            Response.Write("<script>alert('Bạn đã đăng nhập sai')</script>");
        }
    }
Exemple #3
0
    public static bool KiemTraTaiKhoanTonTai(string taiKhoan)
    {
        bool      kq;
        DungChung ketNoi = new DungChung();
        string    sql    = "select * from KhachHang where TenTaiKhoan = '" + taiKhoan + "'";
        DataTable dt     = ketNoi.DocBang(sql);

        if (dt.Rows.Count > 0)
        {
            kq = true;
        }
        else
        {
            kq = false;
        }
        return(kq);
    }
Exemple #4
0
    public static int LayMaTuTang()
    {
        string    sql    = "select * from KhachHang";
        DungChung ketNoi = new DungChung();
        DataTable dt     = new DataTable();

        dt = ketNoi.DocBang(sql);
        int maTuTang = 1;

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            if (int.Parse(dt.Rows[i][0].ToString()) != maTuTang)
            {
                return(maTuTang);
            }
            else
            {
                maTuTang++;
            }
        }
        return(maTuTang);
    }
Exemple #5
0
    public int LayMaTuTangDonDatHang()
    {
        int       soHD   = 1;
        DungChung ketNoi = new DungChung();
        string    sql    = "select * from DonDatHang";
        DataTable dt     = new DataTable();

        dt = ketNoi.DocBang(sql);
        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (int.Parse(dt.Rows[i][0].ToString()) != soHD)
                {
                    return(soHD);
                }
                else
                {
                    soHD++;
                }
            }
        }
        return(soHD);
    }
Exemple #6
0
    public int LayMaTuTangHoa()
    {
        int       MaHoa  = 1;
        DungChung ketNoi = new DungChung();
        string    sql    = "select * from SanPhamHoa";
        DataTable dt     = new DataTable();

        dt = ketNoi.DocBang(sql);
        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (int.Parse(dt.Rows[i][0].ToString()) != MaHoa)
                {
                    return(MaHoa);
                }
                else
                {
                    MaHoa++;
                }
            }
        }
        return(MaHoa);
    }