예제 #1
0
        protected void lbtnUpdate_Click(object sender, EventArgs e)
        {
            string updateBUTTON = lbtnUpdate.Text;

            if (updateBUTTON == "Update")   // update reservation
            {
                ReservationCS sr = new ReservationCS();
                if (RouteData.Values["res_id"] != null)
                {
                    bool success = false;
                    sr.Res_ID   = Convert.ToInt32(RouteData.Values["res_id"]);
                    sr.Guest_ID = Convert.ToInt32(hidetxtGuestID.Value);     // make it hidden
                    //sr.Guest_ID = Convert.ToInt32(txtGuestID.Text.Trim());
                    sr.Tbl_ID = Convert.ToInt32(hidetxtTblID.Value);         // make it hidden
                    //sr.Tbl_ID = Convert.ToInt32(txtTblID.Text.Trim());
                    sr.User_ID = Convert.ToInt32(ddlEmployee.SelectedValue); // changed it to ddl  user id to employee name
                    //sr.User_ID = Convert.ToInt32(txtUserID.Text.Trim());
                    sr.Res_Date      = txtResDate.Text.ToString();
                    sr.Res_Time      = txtResTime.Text.ToString();
                    sr.Res_Guest_Cnt = Convert.ToInt32(txtResGuestCnt.Text.Trim());
                    sr.Res_Spec_Req  = txtResSpecReq.Text.Trim();

                    success = ReservationCS.UpdateReservation(sr);

                    if (success) // if update reservation is true
                    {
                        Response.Redirect("/Admin/Res-Management");
                    }
                }
            }

            else  // insert reservation
            {
                bool success = false;


                GuestCS gr = new GuestCS();
                gr.Guest_Pwd   = UserCS.CreatePasswordHash(gr.Guest_Salt, "password"); // set password to password
                gr.Guest_Email = txtGuestEmail.Text.Trim();
                gr.Guest_First = txtGuestFirstName.Text.Trim();
                gr.Guest_Last  = txtGuestLastName.Text.Trim();
                gr.Guest_Phone = txtGuestPhone.Text.Trim();

                ReservationCS sr = new ReservationCS();
                sr.Guest_ID = GuestCS.InsertGuest(gr);  // guest id = new id

                //sr.Guest_ID = Convert.ToInt32(hidetxtGuestID.Value);  // make it hidden

                // table id = get availble table (date, time, guestcount)
                sr.Tbl_ID = ReservationCS.GetAvailableTable(txtResDate.Text, txtResTime.Text, Convert.ToInt32(txtResGuestCnt.Text.Trim()));  // card coded for test


                //sr.Tbl_ID = Convert.ToInt32(hidetxtTblID.Value);  // make it hidden

                sr.User_ID = Convert.ToInt32(ddlEmployee.SelectedValue.ToString());  // changed it to ddl  user id to employee name
                //sr.User_ID = Convert.ToInt32(txtUserID.Text.Trim());
                sr.Res_Date      = txtResDate.Text.Trim();
                sr.Res_Time      = txtResTime.Text.Trim();
                sr.Res_Guest_Cnt = Convert.ToInt32(txtResGuestCnt.Text.Trim());
                sr.Res_Spec_Req  = txtResSpecReq.Text.Trim();

                success = ReservationCS.InsertReservation(sr);

                if (success) // if insert guest and reservation is true
                {
                    Response.Redirect("/Admin/Res-Management");
                }
            }
        }
예제 #2
0
        protected void lbtnUpdate_Click(object sender, EventArgs e)
        {
            ReservationCS sr = new ReservationCS();

            //string updateBUTTON = lbtnUpdate.Text;

            //    if (updateBUTTON == "Update")   // update reservation
            //   {
            //ReservationCS sr = new ReservationCS();
            if (RouteData.Values["res_id"] != null)
            {
                bool success = false;
                sr.Res_ID   = Convert.ToInt32(RouteData.Values["res_id"]);
                sr.Guest_ID = Convert.ToInt32(hidetxtGuestID.Value);     // make it hidden
                                                                         //sr.Guest_ID = Convert.ToInt32(txtGuestID.Text.Trim());
                sr.Tbl_ID = Convert.ToInt32(hidetxtTblID.Value);         // make it hidden
                                                                         //sr.Tbl_ID = Convert.ToInt32(txtTblID.Text.Trim());
                sr.User_ID = Convert.ToInt32(ddlEmployee.SelectedValue); // changed it to ddl  user id to employee name
                                                                         //sr.User_ID = Convert.ToInt32(txtUserID.Text.Trim());
                sr.Res_Date      = txtResDate.Text.ToString();
                sr.Res_Time      = ddlResTime.SelectedValue.ToString();
                sr.Res_Guest_Cnt = Convert.ToInt32(txtResGuestCnt.Text.Trim());
                sr.Res_Spec_Req  = txtResSpecReq.Text.Trim();

                success = ReservationCS.UpdateReservation(sr);

                if (success) // if update reservation is true
                {
                    Response.Redirect("/Admin/Res-Management");
                }
            }
            // }

            else  // insert reservation
            {
                //bool success = false;
                int new_id = 0;

                GuestCS ng = new GuestCS();

                ng.Guest_Pwd   = UserCS.CreatePasswordHash(ng.Guest_Salt, "password");
                ng.Guest_First = txtGuestFirstName.Text.Trim();
                ng.Guest_Last  = txtGuestLastName.Text.Trim();

                ng.Guest_Email = txtGuestEmail.Text.Trim();
                ng.Guest_Phone = txtGuestPhone.Text.Trim();

                GuestCS g = new GuestCS(txtGuestEmail.Text);
                if (g.Guest_ID > 0)
                {
                    sr.Guest_ID = g.Guest_ID;
                }
                else
                {
                    sr.Guest_ID = GuestCS.InsertGuest(ng);
                }
                //ReservationCS sr = new ReservationCS();
                // sr.Guest_ID = GuestCS.InsertGuest(ng);  // guest id = new id

                sr.Tbl_ID        = ReservationCS.GetAvailableTable(txtResDate.Text, ddlResTime.SelectedValue, Convert.ToInt32(txtResGuestCnt.Text)); // card coded for test
                sr.User_ID       = Convert.ToInt32(ddlEmployee.SelectedValue.ToString());                                                            // changed it to ddl  user id to employee name
                sr.Res_Date      = txtResDate.Text.Trim();
                sr.Res_Time      = ddlResTime.SelectedValue;
                sr.Res_Guest_Cnt = Convert.ToInt32(txtResGuestCnt.Text);
                sr.Res_Spec_Req  = txtResSpecReq.Text.Trim();

                new_id = ReservationCS.InsertReservation(sr);

                //if (success) // if insert guest and reservation is true
                //{
                //    Response.Redirect("/Admin/Res-Management");
                //}
                //else
                //{
                lblError.Text = String.Concat("The Email " + ng.Guest_Email + " The Reservation id is " + new_id);
                //}
            }
        }