Exemple #1
0
        public string getAnhDaiDien(string MaTour)
        {
            TourDLEntities db = new TourDLEntities();

            QLTour.Tour obj = db.Tour.FirstOrDefault(x => x.MaTour == MaTour);
            if (obj.Media.Count(x => x.Main == true) > 0)
            {
                return(obj.Media.First(x => x.Main == true).Url);
            }
            else
            {
                return("");
            }
        }
Exemple #2
0
        public void getKhachSan(string MaTour)
        {
            TourDLEntities db = new TourDLEntities();

            QLTour.CTTour obj    = db.CTTour.FirstOrDefault(x => x.MaTour == MaTour);
            string        MaDDDL = obj.MaDDDL.ToString();

            string MaKS = db.KhachSan.First(x => x.MaDDDL == MaDDDL).MaKS;

            lbKhachSan.Text = db.KhachSan.First(x => x.MaKS == MaKS).TenKS;

            //QLTour.DiaDiemDL obj1 = db.DiaDiemDL.FirstOrDefault(x => x.MaDDDL == MaDDDL);
            //string MaKS = obj1.Ma.ToString();
            //lbKhachSan.Text = db.KhachSan.First(x => x.MaKS == MaKS).TenKS;
        }
Exemple #3
0
        public string getmatour()
        {
            TourDLEntities db    = new TourDLEntities();
            string         maMax = db.Tour.Max(x => x.MaTour);
            //
            string ma;
            int    a = int.Parse(maMax.Substring(2));

            a++;
            if (a < 10)
            {
                ma = "kh00" + a;
            }
            else
            {
                ma = "kh0" + a;
            }
            return(ma);
        }
Exemple #4
0
 public void getInfoKH()
 {
     try
     {
         //Load dữ liệu
         string abc = Session["TaiKhoan"].ToString();
         // Query về db để lấy các thông tin còn lại
         TourDLEntities   db  = new TourDLEntities();
         QLTour.KhachHang obj = db.KhachHang.FirstOrDefault(x => x.TaiKhoan == abc);
         lbTenKH.Text  = obj.TenKH;
         lbDiaChi.Text = obj.DiaChi;
         lbSoDT.Text   = obj.SDT;
         string makh = obj.MaKH;
     }
     catch (Exception)
     {
         Response.Redirect("Login.aspx");
     }
 }
Exemple #5
0
 protected void btnRegister_Click(object sender, EventArgs e)
 {
     try
     {
         TourDLEntities db       = new TourDLEntities();
         string         taikhoan = txtTaiKhoan.Text;
         int            soluong  = db.KhachHang.Count(x => x.TaiKhoan == taikhoan);
         if (soluong == 1)
         {
             //Tài khoản đã tồn tại
             lbError.Text = "tài khoản đã tồn tại!";
         }
         if (txtMatKhau.Text == txtXTMatKhau.Text && txtTaiKhoan.Text != null && txtXTMatKhau.Text != null)
         {
             //check điều kiện
             QLTour.KhachHang obj = db.KhachHang.FirstOrDefault(x => x.TaiKhoan == txtTaiKhoan.Text);
             obj          = new QLTour.KhachHang();
             obj.MaKH     = getmatour();
             obj.TenKH    = null;
             obj.GioiTinh = null;
             obj.QuocTich = null;
             obj.CMND     = null;
             obj.DiaChi   = null;
             obj.SDT      = null;
             obj.TaiKhoan = txtTaiKhoan.Text;
             obj.Matkhau  = mahoa(txtMatKhau.Text);
             db.KhachHang.Add(obj);
             db.SaveChanges();
             Response.Redirect("Login.aspx");
         }
         else
         {
             //lỗi
             lbError.Text = "Thông tin không chính xác";
         }
     }
     catch (Exception)
     {
         lbError.Text = "Không thể tạo tài khoản!";
     }
 }
Exemple #6
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            //Do MD5 Hashing...
            byte[] hs   = new byte[50];
            string pass = txtMatKhau.Text;
            MD5    md5  = MD5.Create();

            byte[]        inputBytes = System.Text.Encoding.ASCII.GetBytes(pass);
            byte[]        hash       = md5.ComputeHash(inputBytes);
            StringBuilder sb         = new StringBuilder();

            for (int i = 0; i < hash.Length; i++)
            {
                hs[i] = hash[i];
                sb.Append(hs[i].ToString("x2"));
            }
            var hash_pass = sb.ToString();

            string taikhoan = txtTaiKhoan.Text;
            //string TenKhachHang;
            //

            TourDLEntities db      = new TourDLEntities();
            int            soluong = db.KhachHang.Count(x => x.TaiKhoan == taikhoan && x.Matkhau == hash_pass);

            if (soluong == 1)
            {
                // Dang nhap thanh cong, gán seesion
                Session["TaiKhoan"] = taikhoan;
                //QLTour.KhachHang obj = db.KhachHang.FirstOrDefault(x => x.TaiKhoan == taikhoan);
                //Session["MaKH"] = obj.MaKH;
                //
                Response.Redirect("Home.aspx");
            }
            else
            {
                lbError.Text = "Tài khoản hoặc mật khẩu không đúng!";
            }
        }
Exemple #7
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                TourDLEntities db = new TourDLEntities();

                QLTour.Contact obj = new QLTour.Contact();
                obj.Name    = txtName.Text;
                obj.Email   = txtEmail.Text;
                obj.Subject = txtSubject.Text;
                obj.Message = txtMessage.Text;

                db.Contact.Add(obj);
                db.SaveChanges();
                //Response.Write("<script>alert('Gửi thành công!');</script>");
                Response.Redirect("Contacts.aspx");
            }
            catch (Exception)
            {
                // Lỗi
                Response.Write("<script>alert('Gửi thất bại!');</script>");
            }
        }
Exemple #8
0
        void getData(/*string src*/)
        {
            try
            {
                TourDLEntities db = new TourDLEntities();

                List <QLTour.Tour> lstTour = db.Tour.ToList();
                List <string>      lst     = new List <string>();
                int c = 1;
                for (int i = 0; i < txtSearch.Text.Length; i++)
                {
                    if (txtSearch.Text[i] == ' ')
                    {
                        c++;
                    }
                }
                string[] tu = txtSearch.Text.Split(' ');
                for (int i = 0; i < c; i++)
                {
                    lst.Add(tu[i]);
                }
                string             src  = Request.QueryString["src"].ToString();
                List <QLTour.Tour> lstT = db.Tour.Where(x => lst.Any(k => x.TenTour.Contains(src))).ToList();
                int t1 = lstT.Count();
                for (int i = 0; i < t1; i++)
                {
                    Tour obj = lstT.ElementAt(i);
                }
                //List<QLTour.Tour> lst = db.Tour.OrderBy(x => x.MaTour).Take(5).ToList();
                rpSanPhamHot.DataSource = lstT;
                rpSanPhamHot.DataBind();
            }
            catch (Exception)
            {
                lbNotFound.Text = "Không tìm thấy kết quả phù hợp";
            }
        }
        //public void getLoaiTour(string MaTour)
        //{
        //    TourDLEntities db = new TourDLEntities();
        //    int soluong = db.Tour.Count(x => x.MaLoaiTour.ToString() == "lt001");
        //    if (soluong == 1)
        //    {
        //        lbLoaiTour.Text = "Tour trong nước";
        //    }
        //    else
        //    {
        //        lbLoaiTour.Text = "Tour ngoài nước hay còn gọi là tour nước ngoài";
        //    }
        //}
        //public void getMaxUser(string MaTour)
        //{
        //    //Load  Max user
        //    TourDLEntities db = new TourDLEntities();
        //    List<QLTour.Tour> max = db.Tour.Where(x => x.MaTour == MaTour).ToList();
        //    rpLichTrinh.DataSource = max;
        //    rpLichTrinh.DataBind();
        //}
        public string getLoaiPT(string MaPT)
        {
            TourDLEntities db = new TourDLEntities();

            return(db.PhuongTien.First(x => x.MaPT == MaPT).TenPT);
        }
        public string getLoaiTour(string MaLoaiTour)
        {
            TourDLEntities db = new TourDLEntities();

            return(db.LoaiTour.First(x => x.MaLoaiTour == MaLoaiTour).TenLoaiTour);
        }
Exemple #11
0
        public void getTenTour(string MaTour)
        {
            TourDLEntities db = new TourDLEntities();

            lbTenTour.Text = db.Tour.First(x => x.MaTour == MaTour).TenTour;
        }
Exemple #12
0
        public void getMaTour(string MaLT)
        {
            TourDLEntities db = new TourDLEntities();

            lbMaTour.Text = db.LichTrinh.First(x => x.MaLT == MaLT).MaTour;
        }