private void LoadKH()
    {
        DataTable dt = kn.GetData("select * from KhachHang");

        gvKhachhang.DataSource = dt;
        gvKhachhang.DataBind();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["tendn"] != null)
        {
            string sql = "select dh.*, case when TinhTrang=0 then N'Chưa giao' when TinhTrang=1 then N'Đã giao' else N'Đã hủy' end as TrangThai "
                         + " from KhachHang kh, DonDatHang dh where kh.MaKH=dh.MaKH and kh.SDT='" + Session["tendn"].ToString() +
                         "' and TinhTrang <> -1 order by MaDH desc";
            DataTable dt = kn.GetData(sql);
            if (dt.Rows.Count > 0)
            {
                gvdonhang.DataSource = dt;
                gvdonhang.DataBind();
            }
            if (Request.QueryString["id"] != null)
            {
                int    madh = int.Parse(Request.QueryString["id"].ToString());
                string s    = "update DonDatHang set TinhTrang= -1 where MaDH=" + madh;
                try
                {
                    kn.Execute(s);
                    Response.Write("<script> alert('Hủy đơn hàng thành công.');window.location='donhuy.aspx'; </script>");
                }
                catch
                {
                    Response.Write("<script> alert('Đã xảy ra lỗi. Vui lòng kiểm tra lại.') </script>");
                }
            }
        }

        else
        {
            Response.Write("<script type='text/javascript' language='javascript'>alert('Bạn cần đăng nhập để xem thông tin đơn hàng.');window.location='../dangnhap.aspx';</script>");
        }
    }
Beispiel #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["manvien"] != null)
         {
             DataTable dt = kn.GetData("select MaNV,TenNV,NgaySinh,GioiTinh,DiaChi,SDT,Email from NhanVien where MaNV =" + int.Parse(Session["manvien"].ToString()));
             if (dt.Rows.Count > 0)
             {
                 txttendn.Text = dt.Rows[0][0].ToString();
                 txthoten.Text = dt.Rows[0][1].ToString();
                 DateTime date = Convert.ToDateTime(dt.Rows[0][2].ToString());
                 txtngsinh.Text = String.Format("{0:dd/MM/yyyy}", date);
                 cmbgtinh.Text  = dt.Rows[0][3].ToString();
                 txtdiachi.Text = dt.Rows[0][4].ToString();
                 txtsdt.Text    = dt.Rows[0][5].ToString();
                 txtemail.Text  = dt.Rows[0][6].ToString();
                 lblemail.Text  = txtemail.Text;
                 lblsdt.Text    = txtsdt.Text;
             }
             else
             {
                 lbltbao.Text = "Đã xảy ra lỗi. Vui lòng kiểm tra lại.";
             }
         }
         else
         {
             Response.Redirect("dangnhap.aspx");
         }
     }
 }
Beispiel #4
0
        public void loadMaBG()
        {
            DataTable dt = kn.GetData("select * from Danhsachbuugui");

            cmbmabg.DataSource    = dt;
            cmbmabg.DisplayMember = "Mabg";
            cmbmabg.ValueMember   = "Mabg";
        }
    protected void btndangki_Click(object sender, EventArgs e)
    {
        string    sql = "select * from TaiKhoan where TenND='" + txttendn.Text.Trim() + "'";
        DataTable dt  = kn.GetData(sql);

        if (dt.Rows.Count > 0)
        {
            lbltbloi.Text = "Số điện thoại đã đăng ký.";
        }
        else
        {
            sql = "select MaKH from (select MaKH,Email from KhachHang union select MaNV,Email from NhanVien) DB where Email='" + txtemail.Text.Trim() + "'";
            dt  = kn.GetData(sql);
            if (dt.Rows.Count > 0)
            {
                lbltbloi.Text = "Email đã tồn tại.";
            }
            else
            {
                sql = "select MaKH from KhachHang where SDT='" + txttendn.Text.Trim() + "'";
                dt  = kn.GetData(sql);
                if (dt.Rows.Count > 0)
                {
                    try
                    {
                        sql = "update KhachHang set TenKH= N'" + txthoten.Text.Trim() + "',Email='" + txtemail.Text.Trim() + "' where SDT='" + txttendn.Text.Trim() + "'";
                        kn.Execute(sql);
                        sql = "insert into TaiKhoan values(" + int.Parse(dt.Rows[0][0].ToString()) + ",'" + txttendn.Text.Trim() + "','" + MaHoaMatKhau(txtmk.Text.Trim()) + "',N'Khách hàng')";
                        kn.Execute(sql);
                        Response.Write("<script> alert('Đăng ký thành công.'); window.location='../dangnhap.aspx'; </script>");
                    }
                    catch
                    {
                        Response.Write("<script> alert('Đã xảy ra lỗi. Vui lòng kiểm tra lại.') </script>");
                    }
                }
                else
                {
                    try
                    {
                        sql = "insert into KhachHang values(N'" + txthoten.Text.Trim() + "','" + txttendn.Text.Trim() + "','" + txtemail.Text.Trim() + "')";
                        kn.Execute(sql);
                        dt = kn.GetData("select MaKH from KhachHang where SDT= '" + txttendn.Text.Trim() + "'");
                        if (dt.Rows.Count > 0)
                        {
                            sql = "insert into TaiKhoan values(" + int.Parse(dt.Rows[0][0].ToString()) + ",'" + txttendn.Text.Trim() + "','" + MaHoaMatKhau(txtmk.Text.Trim()) + "',N'Khách hàng')";
                            kn.Execute(sql);
                        }
                        Response.Write("<script> alert('Đăng ký thành công.'); window.location='../dangnhap.aspx'; </script>");
                    }
                    catch
                    {
                        Response.Write("<script> alert('Đã xảy ra lỗi. Vui lòng kiểm tra lại.') </script>");
                    }
                }
            }
        }
    }
Beispiel #6
0
    private void LayThongTinSP_ThemGio(int masp)
    {
        string    s         = "select TenSP,HinhAnh,DVT,GiaBan,SoLuong,KhuyenMai,ThanhTien from SanPham left join CTHoaDon on  SanPham.MaSP=CTHoaDon.MaSP where SanPham.MaSP=" + masp;
        DataTable dt        = kn.GetData(s);
        string    tensp     = dt.Rows[0][0].ToString();
        string    hinh      = dt.Rows[0][1].ToString();
        float     dongia    = float.Parse(dt.Rows[0][3].ToString());
        string    dvt       = dt.Rows[0][2].ToString();
        float     khuyenmai = float.Parse(dt.Rows[0][5].ToString());
        int       soluong   = 1;

        ThemGioHang(masp, tensp, hinh, dvt, dongia, khuyenmai, soluong);
    }
Beispiel #7
0
    protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        int       soluongton;
        string    ktrsoluong = "Select SoLuongNhap-SoLuongBan as SLT from R_TonKho where TenSP= (select TenSP from SanPham where MaSP=" + Convert.ToInt32(Request.QueryString["maSo"].ToString()) + ")";
        DataTable ktsl       = kn.GetData(ktrsoluong);

        if (ktsl.Rows.Count > 0)
        {
            Label     slton     = e.Item.FindControl("lblslc") as Label;
            HyperLink hlmuahang = e.Item.FindControl("hlmuahang") as HyperLink;
            HyperLink hldathang = e.Item.FindControl("hldathang") as HyperLink;
            if (ktsl.Rows[0][0].ToString() != "")
            {
                soluongton = int.Parse(ktsl.Rows[0][0].ToString());
                if (soluongton > 0)
                {
                    slton.Text = "Số lượng còn: " + soluongton;
                }
                else
                {
                    slton.Text        = "Hết hàng tạm thời";
                    hlmuahang.Visible = false;
                    hldathang.Visible = false;
                }
            }
            else
            {
                slton.Text        = "Hết hàng tạm thời";
                hlmuahang.Visible = false;
            }
        }
    }
Beispiel #8
0
    protected void btndoimk_Click(object sender, EventArgs e)
    {
        string sql;

        sql = "select * from TaiKhoan where TenND=" + int.Parse(Session["tendn"].ToString()) + " and MatKhau='" + MaHoaMatKhau(txtmkcu.Text.Trim()) + "'";
        DataTable dt = kn.GetData(sql);

        if (dt.Rows.Count > 0)
        {
            try
            {
                sql = "update TaiKhoan set MatKhau='" + MaHoaMatKhau(txtmkmoi.Text.Trim()) + "' where TenND=" + int.Parse(Session["tendn"].ToString());
                kn.Execute(sql);
                Response.Write("<script type='text/javascript'>alert('Đổi mật khẩu thành công.');window.location='../dangnhap.aspx';</script>");
            }
            catch
            {
                lbltbloi.Text = "Đã xảy ra lỗi. Vui lòng kiểm tra lại.";
            }
        }
        else
        {
            lbltbloi.Text = "Mật khẩu cũ không đúng.";
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["tendn"] != null)
     {
         string    sql    = "select MaKH from KhachHang where SDT='" + Session["tendn"].ToString() + "'";
         DataTable dtMaKH = kn.GetData(sql);
         if (dtMaKH.Rows.Count > 0)
         {
             makh = int.Parse(dtMaKH.Rows[0][0].ToString());
             if (Session["giohang"] != null)
             {
                 DataTable dt = new DataTable();
                 dt = (DataTable)Session["giohang"];
                 float tongtien = 0;
                 foreach (DataRow row in dt.Rows)
                 {
                     row["ThanhTien"] = int.Parse(row["SoLuong"].ToString()) * float.Parse(row["GiaBan"].ToString()) * (1 - float.Parse(row["KhuyenMai"].ToString()) / 100);
                     tongtien        += float.Parse(row["ThanhTien"].ToString());
                 }
                 lbltongthanhtien.Text = String.Format("{0:#,##0}", float.Parse(tongtien.ToString())) + " đồng";
                 gvgiohang.DataSource  = dt;
                 gvgiohang.DataBind();
                 lbltongcong.Visible      = true;
                 lbltongthanhtien.Visible = true;
             }
             else
             {
                 Response.Redirect("~/sieuthi/giohang.aspx");
             }
         }
     }
     else
     {
         Response.Write("<script type='text/javascript' language='javascript'>alert('Bạn cần đăng nhập để mua hàng.');window.location='../dangnhap.aspx';</script>");
     }
     if (!IsPostBack)
     {
         string    laythongtin = "select TenKH,DDH.DiaChiNhan,KH.SDT from KHACHHANG KH, DonDatHang DDH where KH.MaKH=DDH.MaKH and KH.MaKH=" + makh;
         DataTable dtKH        = kn.GetData(laythongtin);
         if (dtKH.Rows.Count > 0)
         {
             txthoten.Text  = dtKH.Rows[0][0].ToString();
             txtdiachi.Text = dtKH.Rows[0][1].ToString();
             txtdt.Text     = dtKH.Rows[0][2].ToString();
         }
     }
 }
Beispiel #10
0
    private void DanhMuc()
    {
        DataTable dt = kn.GetData("select MaLoai,TenLoai from LoaiSP");

        if (dt.Rows.Count > 0)
        {
            DLDanhMuc.DataSource = dt;
            DLDanhMuc.DataBind();
        }
    }
Beispiel #11
0
    private void TenLoaiSP()
    {
        int       maloai = int.Parse(Request.QueryString["maloai"].ToString());
        DataTable dt     = kn.GetData("select TenLoai from LoaiSP where MaLoai=" + maloai);

        if (dt.Rows.Count > 0)
        {
            lbldanhmuc.Text = dt.Rows[0][0].ToString();
        }
    }
Beispiel #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["tendn"] != null)
        {
            string sql = "select dh.*, case when TinhTrang=0 then N'Chưa giao' when TinhTrang=1 then N'Đã giao' else N'Đã hủy' end as TrangThai "
                         + " from KhachHang kh, DonDatHang dh where kh.MaKH=dh.MaKH and kh.SDT='" + Session["tendn"].ToString() +
                         "' and TinhTrang = -1 order by MaDH desc";
            DataTable dt = kn.GetData(sql);
            if (dt.Rows.Count > 0)
            {
                gvdonhang.DataSource = dt;
                gvdonhang.DataBind();
            }
        }

        else
        {
            Response.Write("<script type='text/javascript' language='javascript'>alert('Bạn cần đăng nhập để xem thông tin đơn hàng.');window.location='../dangnhap.aspx';</script>");
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["tendn"] != null)
         {
             DataTable dt = kn.GetData("select TenKH,SDT,Email from KhachHang where SDT ='" + Session["tendn"].ToString() + "'");
             if (dt.Rows.Count > 0)
             {
                 txttendn.Text = dt.Rows[0][1].ToString();
                 txthoten.Text = dt.Rows[0][0].ToString();
                 txtemail.Text = dt.Rows[0][2].ToString();
                 lblemail.Text = txtemail.Text;
             }
         }
         else
         {
             Response.Redirect("../dangnhap.aspx");
         }
     }
 }
Beispiel #14
0
    private void LoadNV(int manv)
    {
        DataTable dt = kn.GetData("select * from NhanVien where MaNV=" + manv);

        gvTimKiem.DataSource = dt;
        gvTimKiem.DataBind();
    }
Beispiel #15
0
    private void LoadNV()
    {
        DataTable dt = kn.GetData("select * from NhanVien");

        gvNhanvien.DataSource = dt;
        gvNhanvien.DataBind();
    }
Beispiel #16
0
    protected void btndangnhap_Click(object sender, EventArgs e)
    {
        try
        {
            string    sql = "select LoaiND from TaiKhoan where TenND='" + txtusername.Text.Trim() + "' and MatKhau='" + MaHoaMatKhau(txtpassword.Text) + "'";
            DataTable dt  = kn.GetData(sql);
            if (dt.Rows.Count > 0)
            {
                Session["chucvu"] = dt.Rows[0][0].ToString();
                if (Session["chucvu"].ToString() == "Khách hàng")
                {
                    Session["tendn"] = txtusername.Text.Trim();
                    Response.Redirect("~/trangchu.aspx");
                }
                else
                {
                    string    sql1 = "select TenNV from NhanVien where MaNV=" + int.Parse(txtusername.Text.Trim());
                    DataTable dt1  = kn.GetData(sql1);
                    if (dt1.Rows.Count > 0)
                    {
                        Session["manvien"] = int.Parse(txtusername.Text.Trim());
                        Session["ten"]     = dt1.Rows[0][0].ToString();
                    }
                    Response.Redirect("qlsieuthi.aspx");
                }
            }

            else
            {
                lbltbloi.Text    = "Username hoặc Password không đúng ";
                txtpassword.Text = "";
            }
        }
        catch
        {
            lbltbloi.Text    = "Username hoặc Password không đúng ";
            txtpassword.Text = "";
        }
    }
        public void LoadDSBuuGui()
        {
            dsbuugui.Items.Clear();
            DataTable dt = kn.GetData("select * from Danhsachbuugui");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ListViewItem it = new ListViewItem((i + 1).ToString());
                it.SubItems.Add(dt.Rows[i][0].ToString());
                it.SubItems.Add(dt.Rows[i][1].ToString());
                it.SubItems.Add(dt.Rows[i][3].ToString());
                it.SubItems.Add(dt.Rows[i][4].ToString());
                it.SubItems.Add(dt.Rows[i][6].ToString());
                it.SubItems.Add(dt.Rows[i][7].ToString());
                it.SubItems.Add(String.Format("{0:dd/MM/yyyy}", dt.Rows[i][9]));
                it.SubItems.Add(dt.Rows[i][10].ToString());
                it.SubItems.Add(String.Format("{0:#,##0}", float.Parse(dt.Rows[i][15].ToString())));
                it.SubItems.Add(String.Format("{0:#,##0}", float.Parse(dt.Rows[i][16].ToString())));
                dsbuugui.Items.Add(it);
                dsach = dsbuugui;
            }
        }
Beispiel #18
0
    protected void txtmakh_TextChanged(object sender, EventArgs e)
    {
        string    sql = "select TenKH from KhachHang where SDT='" + txtmakh.Text + "'";
        DataTable dt  = kn.GetData(sql);

        if (dt.Rows.Count > 0)
        {
            txttenkh.Text    = dt.Rows[0][0].ToString();
            Session["sdt"]   = txtmakh.Text;
            Session["tenkh"] = txttenkh.Text;
        }
        else
        {
            txttenkh.Text = "";
        }
    }
Beispiel #19
0
    protected void LoadCmb(string sql, string textfield, string valuefield, DropDownList cmb, string name)
    {
        DataTable dt  = kn.GetData(sql);
        DataTable dt1 = new DataTable();

        dt1.Columns.Add(valuefield);
        dt1.Columns.Add(textfield);
        DataRow dr = dt1.NewRow();

        dr[valuefield] = 1;
        dr[textfield]  = name;
        dt1.Rows.Add(dr);
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            DataRow dr1 = dt.Rows[i];
            dt1.ImportRow(dr1);
        }

        cmb.DataSource     = dt1;
        cmb.DataTextField  = textfield;
        cmb.DataValueField = valuefield;
        cmb.DataBind();
    }
Beispiel #20
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["Tendangnhap"] == null)
     {
         Response.Redirect("~/DangNhap.aspx");
     }
     if (Session["GioHang"] == null)
     {
         Response.Redirect("~/DatHang.aspx");
     }
     if (Session["TenDangNhap"] != null)
     {
         string    s    = "select Tendangnhap,Matkhau,Sodienthoai,Email,DiaChi from TAIKHOAN where Tendangnhap = '" + Session["Tendangnhap"].ToString() + "'";
         DataTable dtkh = x.GetData(s);
         if (dtkh.Rows.Count > 0)
         {
             //KhachHangID = int.Parse(dt.Rows[0][0].ToString());
             lbHoTen.Text     = dtkh.Rows[0]["Tendangnhap"].ToString();
             lbDiaChi.Text    = dtkh.Rows[0]["Diachi"].ToString();
             lbDienThoai.Text = dtkh.Rows[0]["Sodienthoai"].ToString();
             lbEmail.Text     = dtkh.Rows[0]["Email"].ToString();
         }
     }
     if (Session["GioHang"] != null)
     {
         DataTable dtgh = new DataTable();
         dtgh = (DataTable)Session["GioHang"];
         gvGioHang.DataSource = dtgh;
         gvGioHang.DataBind();
     }
     if (Session["GioHang"] != null)
     {
         DataTable dtgh = new DataTable();
         dtgh = (DataTable)Session["GioHang"];
         System.String TongTien = "";
         foreach (DataRow r in dtgh.Rows)
         {
             r["ThanhTien"]  = r["Gia"];
             TongTien        = Convert.ToString(r["ThanhTien"]);
             lbtongtien.Text = TongTien.ToString();
         }
         gvGioHang.DataSource = dtgh;
         gvGioHang.DataBind();
     }
     if (!IsPostBack)
     {
         cldNgayGiaoHang.SelectedDate = DateTime.Today;
     }
 }
Beispiel #21
0
        private string maTuTang()
        {
            string sql = "SELECT Mabg FROM Danhsachbuugui";
            // Lấy DataTable từ câu truy vấn truyền vào (Apdapter Fill DataTable)
            DataTable tb = kn.GetData(sql);

            int[] arrCode = new int[tb.Rows.Count];
            int   code;

            for (int i = 0; i < tb.Rows.Count; i++)
            {
                code       = int.Parse(tb.Rows[i]["Mabg"].ToString().Remove(0, 2));
                arrCode[i] = code;
            }
            code = arrCode.Max() + 1;
            return("BK00" + code);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
         if (Session["tendn"] == null)
         {
             Response.Redirect("dangnhap.aspx");
         }
     if (Request.QueryString["mapx"] != null)
     {
         int maso = int.Parse(Request.QueryString["mapx"].ToString());
         DataTable dt = kn.GetData("select * from CTPhieuXuat where MaPhieu=" + maso);
         if (dt.Rows.Count <= 0)
         {
             kn.Execute("delete from PhieuXuat where MaPhieu=" + maso);
             xuathd.Visible = false;
         }
     }
 }
Beispiel #23
0
 private void btndoimk_Click(object sender, EventArgs e)
 {
     if (txtmkcu.Text != "" && txtmkmoi.Text != "" && txtnhaplaimk.Text != "")
     {
         DataTable dt = kn.GetData("select * from Dangnhap where MaND='" + DangNhap.mand + "' and MatKhau='" + txtmkcu.Text.Trim() + "'");
         if (dt.Rows.Count > 0)
         {
             if (txtmkmoi.Text.Trim() == txtnhaplaimk.Text.Trim())
             {
                 try
                 {
                     kn.Execute("update Dangnhap set MatKhau='" + txtmkmoi.Text.Trim() + "' where MaND='" + DangNhap.mand + "'");
                     MessageBox.Show("Đổi mật khẩu thành công", "Thông báo");
                 }
                 catch
                 {
                     MessageBox.Show("Đổi mật khẩu thất bại", "Thông báo");
                 }
             }
             else
             {
                 MessageBox.Show("Mật khẩu nhập lại không khớp", "Thông báo");
                 txtnhaplaimk.Text = "";
                 txtnhaplaimk.Focus();
             }
         }
         else
         {
             MessageBox.Show("Mật khẩu cũ không đúng", "Thông báo");
             txtmkcu.SelectAll();
             txtmkcu.Focus();
         }
     }
     else
     {
         MessageBox.Show("Vui lòng nhập đầy đủ thông tin", "Thông báo");
     }
 }
Beispiel #24
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["hc"] != null)
         {
             int       Masp = int.Parse(Request.QueryString["hc"]);
             DataTable dl   = x.GetData("SELECT IDSanPham,TenSP,HinhSP,HinhSP2,HinhSP3,HinhSP4,HinhSP5,MoTa,Gia,PhienBan,XuatXu,KieuGiang,TinhTrang,NamSanXuat,NoiBan,Odo,HopSo,MauNgoaiThat,MauNoiThat,SoCua,SoGhe,DungTichXiLanh,DanDong,NhienLieu FROM SANPHAM where IDSanPham=" + Masp);
             Masp = int.Parse(dl.Rows[0][0].ToString());
             string Tensp          = dl.Rows[0][1].ToString();
             string Hinhsp1        = dl.Rows[0][2].ToString();
             string Hinhsp2        = dl.Rows[0][3].ToString();
             string Hinhsp3        = dl.Rows[0][4].ToString();
             string Hinhsp4        = dl.Rows[0][5].ToString();
             string Hinhsp5        = dl.Rows[0][6].ToString();
             string Mota           = dl.Rows[0][7].ToString();
             string Giasp          = dl.Rows[0][8].ToString();
             string Phienban       = dl.Rows[0][9].ToString();
             string Xuatxu         = dl.Rows[0][10].ToString();
             string Kieugiang      = dl.Rows[0][11].ToString();
             string Tinhtrang      = dl.Rows[0][12].ToString();
             int    Namsanxuat     = Convert.ToInt32(dl.Rows[0][13].ToString());
             string Noiban         = dl.Rows[0][14].ToString();
             int    Odo            = Convert.ToInt32(dl.Rows[0][15].ToString());
             string Hopso          = dl.Rows[0][16].ToString();
             string Maungoaithat   = dl.Rows[0][17].ToString();
             string Maunoithat     = dl.Rows[0][18].ToString();
             int    Socua          = Convert.ToInt32(dl.Rows[0][19].ToString());
             int    Soghe          = Convert.ToInt32(dl.Rows[0][20].ToString());
             int    Dungtichxilanh = Convert.ToInt32(dl.Rows[0][21].ToString());
             string Dandong        = dl.Rows[0][22].ToString();
             string Nhienlieu      = dl.Rows[0][23].ToString();
             ThemVaodl(Masp, Tensp, Hinhsp1, Hinhsp2, Hinhsp3, Hinhsp4, Hinhsp5, Mota, Giasp, Phienban, Xuatxu, Kieugiang, Tinhtrang, Namsanxuat, Noiban, Odo, Hopso, Maungoaithat, Maunoithat, Socua, Soghe, Dungtichxilanh, Dandong, Nhienlieu);
             dlSanPham.DataSource = dl;
             dlSanPham.DataBind();
         }
     }
 }
Beispiel #25
0
 private void btndangnhap_Click(object sender, EventArgs e)
 {
     if (txttendn.Text != "" && txtmk.Text != "")
     {
         string    s  = "select MaND from Dangnhap where TenDN='" + txttendn.Text.Trim() + "' and MatKhau='" + txtmk.Text.Trim() + "'";
         DataTable dt = kn.GetData(s);
         if (dt.Rows.Count > 0)
         {
             mand = dt.Rows[0][0].ToString();
             Form_main frm = new Form_main();
             frm.Show();
             this.Hide();
         }
         else
         {
             MessageBox.Show("Đăng nhập thất bại", "Thông báo");
         }
     }
     else
     {
         MessageBox.Show("Vui lòng nhập đầy đủ thông tin", "Thông báo");
     }
 }
Beispiel #26
0
 protected void Page_Load(object sender, EventArgs e)
 {
     CheckDN();
     if (!IsPostBack)
     {
         if (Request.QueryString["hc"] != null)
         {
             int       Masp         = int.Parse(Request.QueryString["hc"]);
             DataTable dt           = x.GetData("SELECT TenSP,Gia,MauNgoaiThat,PhienBan,HinhSP FROM SANPHAM where IDSanPham=" + Masp);
             string    Tensp        = dt.Rows[0][0].ToString();
             string    Giasp        = dt.Rows[0][1].ToString();
             string    Maungoaithat = dt.Rows[0][2].ToString();
             string    Phienban     = dt.Rows[0][3].ToString();
             string    Hinhsp       = dt.Rows[0][4].ToString();
             ThemVaoGioHang(Tensp, Giasp, Maungoaithat, Phienban, Hinhsp);
         }
         if (Session["GioHang"] != null)
         {
             DataTable dt = new DataTable();
             dt = (DataTable)Session["GioHang"];
             System.String TongTien = "";
             foreach (DataRow r in dt.Rows)
             {
                 r["ThanhTien"]  = r["Gia"];
                 TongTien        = Convert.ToString(r["ThanhTien"]);
                 lbtongtien.Text = TongTien.ToString();
             }
             gvGioHang.DataSource = dt;
             gvGioHang.DataBind();
         }
         if (Session["GioHang"] == null)
         {
             Response.Write("<script> alert('Giỏ hàng rỗng !')</script>");
         }
     }
 }
 protected void LoadNguoiDung()
 {
     gvNguoiDung.DataSource = kn.GetData("select * from TaiKhoan");
     gvNguoiDung.DataBind();
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["malh"] != null)
         {
             gvLH.Visible = false;
             Label1.Text  = "Nội Dung";
             int       malh = int.Parse(Request.QueryString["malh"].ToString());
             string    sql  = "select * from LienHe where MaLH=" + malh;
             DataTable dt   = kn.GetData(sql);
             if (dt.Rows.Count > 0)
             {
                 lblhoten.Text  = dt.Rows[0]["HoTen"].ToString();
                 lblemail.Text  = dt.Rows[0]["Email"].ToString();
                 lblcauhoi.Text = dt.Rows[0]["NoiDung"].ToString();
                 if (dt.Rows[0]["TrangThai"].ToString() == "True")
                 {
                     traloi.Visible     = false;
                     btngui.Visible     = false;
                     txtnoidung.Visible = false;
                 }
             }
         }
         else if (Request.QueryString["timkiemlh"] != null)
         {
             gvLH.Visible       = false;
             lblcauhoi.Visible  = false;
             lblemail.Visible   = false;
             lblhoten.Visible   = false;
             email.Visible      = false;
             cauhoi.Visible     = false;
             hoten.Visible      = false;
             traloi.Visible     = false;
             txtnoidung.Visible = false;
             btngui.Visible     = false;
             Label1.Text        = "Tìm kiếm";
             string   ngay  = Request.QueryString["timkiemlh"].ToString();
             string[] chuoi = ngay.Split('-');
             string[] str   = chuoi[0].Split('/');
             string[] str1  = chuoi[1].Split('/');
             string   date  = str[2] + "-" + str[1] + "-" + str[0];
             string   date1 = str1[2] + "-" + str1[1] + "-" + str1[0];
             string   sql   = "";
             sql = "SELECT *, case when TrangThai=0 then N'Chưa phản hồi' else N'Đã phản hồi' end as TT from LienHe where NgayGui between '" + date + "' and '" + date1 + " 23:59:59' order by NgayGui desc";
             DataTable dt = kn.GetData(sql);
             gvLHTK.DataSource = dt;
             gvLHTK.DataBind();
             if (gvLHTK.Rows.Count == 0)
             {
                 Label1.Text = "Tìm kiếm: Không tìm thấy";
             }
         }
         else if (Request.QueryString["tim_malh"] != null)
         {
             int malh = int.Parse(Request.QueryString["tim_malh"].ToString());
             gvLH.Visible       = false;
             lblcauhoi.Visible  = false;
             lblemail.Visible   = false;
             lblhoten.Visible   = false;
             email.Visible      = false;
             cauhoi.Visible     = false;
             hoten.Visible      = false;
             traloi.Visible     = false;
             txtnoidung.Visible = false;
             btngui.Visible     = false;
             Label1.Text        = "Tìm kiếm";
             string    sql = "SELECT *, case when TrangThai=0 then N'Chưa phản hồi' else N'Đã phản hồi' end as TT from LienHe where MaLH=" + malh + " order by NgayGui desc";
             DataTable dt  = kn.GetData(sql);
             gvLHTK.DataSource = dt;
             gvLHTK.DataBind();
             if (gvLHTK.Rows.Count == 0)
             {
                 Label1.Text = "Tìm kiếm: Không tìm thấy";
             }
         }
         else if (Request.QueryString["tim_email"] != null)
         {
             string txtemail = Request.QueryString["tim_email"].ToString();
             gvLH.Visible       = false;
             lblcauhoi.Visible  = false;
             lblemail.Visible   = false;
             lblhoten.Visible   = false;
             email.Visible      = false;
             cauhoi.Visible     = false;
             hoten.Visible      = false;
             traloi.Visible     = false;
             txtnoidung.Visible = false;
             btngui.Visible     = false;
             Label1.Text        = "Tìm kiếm";
             string    sql = "SELECT *, case when TrangThai=0 then N'Chưa phản hồi' else N'Đã phản hồi' end as TT from LienHe where Email like '%" + txtemail + "%' order by NgayGui desc";
             DataTable dt  = kn.GetData(sql);
             gvLHTK.DataSource = dt;
             gvLHTK.DataBind();
             if (gvLHTK.Rows.Count == 0)
             {
                 Label1.Text = "Tìm kiếm: Không tìm thấy";
             }
         }
         else
         {
             lblcauhoi.Visible  = false;
             lblemail.Visible   = false;
             lblhoten.Visible   = false;
             email.Visible      = false;
             cauhoi.Visible     = false;
             hoten.Visible      = false;
             traloi.Visible     = false;
             txtnoidung.Visible = false;
             btngui.Visible     = false;
         }
         if (Request.QueryString["id"] != null)
         {
             int    ma = int.Parse(Request.QueryString["id"].ToString());
             string s  = "delete from LienHe where MaLH=" + ma;
             try
             {
                 kn.Execute(s);
                 Response.Write("<script> alert('Xóa thành công.');window.location='lienhe.aspx'; </script>");
             }
             catch
             {
                 Response.Write("<script> alert('Đã xảy ra lỗi. Vui lòng kiểm tra lại.') </script>");
             }
         }
     }
 }
Beispiel #29
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["madh"] != null)
         {
             gvDDH.Visible = false;
             lblten.Text   = "Chi Tiết Đơn Đặt Hàng";
             int       madh = int.Parse(Request.QueryString["madh"].ToString());
             DataTable dt   = kn.GetData("select TinhTrang from DonDatHang where MaDH=" + madh);
             if (dt.Rows[0][0].ToString() == "0")
             {
                 btnxacnhan.Visible = true;
             }
         }
         else if (Request.QueryString["id"] != null)
         {
             int    ma = int.Parse(Request.QueryString["id"].ToString());
             string s  = "delete from DonDatHang where MaDH=" + ma;
             try
             {
                 kn.Execute(s);
                 Response.Write("<script> alert('Xóa thành công.');window.location='dondathang.aspx'; </script>");
             }
             catch
             {
                 Response.Write("<script> alert('Đã xảy ra lỗi. Vui lòng kiểm tra lại.') </script>");
             }
         }
         else if (Request.QueryString["timkiemdh"] != null)
         {
             string   ngay  = Request.QueryString["timkiemdh"].ToString();
             string[] chuoi = ngay.Split('-');
             string[] str   = chuoi[0].Split('/');
             string[] str1  = chuoi[1].Split('/');
             string   date  = str[2] + "-" + str[1] + "-" + str[0];
             string   date1 = str1[2] + "-" + str1[1] + "-" + str1[0];
             string   sql   = "";
             sql = "SELECT *, case when TinhTrang=0 then N'Chưa giao' when TinhTrang=1 then N'Đã giao' else N'Đã hủy' end as TrangThai from DonDatHang where NgayDH between '" + date + "' and '" + date1 + " 23:59:59' order by NgayDH desc";
             DataTable dt = kn.GetData(sql);
             gvDDH.DataSource = dt;
             gvDDH.DataBind();
             if (gvDDH.Rows.Count == 0)
             {
                 lblten.Text = "Kết quả tìm kiếm: Không tìm thấy";
             }
             else
             {
                 lblten.Text = "Kết quả tìm kiếm: " + gvDDH.Rows.Count;
             }
         }
         else if (Request.QueryString["tim_madon"] != null)
         {
             int       madon = int.Parse(Request.QueryString["tim_madon"].ToString());
             string    sql   = "SELECT *, case when TinhTrang=0 then N'Chưa giao' when TinhTrang=1 then N'Đã giao' else N'Đã hủy' end as TrangThai from DonDatHang where MaDH=" + madon + "  order by NgayDH desc";
             DataTable dt    = kn.GetData(sql);
             gvDDH.DataSource = dt;
             gvDDH.DataBind();
             if (gvDDH.Rows.Count == 0)
             {
                 lblten.Text = "Kết quả tìm kiếm: Không tìm thấy";
             }
             else
             {
                 lblten.Text = "Kết quả tìm kiếm: " + gvDDH.Rows.Count;
             }
         }
         else if (Request.QueryString["tim_sdt"] != null)
         {
             string    sdt = Request.QueryString["tim_sdt"].ToString();
             string    sql = "SELECT *, case when TinhTrang=0 then N'Chưa giao' when TinhTrang=1 then N'Đã giao' else N'Đã hủy' end as TrangThai from DonDatHang where SDT='" + sdt + "'  order by NgayDH desc";
             DataTable dt  = kn.GetData(sql);
             gvDDH.DataSource = dt;
             gvDDH.DataBind();
             if (gvDDH.Rows.Count == 0)
             {
                 lblten.Text = "Kết quả tìm kiếm: Không tìm thấy";
             }
             else
             {
                 lblten.Text = "Kết quả tìm kiếm: " + gvDDH.Rows.Count;
             }
         }
         else
         {
             lblten.Text = "Danh Sách Đơn Đặt Hàng";
             string    sql = "select *, case when TinhTrang=0 then N'Chưa giao' when TinhTrang=1 then N'Đã giao' else N'Đã hủy' end TrangThai from DonDatHang";
             DataTable dt  = kn.GetData(sql);
             gvDDH.DataSource = dt;
             gvDDH.DataBind();
             gvCTDH.Visible = false;
         }
     }
 }
Beispiel #30
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["manvien"] != null)
         {
             txtmanv.Text   = Session["manvien"].ToString();
             txtngnhap.Text = String.Format("{0:dd/MM/yyyy HH:mm:ss}", DateTime.Now);
             LoadCmb("select MaSP,TenSP from SanPham", "TenSP", "MaSP", cmbmasp, "--- Sản phẩm ---");
             if (Request.QueryString["sp"] != null)
             {
                 try
                 {
                     int       masp    = int.Parse(Request.QueryString["sp"].ToString());
                     string    sql     = "select TenSP from SanPham where MaSP=" + masp;
                     DataTable dt1     = kn.GetData(sql);
                     string    tensp   = dt1.Rows[0][0].ToString();
                     float     dongia  = float.Parse(Session["dongia"].ToString());
                     int       soluong = int.Parse(Session["soluong"].ToString());
                     string    ghichu  = Session["ghichu"].ToString();
                     ThemCTPN(masp, tensp, dongia, soluong, ghichu);
                 }
                 catch
                 {
                     Response.Write("<script> alert('Đã xảy ra lỗi. Vui lòng kiểm tra lại.') </script>");
                 }
                 Session["soluong"] = 0;
                 Session["dongia"]  = 0;
             }
             if (Session["ctpn"] != null)
             {
                 float     tongtien = 0;
                 DataTable dt       = new DataTable();
                 dt = (DataTable)Session["ctpn"];
                 foreach (DataRow row in dt.Rows)
                 {
                     row["ThanhTien"]  = float.Parse(row["SoLuong"].ToString()) * float.Parse(row["DonGia"].ToString());
                     tongtien         += float.Parse(row["ThanhTien"].ToString());
                     lblthanhtien.Text = String.Format("{0:#,##0}", tongtien) + " đồng";
                 }
                 gvCTPN.DataSource = dt;
                 gvCTPN.DataBind();
                 btnHuy.Visible       = true;
                 btninphieu.Visible   = true;
                 lbltc.Visible        = true;
                 lblthanhtien.Visible = true;
                 btncapnhat.Visible   = true;
             }
             else
             {
                 Session["soluong"]   = null;
                 Session["ghichu"]    = null;
                 Session["dongia"]    = null;
                 btnHuy.Visible       = false;
                 btninphieu.Visible   = false;
                 lbltc.Visible        = false;
                 lblthanhtien.Visible = false;
                 btncapnhat.Visible   = false;
             }
         }
         else
         {
             Response.Redirect("dangnhap.aspx");
         }
     }
 }