예제 #1
0
        //insert function here
        public static bool InsertReservation(ReservationCS sr)
        {
            //declare return variable
            bool blnSuccess = false;
            //connection object -> ConfigurationManager namespace
            //access to web.config -> connection strings & key values
            SqlConnection cn = new SqlConnection(
                ConfigurationManager.ConnectionStrings["SE256_MurilloConnectionString"].ConnectionString);
            SqlCommand cmd = new SqlCommand("reservations_insert", cn);

            // Mark the Command -> Stored Procedure
            cmd.CommandType = CommandType.StoredProcedure;



            // cmd.Parameters.Add(
            //     "@res_id", SqlDbType.Int).Value = sr.Res_ID;
            // Add Parameters -> Stored Procedure
            cmd.Parameters.Add(
                "@guest_id", SqlDbType.Int).Value = sr.Guest_ID;
            cmd.Parameters.Add(
                "@tbl_id", SqlDbType.Int).Value = sr.Tbl_ID;
            cmd.Parameters.Add(
                "@user_id", SqlDbType.Int).Value = sr.User_ID;
            cmd.Parameters.Add(
                "@res_date", SqlDbType.Date).Value = sr.Res_Date;
            cmd.Parameters.Add(
                "@res_time", SqlDbType.Time).Value = sr.Res_Time;
            cmd.Parameters.Add(
                "@res_guest_cnt", SqlDbType.Int).Value = sr.Res_Guest_Cnt;
            cmd.Parameters.Add(
                "@res_spec_req", SqlDbType.VarChar).Value = sr.Res_Spec_Req;


            // Open database connection -> execute command
            try
            {
                cn.Open();
                //execute -> stored procedure
                cmd.ExecuteNonQuery();
                blnSuccess = true;
            }
            catch (Exception exc)
            {
                //error -> notify user
                exc.ToString();
                blnSuccess = false;
            }
            finally
            {
                cn.Close();
            }
            return(blnSuccess);
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!Request.IsAuthenticated)
            //{
            //    Response.Redirect("~/Login.aspx");
            //}

            //else
            //{

            if (!IsPostBack)
            {
                res_id = Convert.ToInt32(RouteData.Values["res_id"]);

                BindTime();
                if (res_id > 0)      // if there is a res id
                {
                    lbtnUpdate.Text   = "Update";
                    GUESTINFO.Visible = false;     // hide guest information on update hide

                    ReservationCS mt = new ReservationCS(res_id);
                    hidetxtGuestID.Value = mt.Guest_ID.ToString();     // make it hidden
                                                                       //txtGuestID.Text = mt.Guest_ID.ToString();
                    hidetxtTblID.Value = mt.Tbl_ID.ToString();         // make it hidden
                                                                       //txtTblID.Text = mt.Tbl_ID.ToString();
                    ddlEmployee.SelectedValue = mt.User_ID.ToString(); // changed it to ddl  user id to employee name   edited users get all sotred procedure
                                                                       //txtUserID.Text = mt.User_ID.ToString();

                    txtResDate.Text          = mt.Res_Date;
                    ddlResTime.SelectedValue = mt.Res_Time.ToString();
                    txtResGuestCnt.Text      = mt.Res_Guest_Cnt.ToString();
                    txtResSpecReq.Text       = mt.Res_Spec_Req;
                }
                else      // if no res id go to add
                {
                    //lbtnUpdate.Text = "Add";

                    GuestCS ng = new GuestCS();
                    txtGuestEmail.Text     = ng.Guest_Email;
                    txtGuestFirstName.Text = ng.Guest_First;
                    txtGuestLastName.Text  = ng.Guest_Last;
                    txtGuestPhone.Text     = ng.Guest_Phone;

                    ReservationCS mt = new ReservationCS(res_id);
                    ddlEmployee.SelectedValue = null;      // changed it to ddl  user id to employee name
                    txtResDate.Text           = String.Empty;
                    ddlResTime.SelectedValue  = null;
                    txtResGuestCnt.Text       = String.Empty;
                    txtResSpecReq.Text        = String.Empty;
                }
            }
            //  }
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int           res_id = Convert.ToInt32(RouteData.Values["res_id"]);
            ReservationCS mt     = new ReservationCS(res_id);



            lblRes_ID.Text   = String.Concat("Res_ID: ", mt.Res_ID).ToString();
            lblGuest_ID.Text = String.Concat("Guest_ID: ", mt.Guest_ID).ToString();
            lblTbl_ID.Text   = String.Concat("Tbl_ID: ", mt.Tbl_ID).ToString();
            lblUser_ID.Text  = String.Concat("User_ID: ", mt.User_ID).ToString();
            //  txtName.Text = String.Concat(mt.Item_Name);
            lblRes_Date.Text      = String.Concat("Res_Date: ", mt.Res_Date).ToString();
            lblRed_Time.Text      = String.Concat("Red_Time: ", mt.Red_Time).ToString();
            lblRes_Guest_Cnt.Text = String.Concat("Res_Guest_Cnt: ", mt.Res_Guest_Cnt).ToString();
            lblRes_Spec_Req.Text  = String.Concat("Res_Spec_Req: ", mt.Res_Spec_Req).ToString();
        }
예제 #4
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");
                }
            }
        }
예제 #5
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);
                //}
            }
        }