コード例 #1
0
        protected void lbtnUpdate_Click(object sender, EventArgs e)
        {
            string updateBUTTON = lbtnUpdate.Text;

            if (updateBUTTON == "Update")  // update user
            {
                UserCS sr = new UserCS();
                if (RouteData.Values["user_id"] != null)
                {
                    bool success = false;
                    sr.User_ID     = Convert.ToInt32(RouteData.Values["user_id"]);
                    sr.User_Email  = txtEmail.Text.Trim();
                    sr.User_First  = txtFirstName.Text.Trim();
                    sr.User_Last   = txtLastName.Text.Trim();
                    sr.User_Add1   = txtAddress1.Text.Trim();
                    sr.User_Add2   = txtAddress2.Text.Trim();
                    sr.User_City   = txtCity.Text.Trim();
                    sr.State_ID    = ddlStates.SelectedValue;
                    sr.User_Zip    = txtZip.Text.Trim();
                    sr.User_Salt   = txtPassword.Text.Trim();        // salt
                    sr.User_Pwd    = txtConfirmPassword.Text.Trim(); // password
                    sr.User_Phone  = txtPhone.Text.Trim();
                    sr.User_Active = chkIsActive.Checked;

                    success = UserCS.UpdateUser(sr);

                    if (success)
                    {
                        Response.Redirect("/Admin/Users");
                    }
                }
            }

            else  // inser user
            {
                bool   success = false;
                UserCS sr      = new UserCS();
                sr.User_Email  = txtEmail.Text.Trim();
                sr.User_First  = txtFirstName.Text.Trim();
                sr.User_Last   = txtLastName.Text.Trim();
                sr.User_Add1   = txtAddress1.Text.Trim();
                sr.User_Add2   = txtAddress2.Text.Trim();
                sr.User_City   = txtCity.Text.Trim();
                sr.State_ID    = ddlStates.SelectedValue;
                sr.User_Zip    = txtZip.Text.Trim();
                sr.User_Salt   = txtPassword.Text.Trim();
                sr.User_Pwd    = txtConfirmPassword.Text.Trim();
                sr.User_Phone  = txtPhone.Text.Trim();
                sr.User_Active = chkIsActive.Checked;

                success = UserCS.InsertUser(sr);

                if (success)
                {
                    Response.Redirect("/Admin/Users");
                }
            }
        }
コード例 #2
0
ファイル: User.aspx.cs プロジェクト: emurillojr/SofiasGrill
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Request.IsAuthenticated)
            {
                Response.Redirect("~/Login.aspx");
            }

            else
            {
                int user_id = Convert.ToInt32(RouteData.Values["user_id"]);
                if (!IsPostBack)
                {
                    if (user_id > 0)  //if there is a user id
                    {
                        lbtnUpdate.Text = "Update";
                        UserCS mt = new UserCS(user_id);
                        txtFirstName.Text       = mt.User_First;
                        txtLastName.Text        = mt.User_Last;
                        txtAddress1.Text        = mt.User_Add1;
                        txtAddress2.Text        = mt.User_Add2;
                        txtCity.Text            = mt.User_City;
                        ddlStates.SelectedValue = mt.State_ID.ToString();
                        txtZip.Text             = mt.User_Zip;
                        txtPassword.Text        = mt.User_Salt; //salt
                        txtConfirmPassword.Text = mt.User_Pwd;  // password
                        txtEmail.Text           = mt.User_Email;
                        txtConfirmEmail.Text    = mt.User_Email;
                        txtPhone.Text           = mt.User_Phone;
                        chkIsActive.Checked     = mt.User_Active;
                    }
                    else  // if there is no user id go to add
                    {
                        lbtnUpdate.Text = "Add";
                        UserCS mt = new UserCS(user_id);
                        txtFirstName.Text       = String.Empty;
                        txtLastName.Text        = String.Empty;
                        txtAddress1.Text        = String.Empty;
                        txtAddress2.Text        = String.Empty;
                        txtCity.Text            = String.Empty;
                        ddlStates.SelectedValue = null;
                        txtZip.Text             = String.Empty;
                        txtPassword.Text        = String.Empty; //salt
                        txtConfirmPassword.Text = String.Empty; //password
                        txtEmail.Text           = String.Empty;
                        txtConfirmEmail.Text    = String.Empty;
                        txtPhone.Text           = String.Empty;
                        chkIsActive.Checked     = false;
                    }
                }
            }
        }
コード例 #3
0
ファイル: User.aspx.cs プロジェクト: emurillojr/.NET
        protected void Page_Load(object sender, EventArgs e)
        {
            int    user_id = Convert.ToInt32(RouteData.Values["user_id"]);
            UserCS mt      = new UserCS(user_id);

            lblUser_ID.Text     = String.Concat("User_ID: ", mt.User_ID).ToString();
            lblUser_Email.Text  = String.Concat("User_Email: ", mt.User_Email).ToString();
            lblUser_First.Text  = String.Concat("User_First: ", mt.User_First).ToString();
            lblUser_Last.Text   = String.Concat("User_Last: ", mt.User_Last).ToString();
            lblUser_Add1.Text   = String.Concat("User_Add1: ", mt.User_Add1).ToString();
            lblUser_Add2.Text   = String.Concat("User_Add2: ", mt.User_Add2).ToString();
            lblUser_City.Text   = String.Concat("User_City: ", mt.User_City).ToString();
            lblState_ID.Text    = String.Concat("State_ID: ", mt.State_ID).ToString();
            lblUser_Zip.Text    = String.Concat("User_Zip: ", mt.User_Zip).ToString();
            lblUser_Phone.Text  = String.Concat("User_Phone: ", mt.User_Phone).ToString();
            lblUser_Active.Text = String.Concat("User_Active: ", mt.User_Active).ToString();
        }
コード例 #4
0
ファイル: Reservation.aspx.cs プロジェクト: emurillojr/.NET
        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);
                //}
            }
        }
コード例 #6
0
        //insert function here
        public static bool InsertUser(UserCS 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("users_insert", cn);

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


            cmd.Parameters.Add(
                "@user_email", SqlDbType.VarChar).Value = sr.User_Email;
            cmd.Parameters.Add(
                "@user_first", SqlDbType.VarChar).Value = sr.User_First;
            cmd.Parameters.Add(
                "@user_last", SqlDbType.VarChar).Value = sr.User_Last;
            cmd.Parameters.Add(
                "@user_add1", SqlDbType.VarChar).Value = sr.User_Add1;
            cmd.Parameters.Add(
                "@user_add2", SqlDbType.VarChar).Value = sr.User_Add2;
            cmd.Parameters.Add(
                "@user_city", SqlDbType.VarChar).Value = sr.User_City;
            cmd.Parameters.Add(
                "@state_id", SqlDbType.VarChar).Value = sr.State_ID;
            cmd.Parameters.Add(
                "@user_zip", SqlDbType.VarChar).Value = sr.User_Zip;

            cmd.Parameters.Add(
                "@user_salt", SqlDbType.VarChar).Value = sr.User_Salt;

            cmd.Parameters.Add(
                "@user_pwd", SqlDbType.VarChar).Value = sr.User_Pwd;
            cmd.Parameters.Add(
                "@user_phone", SqlDbType.VarChar).Value = sr.User_Phone;
            cmd.Parameters.Add(
                "@user_active", SqlDbType.Bit).Value = sr.User_Active;

            // 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);
        }