コード例 #1
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            UserServiceRef.User newUser = new UserServiceRef.User();
            newUser.firstName = txtFirstName.Text;
            newUser.lastName  = txtLastName.Text;
            newUser.email     = txtEmail.Text;
            newUser.password  = txtPassword1.Text;

            if (String.IsNullOrEmpty(newUser.firstName))
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "ValidationAlertScript", "alert('First name must be at least 2 characters long.')", true);
                return;
            }

            if (String.IsNullOrEmpty(newUser.lastName))
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "ValidationAlertScript", "alert('Last name must be at least 2 characters long.')", true);
                return;
            }

            if (String.IsNullOrEmpty(newUser.email))
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "ValidationAlertScript", "alert('Please enter a valid email.')", true);
                return;
            }

            if (String.IsNullOrEmpty(newUser.password))
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "ValidationAlertScript", "alert('Please enter a valid password.')", true);
                return;
            }

            UserServiceRef.UserService pxy = new UserServiceRef.UserService();
            bool emailUsed = pxy.CheckForEmail(newUser.email);

            if (emailUsed)
            {
                pxy.AddUser(newUser);
                Response.Redirect("Login.aspx");
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "ValidationAlertScript", "alert('The chosen email is already used, please login if you already have an account, or use another email id.')", true);
            }
        }
コード例 #2
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            UserServiceRef.User newUser = new UserServiceRef.User();
            newUser.firstName = txtFirstName.Text;
            newUser.lastName = txtLastName.Text;
            newUser.email = txtEmail.Text;
            newUser.password = txtPassword1.Text;

            if (String.IsNullOrEmpty(newUser.firstName))
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "ValidationAlertScript", "alert('First name must be at least 2 characters long.')", true);
                return;
            }

            if (String.IsNullOrEmpty(newUser.lastName))
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "ValidationAlertScript", "alert('Last name must be at least 2 characters long.')", true);
                return;
            }

            if (String.IsNullOrEmpty(newUser.email))
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "ValidationAlertScript", "alert('Please enter a valid email.')", true);
                return;
            }

            if (String.IsNullOrEmpty(newUser.password))
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "ValidationAlertScript", "alert('Please enter a valid password.')", true);
                return;
            }

            UserServiceRef.UserService pxy = new UserServiceRef.UserService();
            bool emailUsed = pxy.CheckForEmail(newUser.email);

            if (emailUsed)
            {
                pxy.AddUser(newUser);
                Response.Redirect("Login.aspx");
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "ValidationAlertScript", "alert('The chosen email is already used, please login if you already have an account, or use another email id.')", true);
            }
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["email"] != null)
            {
                UserServiceRef.UserService pxy = new UserServiceRef.UserService();
                bool emailExists = pxy.CheckForEmail(Request["email"]);
                if (emailExists)
                {
                    Response.Write("false");
                }
                else
                {
                    Response.Write("true");
                }
            }
            else if ((Request["chat_post"] != null) && (Request["chat_username"] != null))
            {
                SqlCommand objCommand = new SqlCommand();
                objCommand.CommandType = CommandType.StoredProcedure;
                objCommand.CommandText = "PostChat";
                objCommand.Parameters.AddWithValue("@email", Request["chat_username"]);
                objCommand.Parameters.AddWithValue("@chat", Request["chat_post"]);

                DBConnect objDB = new DBConnect();
                objDB.DoUpdateUsingCmdObj(objCommand);
            }
            else if (Request["get_chat_username"] != null)
            {
                SqlCommand objCommand = new SqlCommand();
                objCommand.CommandType = CommandType.StoredProcedure;
                objCommand.CommandText = "GetChat";
                objCommand.Parameters.AddWithValue("@email", Request["get_chat_username"]);

                DBConnect objDB = new DBConnect();
                DataSet   myDS  = objDB.GetDataSetUsingCmdObj(objCommand);

                string response = "";
                for (int i = 0; i < myDS.Tables[0].Rows.Count; i++)
                {
                    DataRow currRow = myDS.Tables[0].Rows[i];
                    response += "<p>" + currRow["chat"] + "</p>";
                }

                Response.Write(response);
            }
            else if (Request["get_chat_rooms"] != null)
            {
                SqlCommand objCommand = new SqlCommand();
                objCommand.CommandType = CommandType.StoredProcedure;
                objCommand.CommandText = "GetChatRooms";

                DBConnect objDB = new DBConnect();
                DataSet   myDS  = objDB.GetDataSetUsingCmdObj(objCommand);

                string response = "";
                for (int i = 0; i < myDS.Tables[0].Rows.Count; i++)
                {
                    DataRow currRow = myDS.Tables[0].Rows[i];
                    response += "<option value='" + currRow["email"] + "'>" + currRow["email"] + "</option>";
                }

                Response.Write(response);
            }
        }
コード例 #4
0
 protected void btnTestCheckEmail_Click(object sender, EventArgs e)
 {
     UserServiceRef.UserService pxy = new UserServiceRef.UserService();
     lblReserveResult.Text = "TestCheckEmail method executed successfully (SHOULD RETURN FALSE SINCE USER EXISTS): "
         + pxy.CheckForEmail("*****@*****.**");
 }
コード例 #5
0
 protected void btnTestCheckEmail_Click(object sender, EventArgs e)
 {
     UserServiceRef.UserService pxy = new UserServiceRef.UserService();
     lblReserveResult.Text = "TestCheckEmail method executed successfully (SHOULD RETURN FALSE SINCE USER EXISTS): "
                             + pxy.CheckForEmail("*****@*****.**");
 }