Ejemplo n.º 1
0
        public DataTable findperson(string text)
        {
            Person person = new Person();

            MySqlConnection connection = new MySqlConnection();
            connection.ConnectionString = connectionString;
            connection.Open();

            MySqlCommand command4 = new MySqlCommand("SELECT ID,FirstName,LastName,Company FROM contacts where FirstName LIKE '%" + text + "%' OR  FirstName LIKE '%" + text + "%' OR LastName LIKE '%" + text + "%' OR  LastName LIKE '%" + text + "%' OR Company LIKE '%" + text + "%' OR  Company LIKE '%" + text + "%' OR MobilePhone LIKE '%" + text + "%' OR EmailAddress LIKE '%" + text + "%' OR  EmailAddress LIKE '%" + text + "%' OR BusinessPhone LIKE '%" + text + "%'", connection);

            DataTable dataTable4 = new DataTable();
            MySqlDataAdapter da4 = new MySqlDataAdapter(command4);

            da4.Fill(dataTable4);
            dataTable4.TableName = "Contacts";
            //GridView3.DataSource = dataTable4;
            //GridView3.DataBind();
            //MySqlCommand command = connection.CreateCommand();
            //MySqlDataReader reader;

            //command.CommandText = "SELECT * FROM information where id=" + text;
            //command.Prepare();
            ////command.Parameters.AddWithValue("@p1", item);
            //reader = command.ExecuteReader();
            //reader.Read();
            //person.id = Convert.ToInt32(reader["id"]);
            //person.name = reader["name"].ToString();
            //person.phone = Convert.ToInt32(reader["phone"]);

            //reader.Close();
            connection.Close();

            return dataTable4;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Person p = new Person("Black");

            p.Name = "Sally Brown";
            p.Age = 20;

            lblPerson.Text = p.Name + " is " + p.Age.ToString() + " years old and has " + p.EyeColor + " eyes";

            lblWalk.Text = p.Walk();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Person p = new Person();

            p.Name = "John Lee";

            //method overloading
            lblWalkInt.Text = p.Walk(100);

            lblWalkString.Text = p.Walk("Back");

            lblWalkNone.Text = p.Walk();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Person p1 = new Person();
            Person p2 = new Person();

            p1.Name = "Sally Brown";
            p1.Age = 20;
            lblPerson1.Text = p1.Name + " is " + p1.Age.ToString() + " years old and has " + p1.EyeColor + " eyes.";

            p2.Name = "John Smith";
            p2.Age = 24;
            lblPerson2.Text = p2.Name + " is " + p2.Age.ToString() + " years old and has " + p2.EyeColor + " eyes.";
        }
Ejemplo n.º 5
0
        public Person findperson(int id)
        {
            Person person = new Person();

            MySqlConnection connection = new MySqlConnection();
            connection.ConnectionString = connectionString;
            connection.Open();
            MySqlCommand command = connection.CreateCommand();
            MySqlDataReader reader;

            command.CommandText = "SELECT * FROM information where id=" + Convert.ToString(id);
            command.Prepare();
            //command.Parameters.AddWithValue("@p1", item);
            reader = command.ExecuteReader();
            reader.Read();
            person.id = Convert.ToInt32(reader["id"]);
            person.name = reader["name"].ToString();
            person.phone = Convert.ToInt32(reader["phone"]);

            reader.Close();
            connection.Close();

            return person;
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Deprecated Method for adding a new object to the People EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPeople(Person person)
 {
     base.AddObject("People", person);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Create a new Person object.
 /// </summary>
 /// <param name="personID">Initial value of the PersonID property.</param>
 public static Person CreatePerson(global::System.Int32 personID)
 {
     Person person = new Person();
     person.PersonID = personID;
     return person;
 }