Exemple #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["emailid"] != null)
        {
            if (!IsPostBack)
            {
                DataView dv = SqlDataSourceUser.Select(DataSourceSelectArguments.Empty) as DataView;

                EmailId.Text = Session["emailid"].ToString();

                if (dv != null)
                {
                    for (int i = 0; i < dv.Table.Rows.Count; i++)
                    {
                        if (EmailId.Text == dv.Table.Rows[i]["EmailId"].ToString())
                        {
                            FullName.Text          = dv.Table.Rows[i]["FullName"].ToString();
                            PhoneNo.Text           = dv.Table.Rows[i]["PhoneNo"].ToString();
                            Image1.ImageUrl        = dv.Table.Rows[i]["Photo"].ToString();
                            HiddenFieldPhoto.Value = dv.Table.Rows[i]["Photo"].ToString();
                            Gender.SelectedValue   = dv.Table.Rows[i]["Gender"].ToString();
                            break;
                        }
                    }
                }
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Msg.Text     = "";
        Msg.CssClass = "";

        DataView dv = SqlDataSourceUser.Select(DataSourceSelectArguments.Empty) as DataView;

        bool Exists = false;

        if (dv != null)
        {
            for (int i = 0; i < dv.Table.Rows.Count; i++)
            {
                if (EmailId.Text == dv.Table.Rows[i]["EmailId"].ToString() &&
                    Password.Text == dv.Table.Rows[i]["Password"].ToString())
                {
                    Exists = true;
                    break;
                }
            }
        }

        if (Exists)
        {
            Session["emailid"] = EmailId.Text;
            Response.Redirect("UpdateProfile.aspx");
        }
        else
        {
            Msg.Text     = "Invalid Email or Password";
            Msg.CssClass = "text-danger";
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Msg.Text     = "";
        Msg.CssClass = "";

        DataView dv = SqlDataSourceUser.Select(DataSourceSelectArguments.Empty) as DataView;

        bool Exists = false;

        if (dv != null)
        {
            for (int i = 0; i < dv.Table.Rows.Count; i++)
            {
                if (EmailId.Text == dv.Table.Rows[i]["EmailId"].ToString() &&
                    OldPassword.Text == dv.Table.Rows[i]["Password"].ToString())
                {
                    Exists = true;
                    break;
                }
            }
        }

        if (Exists)
        {
            SqlDataSourceUser.Update();
            Msg.Text     = "Password Updated";
            Msg.CssClass = "text-success";
        }
        else
        {
            Msg.Text     = "Incorrect Old Password";
            Msg.CssClass = "text-danger";
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Msg.Text     = "";
        Msg.CssClass = "";

        DataView dv = SqlDataSourceUser.Select(DataSourceSelectArguments.Empty) as DataView;

        bool Exists = false;

        if (dv != null)
        {
            for (int i = 0; i < dv.Table.Rows.Count; i++)
            {
                if (EmailId.Text == dv.Table.Rows[i]["EmailId"].ToString())
                {
                    Exists = true;
                    break;
                }
            }
        }

        if (Exists)
        {
            Msg.Text     = "Email already registered";
            Msg.CssClass = "text-danger";
        }
        else
        {
            string FileName = Photo.FileName.ToLower();

            string Extension = FileName.Substring(FileName.LastIndexOf('.'));

            if (Extension == ".jpg" || Extension == ".jpeg" || Extension == ".png")
            {
                HiddenFieldPhoto.Value = "/photos/" + FileName;
                Photo.SaveAs(Server.MapPath(HiddenFieldPhoto.Value));

                SqlDataSourceUser.Insert();
                Msg.Text     = "Sign Up successful";
                Msg.CssClass = "text-success";
            }
            else
            {
                Msg.Text     = "Please select an image file";
                Msg.CssClass = "text-danger";
            }
        }
    }
Exemple #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session == null || Session["LoggedIn"] == null)
        {
            Server.Transfer("~/Default.aspx");
        }

        if (!IsPostBack)
        {
            DataView d = (DataView)SqlDataSourceUser.Select(DataSourceSelectArguments.Empty);

            txtFName.Text   = "" + d[0]["FirstName"];
            txtLName.Text   = "" + d[0]["LastName"];
            txtAddress.Text = "" + d[0]["Address"];
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Msg.Text     = "";
        Msg.CssClass = "";

        DataView dv = SqlDataSourceUser.Select(DataSourceSelectArguments.Empty) as DataView;

        bool Exists = false;

        if (dv != null)
        {
            for (int i = 0; i < dv.Table.Rows.Count; i++)
            {
                if (EmailId.Text == dv.Table.Rows[i]["EmailId"].ToString())
                {
                    Exists = true;
                    break;
                }
            }
        }

        if (Exists)
        {
            Random rn = new Random();

            for (int i = 1; i <= 6; i++)
            {
                HiddenFieldPassword.Value += rn.Next(0, 10);
            }

            MailMessage mailMessage = new MailMessage();
            mailMessage.From = new MailAddress("");
            mailMessage.To.Add(new MailAddress(EmailId.Text));
            mailMessage.Subject  = "Password Recovery";
            mailMessage.Body     = "Your new password is " + HiddenFieldPassword.Value;
            mailMessage.Priority = MailPriority.High;

            SmtpClient smtpClient = new SmtpClient();
            smtpClient.Host        = "smtp.gmail.com";
            smtpClient.Port        = 587;
            smtpClient.EnableSsl   = true;
            smtpClient.Credentials = new System.Net.NetworkCredential("", "");

            try
            {
                smtpClient.Send(mailMessage);
                SqlDataSourceUser.Update();
                Msg.Text     = "Password sent to your email address";
                Msg.CssClass = "text-success";
            }
            catch (Exception ex)
            {
                Msg.Text     = ex.Message;
                Msg.CssClass = "text-danger";
            }
        }
        else
        {
            Msg.Text     = "Email not registered";
            Msg.CssClass = "text-danger";
        }
    }