Ejemplo n.º 1
0
        protected void btn_Click(object sender, EventArgs e)
        {
            try
            {
                var         firstname = TextBox1.Text;
                var         lastname  = TextBox6.Text;
                var         email     = TextBox2.Text;
                var         mob       = TextBox3.Text;
                var         tel       = TextBox4.Text;
                var         dep       = Dep.SelectedValue;
                var         password  = TextBox5.Text;
                var         context   = new MOMEntities();
                MEMBERTABLE user      = new MEMBERTABLE();
                var         exa       = context.MEMBERTABLE.SingleOrDefault(x => x.EMAIL == email);
                if (exa != null)
                {
                    Response.Write("Email already exist");
                }
                else
                {
                    user.FIRSTNAME = firstname;
                    user.LASTNAME  = lastname;
                    user.EMAIL     = email;
                    user.MOBILE    = mob;
                    user.TELEPHONE = tel;
                    user.PASSWORD  = password;
                    user.ID        = 0;
                    var contextt = new ValidationContext(user);
                    var results  = new List <ValidationResult>();
                    var isValid  = Validator.TryValidateObject(user, contextt, results, true);

                    if (!isValid)
                    {
                        foreach (var validationResult in results)
                        {
                            //Response.Write(validationResult.ErrorMessage.ToString());
                            //Response.Redirect("SignUp.aspx");
                        }
                    }
                    else
                    {
                        user.DEPARTMENT = Convert.ToInt32(dep);
                        context.MEMBERTABLE.Add(user);
                        context.SaveChanges();
                        Response.Redirect("Login.aspx");
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Ejemplo n.º 2
0
        protected void btn_Click(object sender, EventArgs e)
        {
            //SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MOMEntities"].ToString());
            try
            {
                string      uid     = TextBox.Text;
                string      pass    = TextBox2.Text;
                var         context = new MOMEntities();
                MEMBERTABLE check   = new MEMBERTABLE();
                check.EMAIL    = uid;
                check.PASSWORD = pass;
                //var contextt = new ValidationContext(uid);
                //var results = new List<ValidationResult>();
                //var isValid = Validator.TryValidateObject(check, contextt, results, true);

                //if (!isValid)
                //{

                //}

                //else
                //{
                var user = context.MEMBERTABLE.SingleOrDefault(x => x.EMAIL == uid && x.PASSWORD == pass);
                if (user != null)
                {
                    //Token_cs obj = new Token_cs();
                    var obj = TokenManager.GenerateToken(user.EMAIL);
                    //var token=TokenManager.GenerateToken(user.EMAIL);
                    Session["TOKEN"] = obj;
                    Response.Redirect("Home.aspx?token=" + obj, false);
                }
                else
                {
                    Label4.Text = "UserId & Password Is not correct Try again..!!";
                }
                //}
                //con.Close();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }