Example #1
0
    protected void btDangNhap_Click(object sender, EventArgs e)
    {
        try
        {
            String strLogin = "******" + txtTenDN.Text + "' and MatKhau='" + txtMatKhau.Text + "'";

            DataTable dt = x.GetData(strLogin);
            if (dt.Rows.Count > 0)
            {
                Session["TenDN"] = txtTenDN.Text;
                Response.Redirect("~/Default.aspx");
            }
            else
            {
                String strLogin_Admin = "select TenDNAdmin from dbo.ADMIN where TenDNAdmin='" + txtTenDN.Text + "' and MatKhauAdmin='" + txtMatKhau.Text + "'";

                DataTable dt1 = x.GetData(strLogin_Admin);
                if (dt1.Rows.Count > 0)
                {
                    Session["TenDNAdmin"] = txtTenDN.Text;
                    Response.Redirect("~/Admin/DangnhapAdmin.aspx");
                }
            }

            lbThongBaoLoi.Text = "Tên đăng nhập hoặc mật khẩu không hợp lệ!";
        }
        catch (Exception ex)
        {
            lbThongBaoLoi.Text = "Thất bại!" + ex.ToString();
        }
    }
    //Hàm lấy sách theo một chủ đề
    private void HoaTheoChuDe(object maCD)
    {
        DataTable dt = x.GetData("Select MaHoa,TenHoa,DonGia,HinhMinhHoa from HOA Where MaCD=" + int.Parse(maCD.ToString()));

        if (dt.Rows.Count > 0)
        {
            dlHoaTheoChuDe.DataSource = dt;
            dlHoaTheoChuDe.DataBind();
        }
    }
Example #3
0
 protected void btDongY_Click(object sender, EventArgs e)
 {
     try
     {
         DataTable dt = x.GetData("Select TenDN From KHACHHANG where TenDN='" + txtTenDN.Text + "' and MatKhau='" + txtMatKhauCu.Text + "'");
         if (dt.Rows.Count > 0)
         {
             /*
              * SqlConnection con = new SqlConnection(x.strCon);
              * con.Open();
              * SqlCommand cmd = new SqlCommand();
              * cmd.CommandType = CommandType.Text;
              * cmd.Connection = con;
              * cmd.CommandText = @"UPDATE KhachHang Set MatKhau=@MatKhau WHERE TenDN = @TenDN";
              * cmd.Parameters.Add("@TenDN", SqlDbType.VarChar, 15);
              * cmd.Parameters["@TenDN"].Value = txtTenDN.Text;
              * cmd.Parameters.Add("@MatKhau", SqlDbType.VarChar, 15);
              * cmd.Parameters["@MatKhau"].Value = txtMatKhauMoi.Text;
              * cmd.ExecuteNonQuery();
              * con.Close();
              */
             x.Execute("UPDATE KhachHang Set MatKhau = '" + txtMatKhauMoi.Text + "' WHERE TenDN = '" + txtTenDN.Text + "'");
             lbThongBaoLoi.Text = "Đổi mật khẩu thành công";
         }
         else
         {
             lbThongBaoLoi.Text = "Tên đăng nhập hoặc mật khẩu cũ không hợp lệ!";
         }
     }
     catch
     {
         lbThongBaoLoi.Text = "Thất bại!";
     }
 }
Example #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["Ms"] != null)
            {
                int       MaHoa   = int.Parse(Request.QueryString["Ms"]);
                DataTable dt      = x.GetData("SELECT TenHoa,DonGia From HOA WHERE MaHoa=" + MaHoa);
                String    TenHoa  = dt.Rows[0][0].ToString();
                float     DonGia  = float.Parse(dt.Rows[0][1].ToString());
                int       SoLuong = 1;
                ThemVaoGioHang(MaHoa, TenHoa, DonGia, SoLuong);
            }

            if (Session["Giohang"] != null)
            {
                DataTable      dt            = (DataTable)Session["Giohang"];
                System.Decimal TongThanhTien = 0;
                foreach (DataRow r in dt.Rows)
                {
                    r["ThanhTien"]       = Convert.ToInt32(r["SoLuong"]) * Convert.ToDecimal(r["DonGia"]);
                    TongThanhTien       += Convert.ToDecimal(r["Thanhtien"]);
                    lbTongThanhTien.Text = TongThanhTien.ToString();
                }
                gvGioHang.DataSource = dt;
                gvGioHang.DataBind();
            }
        }
    }
Example #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["TenDN"] == null)
        {
            Response.Redirect("~/Dangnhap.aspx");
        }
        if (Session["Giohang"] == null)
        {
            Response.Redirect("~/Giohang.aspx");
        }
        if (Session["TenDN"] != null)
        {
            string    s  = "Select MaKH,HoTenKH,DiaChiKH,DienThoaiKH,Email from KHACHHANG where TenDN='" + Session["TenDN"].ToString() + "'";
            DataTable dt = x.GetData(s);
            if (dt.Rows.Count > 0)
            {
                MaKH             = int.Parse(dt.Rows[0][0].ToString());
                lbHoTen.Text     = dt.Rows[0][1].ToString();
                lbDiaChi.Text    = dt.Rows[0][2].ToString();
                lbDienThoai.Text = dt.Rows[0][3].ToString();
                lbEmail.Text     = dt.Rows[0][4].ToString();
            }
        }
        if (Session["Giohang"] != null)
        {
            DataTable dt = new DataTable();
            dt = (DataTable)Session["GioHang"];
            System.Decimal tongThanhTien = 0;
            foreach (DataRow r in dt.Rows)
            {
                r["ThanhTien"]  = Convert.ToInt32(r["SoLuong"]) * Convert.ToDecimal(r["DonGia"]);
                tongThanhTien  += Convert.ToDecimal(r["ThanhTien"]);
                lbTongTien.Text = tongThanhTien.ToString();
            }
            gvGioHang.DataSource = dt;
            gvGioHang.DataBind();

            maDonHang  = int.Parse(x.GetData("Select max(SoDH) from DONDATHANG").Rows[0][0].ToString()) + 1;
            tongTriGia = tongThanhTien;
        }
        if (!IsPostBack)
        {
            cldNgayGiaoHang.SelectedDate = DateTime.Today;
        }
    }