Ejemplo n.º 1
0
 protected void btDangNhap_Click1(object sender, EventArgs e)
 {
     try
     {
         DataTable dt1, dt2;
         dt1 = XLDL.GetData("select MaTV,TenTV from ThanhVien where Email = '" + txtEmail.Text + "' and MatKhau = '" + txtMatKhau.Text + "'");
         dt2 = XLDL.GetData("select MaAdmin,TenAdmin from Admin where Email = '" + txtEmail.Text + "' and MatKhau = '" + txtMatKhau.Text + "'");
         if (dt1.Rows.Count > 0)
         {
             Session["MaTV"]  = dt1.Rows[0][0].ToString();
             Session["TenTV"] = dt1.Rows[0][1].ToString();
             Response.Redirect("~/Index.aspx");
         }
         if (dt2.Rows.Count > 0)
         {
             Session["MaAdmin"]  = dt2.Rows[0][0].ToString();
             Session["TenAdmin"] = dt2.Rows[0][1].ToString();
             Response.Redirect("~/Admin/Admin.aspx");
         }
         else
         {
             Response.Write("<script>alert('sai tài khoản hoặc mật khẩu')</script>");
         }
     }
     catch
     {
         Response.Write("<script>alert('Có lỗi trong quá trình đăng nhập')</script>");
     }
 }
Ejemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     DataList1.DataSource = XLDL.GetData("select top 3 TT.*,TV.TenTV from TinTuc TT,ThanhVien TV where TV.MaTV = TT.MaTV and Duyet='1' order by NgayDang DESC");
     DataList1.DataBind();
     DataList2.DataSource = XLDL.GetData("select top 6 BD.*,TV.TenTV from BaiDang BD, ThanhVien TV where TV.MaTV = BD.MaTV and Duyet='1' order by NgayDang DESC");
     DataList2.DataBind();
 }
Ejemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack != true)
     {
         if (Request.QueryString["MaBai"] != null)/*xảy ra trường hợp 1*/
         {
             int       MaBai   = int.Parse(Request.QueryString["MaBai"]);
             DataTable dt      = XLDL.GetData("SELECT TieuDe,DonGia from BaiDang WHERE MaBai = " + MaBai);
             String    TieuDe  = dt.Rows[0][0].ToString();
             double    DonGia  = double.Parse(dt.Rows[0][1].ToString());
             int       SoLuong = 1;
             ThemVaoGioHang(MaBai, TieuDe, DonGia, SoLuong);
         }
         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.ToDouble(r["DonGia"]);
                 TongThanhTien       += Convert.ToDecimal(r["ThanhTien"]);
                 lbTongThanhTien.Text = TongThanhTien.ToString();
             }
             gvGioHang.DataSource = dt;
             gvGioHang.DataBind();
         }
     }
 }
Ejemplo n.º 4
0
        protected void btDongY_Click(object sender, EventArgs e)
        {
            int    httt = 0, htgh = 0;
            string TenNguoiNhan, DiaChiNhan, DienThoaiNhan;

            TenNguoiNhan  = txtNguoiNhan.Text;
            DiaChiNhan    = txtNguoiNhan.Text;
            DienThoaiNhan = txtDienThoai.Text;
            decimal tongthanhtien = decimal.Parse(lbTongTien.Text);

            // httt = Convert.ToInt32(rblHinhThucThanhToan.SelectedItem.Value);
            htgh = Convert.ToInt32(rblhinhThucGiaoHang.SelectedItem.Value);
            try
            {
                SqlConnection con = new SqlConnection(XLDL.strCon);
                con.Open();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.Text;
                cmd.Connection  = con;
                cmd.CommandText = @"insert into DonDatHang(MaTV,NgayDH,TriGia,NgayGH,TenNguoiNhan,DiaChiNhan,DTNhan,HTTT,HTGH)
                Values(" + Session["MaTV"] + ",@ngaydathang," + tongthanhtien + ",@ngaygiaohang,N'" + TenNguoiNhan + "',N'" + DiaChiNhan + "','" + DienThoaiNhan + "'," + httt + "," + htgh + ")";
                cmd.Parameters.Add("@ngaydathang", SqlDbType.SmallDateTime);
                cmd.Parameters["@ngaydathang"].Value = DateTime.Now;
                cmd.Parameters.Add("@ngaygiaohang", SqlDbType.SmallDateTime);
                cmd.Parameters["@ngaygiaohang"].Value = calNgayGiao.SelectedDate;
                cmd.ExecuteNonQuery();
                con.Close();

                //laymadonhang
                string    s    = @"Select max(MaDH) from  DonDatHang Where MaTV = " + Session["MaTV"];
                int       MaDH = int.Parse(XLDL.GetData(s).Rows[0][0].ToString());
                DataTable dt   = new DataTable();
                dt = (DataTable)Session["GioHang"];
                int    MaSP, SoLuong;
                double DonGia, ThanhTien;
                /* Luu san pham vao table CTDATHANG */
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    MaSP      = int.Parse(dt.Rows[i]["MaBai"].ToString());
                    SoLuong   = int.Parse(dt.Rows[i]["SoLuong"].ToString());
                    DonGia    = double.Parse(dt.Rows[i]["DonGia"].ToString());
                    ThanhTien = double.Parse(dt.Rows[i]["ThanhTien"].ToString());
                    s         = "INSERT INTO CTDatHang(MaDH,MaBai,SoLuong,DonGia,ThanhTien) VALUES(" + MaDH + "," + MaSP + "," + SoLuong + "," + DonGia + "," + ThanhTien + ")";
                    XLDL.Execute(s);
                    XLDL.Execute("Update BaiDang set TrangThai = '1' where MaBai = " + MaSP);
                }
                /* xoa gio hang sau khi da thuc hien xong dat hang*/
                Session["GioHang"] = null;
                /*Sau khi dat hang se chuyen toi trang XAc nhan don hang */
                Response.Redirect("~/Xacnhandonhang.aspx");
            }
            catch
            {
                lbThongBaoLoi.Text = "Lỗi trong quá trình cập nhật dữ liệu!";
            }
        }
Ejemplo n.º 5
0
        private void load()
        {
            int       MaTin = int.Parse(Request.QueryString["MaTin"]);
            DataTable dt    = new DataTable();

            dt                    = XLDL.GetData("Select TieuDe,TomTat,NoiDung from TinTuc where MaTin = " + MaTin);
            txtTieuDe.Text        = dt.Rows[0][0].ToString();
            txtTomTat.Text        = dt.Rows[0][1].ToString();
            CKEditorControl1.Text = dt.Rows[0][2].ToString();
        }
Ejemplo n.º 6
0
        private void capnhat()
        {
            string    chuoitk = Request.QueryString["chuoitk"];
            DataTable dt1, dt2;

            dt1 = XLDL.GetData("SELECT * FROM BaiDang WHERE TieuDe LIKE N'%" + chuoitk + "%' and Duyet = '1'");
            dt2 = XLDL.GetData("SELECT * FROM TinTuc WHERE TieuDe LIKE N'%" + chuoitk + "%' and Duyet = '1'");
            DataList1.DataSource = dt2;
            DataList1.DataBind();
            DataList2.DataSource = dt1;
            DataList2.DataBind();
        }
Ejemplo n.º 7
0
        private void load()
        {
            int       MaTin = int.Parse(Request.QueryString["MaTin"]);
            DataTable dt1, dt2;

            dt1                   = XLDL.GetData("select TieuDe,NoiDung from TinTuc where MaTin = " + MaTin);
            lbTieuDe.Text         = dt1.Rows[0][0].ToString();
            lbNoiDung.Text        = dt1.Rows[0][1].ToString();
            dt2                   = XLDL.GetData("select TV.TenTV, BLTT.NoiDung,BLTT.NgayBL from ThanhVien TV,BLTinTuc BLTT where TV.MaTV = BLTT.MaTV and BLTT.MaTin = " + MaTin + " order by NgayBL DESC");
            dlBinhLuan.DataSource = dt2;
            dlBinhLuan.DataBind();
        }
Ejemplo n.º 8
0
        private void load()
        {
            int       MaBai = int.Parse(Request.QueryString["MaBai"]);
            DataTable dt    = new DataTable();

            dt                    = XLDL.GetData("Select TieuDe,NoiDung,DonGia,TomTat,HinhMinhHoa from BaiDang where MaBai = " + MaBai);
            txtTieuDe.Text        = dt.Rows[0][0].ToString();
            CKEditorControl1.Text = dt.Rows[0][1].ToString();
            txtDonGia.Text        = dt.Rows[0][2].ToString();
            txtTomTat.Text        = dt.Rows[0][3].ToString();
            Image1.ImageUrl       = "~/Images/BaiDang/" + dt.Rows[0][4].ToString();
            Session["TenHinh"]    = dt.Rows[0][4].ToString();
        }
Ejemplo n.º 9
0
        private void load()
        {
            int       MaBai = int.Parse(Request.QueryString["MaBai"]);
            DataTable dt1, dt2, dt3;

            dt1                   = XLDL.GetData("select TieuDe,HinhMinhHoa,NoiDung from BaiDang where MaBai = " + MaBai);
            Image1.ImageUrl       = "~/Images/BaiDang/" + dt1.Rows[0][1].ToString();
            lbTieuDe.Text         = dt1.Rows[0][0].ToString();
            lbNoiDung.Text        = dt1.Rows[0][2].ToString();
            dt2                   = XLDL.GetData("select TV.TenTV, BLBD.NoiDung,BLBD.NgayBL from ThanhVien TV,BLBaiDang BLBD where TV.MaTV = BLBD.MaTV and BLBD.MaBai = " + MaBai + " order by NgayBL DESC");
            dlBinhLuan.DataSource = dt2;
            dlBinhLuan.DataBind();
            dt3           = XLDL.GetData("SELECT COUNT(*) as SLLike FROM Thich where MaBai = " + MaBai);
            lbSLLike.Text = dt3.Rows[0][0].ToString();
        }
Ejemplo n.º 10
0
        private void kiemtralike()
        {
            int       MaBai = int.Parse(Request.QueryString["MaBai"]);
            DataTable dt    = XLDL.GetData("select * from Thich where MaTV = " + Session["MaTV"] + " and MaBai = " + MaBai);

            if (dt.Rows.Count > 0)
            {
                btBoThich.Visible = true;
                btThich.Visible   = false;
            }
            else
            {
                btBoThich.Visible = false;
                btThich.Visible   = true;
            }
        }
Ejemplo n.º 11
0
        //decimal a;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack != true)
            {
                if (Session["MaTV"] == null)
                {
                    Response.Redirect("~/Dangnhap.aspx");
                }
                if (Session["GioHang"] == null)
                {
                    Response.Redirect("~/Giohang.aspx");
                }
                if (Session["MaTV"] != null)
                {
                    string    s  = @"select MaTV,TenTV,DiaChi,SDT,Email from ThanhVien where MaTV ='" + Session["MaTV"].ToString() + "'";
                    DataTable dt = XLDL.GetData(s);
                    if (dt.Rows.Count > 0)
                    {
                        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();
                        txtNguoiNhan.Text = dt.Rows[0][1].ToString();
                        txtDiaChi.Text    = dt.Rows[0][2].ToString();
                        txtDienThoai.Text = dt.Rows[0][3].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();

                        //Session["lbtongthanhtien"] = tongthanhtien;
                        // a = tongthanhtien;
                    }
                    gvGioHang.DataSource = dt;
                    gvGioHang.DataBind();
                }
                calNgayGiao.SelectedDate = DateTime.Today;
            }
        }
Ejemplo n.º 12
0
 protected void gvTinTuc_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Xoa")
     {
         try
         {
             int       chiso = int.Parse(e.CommandArgument.ToString());
             int       ma    = int.Parse(gvTinTuc.Rows[chiso].Cells[0].Text);
             DataTable dt    = XLDL.GetData("delete from TinTuc where MaTin =" + ma);
             Response.Write("<script>alert('Xóa thành công')</script>");
             laytintuc();
         }
         catch
         {
             Response.Write("<script>alert('Lỗi')</script>");
         }
     }
 }
Ejemplo n.º 13
0
 protected void btDangKy_Click(object sender, EventArgs e)
 {
     try
     {
         string str1 = @"select * from ThanhVien where Email = '" + txtEmail.Text + "'";
         if (XLDL.GetData(str1).Rows.Count > 0)
         {
             lbThongBaoLoi.Text = "Tên đăng nhập đã tồn tại";
             txtEmail.Focus();
         }
         else
         {
             SqlConnection con = new SqlConnection(XLDL.strCon);
             con.Open();
             SqlCommand cmd = new SqlCommand();
             cmd.CommandType = CommandType.Text;
             cmd.Connection  = con;
             cmd.CommandText = "INSERT INTO ThanhVien (TenTV,GioiTinh,NgaySinh,Email,MatKhau,DiaChi,SDT) VALUES (@tentv,@gioitinh,@ngaysinh,@email,@matkhau,@diachi,@sdt)";
             cmd.Parameters.Add("@tentv", SqlDbType.NVarChar, 50);
             cmd.Parameters["@tentv"].Value = txtHoTen.Text;
             cmd.Parameters.Add("@gioitinh", SqlDbType.Int);
             cmd.Parameters["@gioitinh"].Value = Convert.ToInt16(rblGioiTinh.SelectedItem.Value.Equals("Nam") ? 1 : 0);
             cmd.Parameters.Add("@ngaysinh", SqlDbType.SmallDateTime);
             cmd.Parameters["@ngaysinh"].Value = DateTime.Parse(txtNamSinh.Text + "-" + ddlThangSinh.Text + "-" + ddlNgaySinh.Text);
             cmd.Parameters.Add("@Email", SqlDbType.VarChar, 50);
             cmd.Parameters["@Email"].Value = txtEmail.Text;
             cmd.Parameters.Add("@matkhau", SqlDbType.VarChar, 50);
             cmd.Parameters["@matkhau"].Value = txtMatKhau.Text;
             cmd.Parameters.Add("@diachi", SqlDbType.NVarChar, 50);
             cmd.Parameters["@diachi"].Value = txtDiaChi.Text;
             cmd.Parameters.Add("@sdt", SqlDbType.VarChar, 10);
             cmd.Parameters["@sdt"].Value = txtDienThoai.Text;
             cmd.ExecuteNonQuery();
             con.Close();
             Response.Redirect("~/Dangnhap.aspx");
         }
     }
     catch
     {
         lbThongBaoLoi.Text = "Thất bại!";
     }
 }
Ejemplo n.º 14
0
        protected void btLuu_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = XLDL.GetData("select MatKhau from ThanhVien where MaTV = " + Session["MaTV"]);
                if (dt.Rows[0][0].ToString() == txtMKCu.Text)
                {
                    XLDL.Execute("UPDATE KHACHHANG Set MatKhau = '" + txtMKMoi.Text + "' where MaTV = " + Session["MaTV"]);

                    Response.Redirect("~/QLTaikhoan.aspx");
                }
                else
                {
                    lbThongBao.Text = "Mật khẩu cũ không đúng!";
                }
            }
            catch
            {
                lbThongBao.Text = "Thất bại!";
            }
        }
Ejemplo n.º 15
0
        protected void btDang_Click(object sender, EventArgs e)
        {
            if (DropDownList1.SelectedItem.Value == "0")
            {
                try
                {
                    string str1 = @"Select * from BaiDang Where TieuDe = '" + txtTieuDe.Text + "'";
                    if (XLDL.GetData(str1).Rows.Count > 0)
                    {
                        lbThongBao.Text = "Bài viết đã tồn tại";
                        txtTieuDe.Focus();
                    }
                    else
                    {
                        string sTenfile;
                        sTenfile = file_upload.FileName;

                        SqlConnection con = new SqlConnection(XLDL.strCon);
                        con.Open();
                        SqlCommand cmd = new SqlCommand();
                        cmd.CommandType = CommandType.Text;
                        cmd.Connection  = con;
                        cmd.CommandText = @"INSERT INTO BaiDang(TieuDe,NoiDung,DonGia,NgayDang,MaTV,TomTat,HinhMinhHoa) 
                                        VALUES(@tieude,@noidung,@dongia,@ngaydang,@matv,@tomtat,@hinhminhhoa)";
                        cmd.Parameters.Add("@tieude", SqlDbType.NVarChar, 50);
                        cmd.Parameters["@tieude"].Value = txtTieuDe.Text;
                        cmd.Parameters.Add("@noidung", SqlDbType.NText);
                        cmd.Parameters["@noidung"].Value = CKEditorControl1.Text.ToString();
                        cmd.Parameters.Add("@dongia", SqlDbType.Money);
                        cmd.Parameters["@dongia"].Value = txtDonGia.Text;
                        cmd.Parameters.Add("@ngaydang", SqlDbType.SmallDateTime);
                        cmd.Parameters["@ngaydang"].Value = DateTime.Today;
                        cmd.Parameters.Add("@matv", SqlDbType.Int);
                        cmd.Parameters["@matv"].Value = Session["MaTV"].ToString();
                        cmd.Parameters.Add("@tomtat", SqlDbType.NVarChar, 100);
                        cmd.Parameters["@tomtat"].Value = txtTomTat.Text;
                        cmd.Parameters.Add("@hinhminhhoa", SqlDbType.VarChar, 50);
                        cmd.Parameters["@hinhminhhoa"].Value = file_upload.FileName.ToString();
                        cmd.ExecuteNonQuery();
                        con.Close();
                        file_upload.SaveAs(MapPath("~/Images/BaiDang/" + sTenfile));
                        lbThongBao.Text = "Đăng bài thành công";
                        cleartable();
                    }
                }
                catch
                {
                    lbThongBao.Text = "Thất Bại!";
                }
            }
            if (DropDownList1.SelectedItem.Value == "1")
            {
                try
                {
                    string str1 = @"Select * from TinTuc Where TieuDe = '" + txtTieuDe.Text + "'";
                    if (XLDL.GetData(str1).Rows.Count > 0)
                    {
                        lbThongBao.Text = "Bài viết đã tồn tại";
                        txtTieuDe.Focus();
                    }
                    else
                    {
                        SqlConnection con = new SqlConnection(XLDL.strCon);
                        con.Open();
                        SqlCommand cmd = new SqlCommand();
                        cmd.CommandType = CommandType.Text;
                        cmd.Connection  = con;
                        cmd.CommandText = @"INSERT INTO TinTuc(TieuDe,TomTat,NoiDung,NgayDang,MaTV) 
                                        VALUES(@tieude,@tomtat,@noidung,@ngaydang,@matv)";
                        cmd.Parameters.Add("@tieude", SqlDbType.NVarChar, 50);
                        cmd.Parameters["@tieude"].Value = txtTieuDe.Text;
                        cmd.Parameters.Add("@noidung", SqlDbType.NText);
                        cmd.Parameters["@noidung"].Value = CKEditorControl1.Text.ToString();
                        cmd.Parameters.Add("@ngaydang", SqlDbType.SmallDateTime);
                        cmd.Parameters["@ngaydang"].Value = DateTime.Today;
                        cmd.Parameters.Add("@matv", SqlDbType.Int);
                        cmd.Parameters["@matv"].Value = Session["MaTV"].ToString();
                        cmd.Parameters.Add("@tomtat", SqlDbType.NVarChar, 200);
                        cmd.Parameters["@tomtat"].Value = txtTomTat.Text;
                        cmd.ExecuteNonQuery();
                        con.Close();
                        lbThongBao.Text = "Đăng thành công. Xin chờ quản trị viên duyệt bài!";
                        cleartable();
                    }
                }
                catch
                {
                    lbThongBao.Text = "Thất Bại!";
                }
            }
        }
Ejemplo n.º 16
0
 private void laytintuc()
 {
     DataList1.DataSource = XLDL.GetData("select TT.*,TV.TenTV from TinTuc TT,ThanhVien TV where TV.MaTV = TT.MaTV and Duyet='1' order by NgayDang DESC");
     DataList1.DataBind();
 }
Ejemplo n.º 17
0
 private void laybaidang()
 {
     gvDangBan.DataSource = XLDL.GetData("Select * from BaiDang where MaTV = " + Session["MaTV"] + " order by NgayDang DESC ");
     gvDangBan.DataBind();
 }
Ejemplo n.º 18
0
 private void laytintuc()
 {
     gvTinTuc.DataSource = XLDL.GetData("select * from TinTuc where MaTV = " + Session["MaTV"] + " order by NgayDang DESC ");
     gvTinTuc.DataBind();
 }