Esempio n. 1
0
        //string userid = Common.common.sessionname;
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((string)Session["userid"] == null)
            {
                Response.Redirect("~/LogIn.aspx");
            }
            if (IsPostBack)
            {
                //SqlConnection connection = new SqlConnection(Common.common.strcon);
                //SqlCommand command = new SqlCommand("SELECT dp FROM Member WHERE Id = @Id", connection);
                //command.Parameters.AddWithValue("@Id", (string)Session["userid"]);

                //SqlDataReader reader;
                //connection.Open();
                //reader = command.ExecuteReader();
                //reader.Read();
                //string url = "~/dp/" + reader["dp"];
                //Image1.ImageUrl = url;

                error_label.Text = "";
            }
            if (!IsPostBack)
            {
                if ((string)Session["newpassword"] != null)
                {
                    string args = "{email:" + '"' + Session["email"].ToString() + '"' + ",password:"******"' + Session["password"].ToString() + '"' + ",newpassword:"******"' + Session["newpassword"].ToString() + '"' + ",name:" + '"' + Session["name"].ToString() + '"' + "}";
                    Page.ClientScript.RegisterStartupScript(Button1.GetType(), "test", "accountupdate(" + args + ");", true);
                }
                SqlConnection connection = new SqlConnection(Common.common.strcon);
                SqlCommand    command    = new SqlCommand("SELECT * FROM Member WHERE Id = @Id", connection);
                command.Parameters.AddWithValue("@Id", (string)Session["userid"]);

                try
                {
                    SqlDataReader reader;
                    connection.Open();
                    reader = command.ExecuteReader();
                    reader.Read();
                    string url = "~/dp/" + reader["dp"];
                    Image1.ImageUrl    = url;
                    TextBox1.Text      = (string)reader["Name"];
                    Label11.Text       = (string)reader["Email"];
                    TextBox3.Text      = (string)reader["Phone"];
                    TextBox4.Text      = (string)reader["status"];
                    TextBox5.Text      = (string)reader["password"];
                    DropDownList1.Text = (string)reader["gender"];
                    TextBox8.Text      = (string)reader["age"];
                }
                catch (Exception err)
                {
                    error_label.Text = "Error occured while getting data<br>Please try after some time" + err;
                }
                finally
                {
                    connection.Close();
                }
            }
        }
Esempio n. 2
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     Model.SelectLicensePlate(TextBox1.Text, TextBox2.Text, DropDownList1.SelectedItem.Text);
     ScriptManager.RegisterStartupScript(Button1, Button1.GetType(), "close", "Close();", true);
 }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (email_conflict() == true)
            {
                error_label.Text = "Email already Exist ";
            }

            else
            {
                string args = "{email:" + '"' + TextBox2.Text + '"' + ",password:"******"' + TextBox5.Text + '"' + ",full_name:" + '"' + TextBox1.Text + '"' + "}";
                Page.ClientScript.RegisterStartupScript(Button1.GetType(), "test", "createaccount(" + args + ");", true);
                string insertSQL;
                insertSQL  = "INSERT INTO Member (Name, Email,Phone,dp,status, password,gender,age) VALUES (";
                insertSQL += "@Name, @Email,@Phone,@dp,@status,@password,@gender,@age)";


                SqlConnection con = new SqlConnection(Common.common.strcon);
                SqlCommand    cmd = new SqlCommand(insertSQL, con);

                string filename  = FileUploadControl.FileName;
                string filename1 = randomname + System.IO.Path.GetExtension(filename);

                if (FileUploadControl.HasFile)
                {
                    string[] acceptedExtensions = new string[] { ".png", ".jpg", ".jpeg" };
                    if (acceptedExtensions.Contains(System.IO.Path.GetExtension(filename)))
                    {
                        if (FileUploadControl.PostedFile.ContentLength < 1048576)
                        {
                            if (File.Exists("~/dp/" + filename1) == true)
                            {
                                File.Delete("~/dp/" + filename1);
                            }
                            FileUploadControl.SaveAs((Server.MapPath("~/dp/") + filename1));
                            error_label.Text = "Upload status: File uploaded!";
                        }
                        else
                        {
                            error_label.Text = "Upload status: The file has to be less than 4 MB!";
                        }
                    }
                    else
                    {
                        error_label.Text = "this extension is not allowed";
                    }
                }

                cmd.Parameters.AddWithValue("@Name", TextBox1.Text);
                cmd.Parameters.AddWithValue("@Email", TextBox2.Text);
                cmd.Parameters.AddWithValue("@Phone", TextBox3.Text);
                cmd.Parameters.AddWithValue("@dp", filename1);
                cmd.Parameters.AddWithValue("@status", TextBox4.Text);
                cmd.Parameters.AddWithValue("@password", TextBox5.Text);
                cmd.Parameters.AddWithValue("@gender", DropDownList1.Text);
                cmd.Parameters.AddWithValue("@age", TextBox8.Text);


                try
                {
                    con.Open();
                    cmd.ExecuteNonQuery();
                    error_label.Text = "Account Created successfully";
                }
                catch (Exception err)
                {
                    error_label.Text = "Error occured while creating <br>account Please try after some time" + err;
                }
                finally
                {
                    con.Close();
                }
            }
        }