protected void btnRegister_Click(object sender, EventArgs e)
        {
            Classes.Validation objValidate = new Classes.Validation();
            bool error = false;
            litError.Text = "";

            if (!objValidate.isValidName(txtName.Text.ToString()))
            {
                error = true;
                litError.Text += "Invalid Name<br>";
            }

            if (!objValidate.isValidEmail(txtEmail.Text.ToString()))
            {
                error = true;
                litError.Text += "Invalid Email Address<br>";
            }

            if (!objValidate.isValidPassword(txtPassword.Text.ToString()))
            {
                error = true;
                litError.Text += "Invalid Password<br>";
            }

            if (txtPassword.Text.ToString() != txtRePassword.Text.ToString())
            {
                error = true;
                litError.Text += "Passwords do not match<br>";
            }

            if (error)
                return;

            Classes.User objUser = new Classes.User();

            if (objUser.addUser(txtName.Text.ToString(), txtEmail.Text.ToString(), txtPassword.Text.ToString(), null, "Customer"))
            {
                string activationCode = objUser.getActivationCode(txtEmail.Text.ToString());

                string activationLink = "http://" + Request.Url.Authority + "/Account/Activate.aspx?code=" + activationCode + "&email=" + txtEmail.Text.ToString(); ;

                string activationMessage = "Hello " + txtName.Text.ToString() + ",<br><br>";
                activationMessage += "Please activate your account by clicking on the link:<br><br>";
                activationMessage += activationLink;

                Classes.Mail objMail = new Classes.Mail(txtEmail.Text.ToString(), "eShopee Account Activation", activationMessage);

                litError.Text = "You are successfully registered";

            }

            else
                litError.Text = "Your account could not be registered";

            objUser.close();
        }
Example #2
0
        public int inviteSend(int userId, string email)
        {
            int status = 0;

            Classes.UserInfo ui = new Classes.UserInfo();
            string userFullName = ui.getUserFullNameByUserId(userId);

            string siteLink = ConfigurationManager.AppSettings["WebsiteLink"].ToString();
            string link = siteLink + "Register/" + userId.ToString();
            Classes.Mail m = new Classes.Mail();
            int status2 = m.sendMail("invite", email,
                "Hi, " + userFullName + " invited you to join CityCrowd.<br/><a href='"
                + link + "'>CLICK HERE</a> to join your friend and other CityCrowders.<br/><br/>CityCowd Team", userFullName);

            status = 1;

            return status;
        }
Example #3
0
        public int inviteSend(int userId, string email)
        {
            int status = 0;

            Classes.UserInfo ui           = new Classes.UserInfo();
            string           userFullName = ui.getUserFullNameByUserId(userId);

            string siteLink = ConfigurationManager.AppSettings["WebsiteLink"].ToString();
            string link     = siteLink + "Register/" + userId.ToString();

            Classes.Mail m       = new Classes.Mail();
            int          status2 = m.sendMail("invite", email,
                                              "Hi, " + userFullName + " invited you to join CityCrowd.<br/><a href='"
                                              + link + "'>CLICK HERE</a> to join your friend and other CityCrowders.<br/><br/>CityCowd Team", userFullName);

            status = 1;

            return(status);
        }
Example #4
0
        public int verifyEmailSend(int userId)
        {
            DataTable      dt      = new DataTable();
            DataSet        ds      = new DataSet();
            SqlConnection  sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
            SqlDataAdapter sda     = new SqlDataAdapter("sp_verifyEmailGetCode", sqlConn);

            sda.SelectCommand.CommandType = CommandType.StoredProcedure;
            sda.SelectCommand.Parameters.Add("@UserId", SqlDbType.Int).Value = userId;

            //try
            //{
            sda.Fill(ds);
            dt = ds.Tables[0];
            //}
            //catch (Exception ex)
            //{

            //}
            //finally
            //{
            sqlConn.Close();
            sda.Dispose();
            sqlConn.Dispose();
            //}

            if (dt.Rows.Count == 0)
            {
                return(0); //no user found
            }
            else
            {
                string       siteLink = ConfigurationManager.AppSettings["WebsiteLink"].ToString();
                string       link     = siteLink + "Verify/Email/" + (dt.Rows[0]["VerificationCode"].ToString());
                Classes.Mail m        = new Classes.Mail();
                int          status2  = m.sendMail("verifyemail", dt.Rows[0]["Email"].ToString(),
                                                   "Hi,<br/>To verify your email addrss please <a href='"
                                                   + link + "'>CLICK HERE</a><br/><br/>CityCowd Team", "");

                return(1);
            }
        }
Example #5
0
        public int request(string email)
        {
            int    status = 0;
            string VCode  = "";

            DataTable      dt      = new DataTable();
            DataSet        ds      = new DataSet();
            SqlConnection  sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
            SqlDataAdapter sda     = new SqlDataAdapter("sp_getUserIdByEmail", sqlConn);
            SqlCommand     sqlCmd  = new SqlCommand("sp_forgotPasswordRequest", sqlConn);

            //try
            //{
            sda.SelectCommand.CommandType = CommandType.StoredProcedure;
            sda.SelectCommand.Parameters.Add(new SqlParameter("@Email", SqlDbType.VarChar));
            sda.SelectCommand.Parameters["@Email"].Value = email;
            sda.Fill(ds);
            dt = ds.Tables[0];

            if (dt.Rows.Count == 0)
            {
                //email address was bit dounf
                status = 2;
            }
            else
            {
                DataTable      dt2  = new DataTable();
                DataSet        ds2  = new DataSet();
                SqlDataAdapter sda2 = new SqlDataAdapter("sp_forgotPasswordExists", sqlConn);
                sda2.SelectCommand.CommandType = CommandType.StoredProcedure;
                sda2.SelectCommand.Parameters.Add(new SqlParameter("@Email", SqlDbType.VarChar));
                sda2.SelectCommand.Parameters["@Email"].Value = email;
                sda2.Fill(ds2);
                dt2 = ds2.Tables[0];

                if (dt2.Rows.Count == 0)
                {
                    VCode = Convert.ToString(Guid.NewGuid());

                    sqlCmd.CommandType = CommandType.StoredProcedure;
                    sqlCmd.Parameters.Add("@Email", SqlDbType.VarChar).Value  = email;
                    sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value     = Convert.ToInt32(dt.Rows[0]["UserId"].ToString());
                    sqlCmd.Parameters.Add("@VCode", SqlDbType.NVarChar).Value = VCode;

                    sqlConn.Open();
                    sqlCmd.ExecuteNonQuery();

                    status = 1;
                }
                else
                {
                    VCode = dt2.Rows[0]["VerificationCode"].ToString();
                }

                status = 1;

                string       siteLink = ConfigurationManager.AppSettings["WebsiteLink"].ToString();
                string       link     = siteLink + "ForgotPassword/Recover/" + VCode;
                Classes.Mail m        = new Classes.Mail();
                int          status2  = m.sendMail("password", email,
                                                   "Hi,<br/>You requested to recover your CityCrowd password.<br/>To recover your password please <a href='"
                                                   + link + "'>CLICK HERE</a><br/><br/>CityCowd Team", "");

                sda2.Dispose();
            }
            //}
            //catch (Exception ex)
            //{

            //}
            //finally
            //{
            sqlConn.Close();
            sda.Dispose();
            sqlCmd.Dispose();
            sqlConn.Dispose();
            //}

            return(status);
        }
Example #6
0
        public Int16 completion(int userId, string username, string firstName, string lastName, Int16 gender, int locationId, string birthDate, bool hasPhoto)
        {
            Int16 status = 0;

            //check username valid
            Regex RgxUrl = new Regex("[^a-zA-Z]");

            if (Regex.Matches(username, @"[a-zA-Z]").Count == 0)
            {
                status = -2;
            }
            else
            {
                //special symbols
                RgxUrl = new Regex("[^a-zA-Z0-9]");

                if (RgxUrl.IsMatch(username))
                {
                    status = -3;
                }
                else
                {
                    //check username exists
                    Classes.UserInfo ui             = new Classes.UserInfo();
                    bool             usernameExists = ui.checkUsernameExists(username);

                    if (usernameExists)
                    {
                        status = -1;
                    }
                    else
                    {
                        status = 1;

                        SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
                        SqlCommand    sqlCmd  = new SqlCommand("sp_completion", sqlConn);
                        sqlCmd.CommandType = CommandType.StoredProcedure;
                        sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value         = userId;
                        sqlCmd.Parameters.Add("@Username", SqlDbType.VarChar).Value   = username;
                        sqlCmd.Parameters.Add("@FirstName", SqlDbType.NVarChar).Value = firstName;
                        sqlCmd.Parameters.Add("@LastName", SqlDbType.NVarChar).Value  = lastName;
                        sqlCmd.Parameters.Add("@Gender", SqlDbType.TinyInt).Value     = gender;
                        sqlCmd.Parameters.Add("@LocationId", SqlDbType.Int).Value     = locationId;
                        sqlCmd.Parameters.Add("@BirthDate", SqlDbType.Date).Value     = Convert.ToDateTime(birthDate);//Convert.ToDateTime(dob);
                        sqlCmd.Parameters.Add("@HasPhoto", SqlDbType.Bit).Value       = hasPhoto;

                        //try
                        //{
                        sqlConn.Open();
                        sqlCmd.ExecuteNonQuery();
                        //}
                        //catch (Exception ex)
                        //{

                        //}
                        //finally
                        //{
                        sqlConn.Close();
                        sqlCmd.Dispose();
                        sqlConn.Dispose();
                        //}

                        Classes.Notifications n = new Classes.Notifications();
                        n.notificationAdd(userId, 1, Convert.ToInt64(userId));

                        string email    = ui.getEmailByUserId(userId);
                        string siteLink = ConfigurationManager.AppSettings["WebsiteLink"].ToString();
                        string link     = siteLink;
                        string message  = "<br/>Welcome to CityCrowd.<br/>You have successfully registered.<br/><a href='"
                                          + link + "'>CLICK HERE</a> to visit the website.<br/><br/>CityCowd Team";

                        if (!ui.isUserEmailVerified(userId))
                        {
                            string        VCode    = Convert.ToString(Guid.NewGuid());
                            SqlConnection sqlConn2 = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
                            SqlCommand    sqlCmd2  = new SqlCommand("sp_verifyEmailAdd", sqlConn2);
                            sqlCmd2.CommandType = CommandType.StoredProcedure;
                            sqlCmd2.Parameters.Add("@UserId", SqlDbType.Int).Value     = userId;
                            sqlCmd2.Parameters.Add("@VCode", SqlDbType.NVarChar).Value = VCode;

                            sqlConn2.Open();
                            sqlCmd2.ExecuteNonQuery();

                            link    = siteLink + "Verify/Email/" + VCode;
                            message = "<br/>Welcome to CityCrowd.<br/>You have successfully registered.<br/><a href='"
                                      + link + "'>CLICK HERE</a> to verify your email address and visit the website.<br/><br/>CityCowd Team";
                        }

                        Classes.Mail m       = new Classes.Mail();
                        int          status2 = m.sendMail("register", email,
                                                          "Hi, " + firstName + message, "");
                    }
                }
            }

            return(status);
        }
Example #7
0
        public int verifyEmailSend(int userId)
        {
            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
            SqlDataAdapter sda = new SqlDataAdapter("sp_verifyEmailGetCode", sqlConn);
            sda.SelectCommand.CommandType = CommandType.StoredProcedure;
            sda.SelectCommand.Parameters.Add("@UserId", SqlDbType.Int).Value = userId;

            //try
            //{
                sda.Fill(ds);
                dt = ds.Tables[0];
            //}
            //catch (Exception ex)
            //{

            //}
            //finally
            //{
                sqlConn.Close();
                sda.Dispose();
                sqlConn.Dispose();
            //}

            if (dt.Rows.Count == 0)
            {
                return 0; //no user found
            }
            else
            {
                string siteLink = ConfigurationManager.AppSettings["WebsiteLink"].ToString();
                string link = siteLink + "Verify/Email/" + (dt.Rows[0]["VerificationCode"].ToString());
                Classes.Mail m = new Classes.Mail();
                int status2 = m.sendMail("verifyemail", dt.Rows[0]["Email"].ToString(),
                    "Hi,<br/>To verify your email addrss please <a href='"
                    + link + "'>CLICK HERE</a><br/><br/>CityCowd Team", "");

                return 1;
            }
        }
Example #8
0
        public Int16 completion(int userId, string username, string firstName, string lastName, Int16 gender, int locationId, string birthDate, bool hasPhoto)
        {
            Int16 status = 0;

            //check username valid
            Regex RgxUrl = new Regex("[^a-zA-Z]");
            if (Regex.Matches(username, @"[a-zA-Z]").Count == 0)
            {
                status = -2;
            }
            else
            {
                //special symbols
                RgxUrl = new Regex("[^a-zA-Z0-9]");

                if (RgxUrl.IsMatch(username))
                {
                    status = -3;
                }
                else
                {

                    //check username exists
                    Classes.UserInfo ui = new Classes.UserInfo();
                    bool usernameExists = ui.checkUsernameExists(username);

                    if (usernameExists)
                    {
                        status = -1;
                    }
                    else
                    {
                        status = 1;

                        SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
                        SqlCommand sqlCmd = new SqlCommand("sp_completion", sqlConn);
                        sqlCmd.CommandType = CommandType.StoredProcedure;
                        sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = userId;
                        sqlCmd.Parameters.Add("@Username", SqlDbType.VarChar).Value = username;
                        sqlCmd.Parameters.Add("@FirstName", SqlDbType.NVarChar).Value = firstName;
                        sqlCmd.Parameters.Add("@LastName", SqlDbType.NVarChar).Value = lastName;
                        sqlCmd.Parameters.Add("@Gender", SqlDbType.TinyInt).Value = gender;
                        sqlCmd.Parameters.Add("@LocationId", SqlDbType.Int).Value = locationId;
                        sqlCmd.Parameters.Add("@BirthDate", SqlDbType.Date).Value = Convert.ToDateTime(birthDate);//Convert.ToDateTime(dob);
                        sqlCmd.Parameters.Add("@HasPhoto", SqlDbType.Bit).Value = hasPhoto;

                        //try
                        //{
                            sqlConn.Open();
                            sqlCmd.ExecuteNonQuery();
                        //}
                        //catch (Exception ex)
                        //{

                        //}
                        //finally
                        //{
                            sqlConn.Close();
                            sqlCmd.Dispose();
                            sqlConn.Dispose();
                        //}

                        Classes.Notifications n = new Classes.Notifications();
                        n.notificationAdd(userId, 1, Convert.ToInt64(userId));

                        string email = ui.getEmailByUserId(userId);
                        string siteLink = ConfigurationManager.AppSettings["WebsiteLink"].ToString();
                        string link = siteLink;
                        string message = "<br/>Welcome to CityCrowd.<br/>You have successfully registered.<br/><a href='"
                            + link + "'>CLICK HERE</a> to visit the website.<br/><br/>CityCowd Team";

                        if(!ui.isUserEmailVerified(userId))
                        {
                            string VCode = Convert.ToString(Guid.NewGuid());
                            SqlConnection sqlConn2 = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
                            SqlCommand sqlCmd2 = new SqlCommand("sp_verifyEmailAdd", sqlConn2);
                            sqlCmd2.CommandType = CommandType.StoredProcedure;
                            sqlCmd2.Parameters.Add("@UserId", SqlDbType.Int).Value = userId;
                            sqlCmd2.Parameters.Add("@VCode", SqlDbType.NVarChar).Value = VCode;

                            sqlConn2.Open();
                            sqlCmd2.ExecuteNonQuery();

                            link = siteLink + "Verify/Email/" + VCode;
                            message = "<br/>Welcome to CityCrowd.<br/>You have successfully registered.<br/><a href='"
                            + link + "'>CLICK HERE</a> to verify your email address and visit the website.<br/><br/>CityCowd Team";
                        }
                        
                        Classes.Mail m = new Classes.Mail();
                        int status2 = m.sendMail("register", email,
                            "Hi, " + firstName + message, "");
                    }
                }
            }

            return status;
        }
Example #9
0
        public int request(string email)
        {
            int status = 0;
            string VCode = "";

            DataTable dt = new DataTable();
            DataSet ds = new DataSet();
            SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AppConnectionString"].ConnectionString);
            SqlDataAdapter sda = new SqlDataAdapter("sp_getUserIdByEmail", sqlConn);
            SqlCommand sqlCmd = new SqlCommand("sp_forgotPasswordRequest", sqlConn);

            //try
            //{
            sda.SelectCommand.CommandType = CommandType.StoredProcedure;
            sda.SelectCommand.Parameters.Add(new SqlParameter("@Email", SqlDbType.VarChar));
            sda.SelectCommand.Parameters["@Email"].Value = email;
            sda.Fill(ds);
            dt = ds.Tables[0];

            if (dt.Rows.Count == 0)
            {
                //email address was bit dounf
                status = 2;
                
            }
            else
            {
                DataTable dt2 = new DataTable();
                DataSet ds2 = new DataSet();
                SqlDataAdapter sda2 = new SqlDataAdapter("sp_forgotPasswordExists", sqlConn);
                sda2.SelectCommand.CommandType = CommandType.StoredProcedure;
                sda2.SelectCommand.Parameters.Add(new SqlParameter("@Email", SqlDbType.VarChar));
                sda2.SelectCommand.Parameters["@Email"].Value = email;
                sda2.Fill(ds2);
                dt2 = ds2.Tables[0];

                if (dt2.Rows.Count == 0)
                {
                    VCode = Convert.ToString(Guid.NewGuid());

                    sqlCmd.CommandType = CommandType.StoredProcedure;
                    sqlCmd.Parameters.Add("@Email", SqlDbType.VarChar).Value = email;
                    sqlCmd.Parameters.Add("@UserId", SqlDbType.Int).Value = Convert.ToInt32(dt.Rows[0]["UserId"].ToString());
                    sqlCmd.Parameters.Add("@VCode", SqlDbType.NVarChar).Value = VCode;

                    sqlConn.Open();
                    sqlCmd.ExecuteNonQuery();

                    status = 1;
                }
                else
                {
                    VCode = dt2.Rows[0]["VerificationCode"].ToString();
                }

                status = 1;

                string siteLink = ConfigurationManager.AppSettings["WebsiteLink"].ToString();
                string link = siteLink + "ForgotPassword/Recover/" + VCode;
                Classes.Mail m = new Classes.Mail();
                int status2 = m.sendMail("password", email, 
                    "Hi,<br/>You requested to recover your CityCrowd password.<br/>To recover your password please <a href='"
                    + link + "'>CLICK HERE</a><br/><br/>CityCowd Team", "");

                sda2.Dispose();
            }
            //}
            //catch (Exception ex)
            //{

            //}
            //finally
            //{
                sqlConn.Close();
                sda.Dispose();
                sqlCmd.Dispose();
                sqlConn.Dispose();
            //}

            return status;
        }