protected void regB_Click(object sender, EventArgs e) { bool validators = Page.IsValid;// to check if email is valid !!!!!!!!!!! if (validators && Name.Text != "" && LName.Text != "" && Email.Text != "" && pass.Text != "" && Phone.Text != "" && ID.Text != "" && pass.Text != "00000000") { //get input values string id = ID.Text; string name = Name.Text; string lname = LName.Text; string password = pass.Text; string phoneNum = Phone.Text; string email = Email.Text; bool passCheck = false; try { passCheck = BlUser.PasswordCheck(password);//check if there is a user with the same password } catch (Exception exception) { MSG.Text = "fail register " + exception.Message;//error massage } string latLng = this.LatLng.Value.ToString(); double lat = OrderNow.GetLat(latLng); double lng = OrderNow.GetLng(latLng); if (passCheck) { int type = 0; try { type = int.Parse(Request.QueryString.Get("Type")); } catch { Response.Redirect("HomePage.aspx"); return; } //if (type!=1&& type != 3&&type != 4) //{ // Response.Redirect("HomePage.aspx"); // return; //} BlUser user = null; try { user = new BlUser(id, type, email, phoneNum, name, lname, password, lat, lng);//add new user to DB } catch (Exception exception) { MSG.Text = "fail register " + exception.Message;//error massage } //log in when finish to register //if (user!=null) //{ // string pass = user.Password; // user = user.Type == 1 ? (BlUser)new BlShopManager(pass) : new BlOrderUser(pass); // Session["user"] = user; //} if (user == null || user.UserId == "-1") { return; } MSG.Text = "seccsuss to register!"; //create a verify code //string verifyCode = GenerateRandomCode(); ////send verify code to email to verify the email ////bool isEmailSent = sendEmail(email, " Fly pack please verify your email address.", //// $"Almost done,{name}! To complete your sign up, we just need to verify your email address: {email}.<br/> Verification code: {verifyCode}<br/> Once verified, you can start order products.<br/>You’re receiving this email because you recently created a new Fly Pack account or added a new email address.<br/> If this wasn’t you, please ignore this email.<br/>Thanks,<br/>The Fly Pack Team"); ////if (!isEmailSent) ////{ //// MSG.Text = "unvalidated email address";//error massage ////} ////else ////{ //MSG.Text = " email sent, code- " + verifyCode;// email to del //BlOrderUser currentUser = (BlOrderUser)Session["user"]; //bool isCustomer = (currentUser != null && currentUser.Type == 4); //if (isCustomer) //{ // Session["user"] = new BlOrderUser(user.Password); //} ////try ////{ //// Dictionary<string, string> emailVerify = ((Dictionary<string, string>)Application["UnVerifyEmail"]); //// emailVerify?.Add(user.UserId, verifyCode); ////} ////catch ////{ //// Application["UnVerifyEmail"] = new Dictionary<string, string> { { user.UserId, verifyCode } }; ////} ////try ////{ //// GlobalVariable.UnVerifyEmail.Add(user.UserId, verifyCode); ////} ////catch ////{ //// GlobalVariable.UnVerifyEmail = new Dictionary<string, string> { { user.UserId, verifyCode } }; ////} //if (isCustomer) //{ // Response.Redirect("VerifyEmail.aspx"); //} //} } else { MSG.Text = "Password caught please try again";//error massage } } else { //convert the the text box style by the validator Phone.CssClass = PhoneValidator.IsValid ? "TextBox" : "TextBoxUnValidValue"; pass.CssClass = passValidator.IsValid && PassNotEmpty.IsValid ? "TextBox" : "TextBoxUnValidValue"; Email.CssClass = EmailValidator.IsValid ? "TextBox" : "TextBoxUnValidValue"; Name.CssClass = NameValidator.IsValid ? "TextBox" : "TextBoxUnValidValue"; LName.CssClass = LNameValidator.IsValid ? "TextBox" : "TextBoxUnValidValue"; ID.CssClass = IDValidator.IsValid ? "TextBox" : "TextBoxUnValidValue"; MSG.Text = "Please type all the details";//error massage } }