コード例 #1
0
        protected void btnregister_Click(object sender, EventArgs e)
        {
            using (var db = new HotelReservationEntities3())
            {
                login login = new login();
                login.userid    = txtuname.Text;
                login.passsword = txtpassword.Text;

                userdetail user = new userdetail();
                user.userid        = txtuname.Text;
                user.name          = txtname.Text;
                user.passportno    = txtnirc.Text;
                user.email_phoneno = txtemail.Text;

                db.logins.Add(login);
                db.SaveChanges();
                db.userdetails.Add(user);
                db.SaveChanges();

                Session["user"]       = login;
                Session["userdetail"] = user;

                Response.Redirect("BookingConfirmation.aspx");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Noofrooms.Text = Convert.ToString(Session["noofrooms"]);
            noofroom       = Convert.ToInt16(Noofrooms.Text);
            Checkin.Text   = Convert.ToString(Session["checkindate"]);
            Checkout.Text  = Convert.ToString(Session["checkout"]);
            Roomtype.Text  = Convert.ToString(Session["roomtype"]);
            x1             = Roomtype.Text;
            // Noofpeople.Text = Convert.ToString(Session["noofpeople"]);
            // String x1 = Convert.ToString(Session["roomnum"]);
            // String x2 = x1;

            // Label16.Text = Convert.ToString(Session["roomnum"]);
            numgen = Convert.ToInt16(Session["roomnum"]);
            //x1=Request.Cookies["roomnum"].Value;
            //numgen = Convert.ToInt16(x1);
            if (x1.Equals("s"))
            {
                Label16.Text = " 1 person/room";
            }
            else if (x1.Equals("d"))
            {
                Label16.Text = " 2 person/room";
            }
            else if (x1.Equals("du"))
            {
                Label16.Text = " 3 person/room";
            }
            else if (x1.Equals("su"))
            {
                Label16.Text = " 5 person/room";
            }

            login login = (login)Session["user"];

            if (login != null)
            {
                userdetail detail = (userdetail)Session["userdetail"];
                TextBox3.Text = detail.name;
                TextBox4.Text = detail.passportno;
                TextBox5.Text = detail.email_phoneno;

                Label2.Text = "Member Infromation";
                Label6.Text = "Member Name";

                Label17.Visible = false;
            }
        }
        protected void Button3_Click(object sender, EventArgs e)
        {
            using (HotelReservationEntities3 db = new HotelReservationEntities3())
            {
                var login = db.logins.Find(TextBox1.Text);
                if (login != null)
                {
                    if (login.passsword.Trim() == TextBox2.Text.Trim())
                    {
                        Session["user"] = login;

                        HotelReservationEntities3 context = new HotelReservationEntities3();

                        var query = from x in context.userdetails
                                    where x.userid == login.userid
                                    select x;


                        userdetail detail = query.First();
                        TextBox3.Text       = detail.name;
                        Session["MainName"] = detail.name;
                        TextBox4.Text       = detail.passportno;
                        TextBox5.Text       = detail.email_phoneno;

                        Session["userdetail"] = detail;
                        Label2.Text           = "Member Infromation";
                        Label6.Text           = "Member Name";

                        Label17.Visible = false;
                        //Response.Redirect("");
                    }
                    else
                    {
                        Label17.Visible = true;
                    }
                }
                else
                {
                    Label17.Visible = true;
                }
            }
        }