示例#1
0
    public CustomerUti getUser(string userName)
    {
        CustomerUti   customer = new CustomerUti();
        SqlConnection conn     = new SqlConnection(ConfigurationManager.ConnectionStrings["PizzaDBRemote"].ConnectionString);

        conn.Open();
        string     checkUser = "******";
        SqlCommand comd      = new SqlCommand(checkUser, conn);

        comd.Parameters.AddWithValue("@userName", userName);
        SqlDataReader dr = comd.ExecuteReader();

        dr.Read();
        if (dr.HasRows)
        {
            customer.UserName = dr[0].ToString();
            customer.FName    = dr[1].ToString();
            customer.LName    = dr[2].ToString();
            customer.Email    = dr[3].ToString();
            customer.Country  = dr[4].ToString();
            customer.Password = dr[5].ToString();
            customer.Age      = dr[6].ToString();
            customer.Gender   = dr[7].ToString().ToCharArray()[0];
        }
        dr.Close();
        conn.Close();
        return(customer);
    }
示例#2
0
    protected void ButtonLogin_Click(object sender, EventArgs e)
    {
        CustomerUti customer = new CustomerUti();

        customer.UserName = TextBoxUserName.Text;
        customer.Password = TextBoxPassword.Text;
        if (customer.checkPassword())
        {
            Session["user"]        = TextBoxUserName.Text;
            LabelMessage.Enabled   = true;
            LabelMessage.Visible   = true;
            LabelMessage.Text      = "Welcome back!";
            LabelMessage.ForeColor = Color.Red;
            string strRedirectPage = "Home.aspx";
            string strRedirectTime = "2";
            string strRedirect     = string.Format("{0};url={1}", strRedirectTime, strRedirectPage);
            Response.AddHeader("refresh", strRedirect);
        }
        else
        {
            LabelMessage.Enabled             = true;
            LabelMessage.Visible             = true;
            LabelMessage.Text                = "Your Username Or Passowrd is in correct!";
            LabelMessage.ForeColor           = Color.Red;
            LinkButtonForgotPassword.Enabled = true;
            LinkButtonForgotPassword.Visible = true;
        }
    }
示例#3
0
    protected void ButtonSubmit_Click(object sender, EventArgs e)
    {
        CustomerUti customer = new CustomerUti();

        customer.UserName = TextBoxUserName.Text;
        customer.FName    = TextBoxFName.Text;
        customer.LName    = TextBoxLName.Text;
        customer.Email    = TextBoxEmail.Text;
        customer.Country  = DropDownListCountry.SelectedItem.ToString();
        customer.Password = TextBoxPassword.Text;
        customer.Age      = TextBoxAge.Text;
        if (RadioButtonFemale.Checked)
        {
            customer.Gender = 'F';
        }
        else
        {
            customer.Gender = 'M';
        }
        if (customer.userExist() == "")
        {
            try
            {
                customer.insertData();
                string strRedirectPage = "Login.aspx";
                string strRedirectTime = "2";
                string strRedirect     = string.Format("{0};url={1}", strRedirectTime, strRedirectPage);
                Response.AddHeader("refresh", strRedirect);
            }
            catch (Exception ex)
            {
                Response.Write("Error: " + ex.ToString());
            } //ending check record
        }
    }         //ending ButtonSubmit_Click method
示例#4
0
    protected void ButtonResetPassword_Click(object sender, EventArgs e)
    {
        CustomerUti customer = new CustomerUti().getUser(TextBoxUserName.Text);

        if (!String.IsNullOrEmpty(customer.Email) && customer.Email.Equals(TextBoxEmail.Text))
        {
            int    rand   = new Random().Next(100000, 999999);
            string newpwd = "new" + rand;
            customer.resetPassword(newpwd);
            LabelMessage.Visible   = true;
            LabelMessage.Text      = "Your password has been reset as " + newpwd;
            LabelMessage.ForeColor = System.Drawing.Color.Red;
            sendNotification(customer.Email);
        }
        else
        {
            LabelMessage.Visible   = true;
            LabelMessage.Text      = "Your Email or UserName are not matched!!";
            LabelMessage.ForeColor = System.Drawing.Color.Red;
        }
    }