Пример #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     Person p = new Person(Convert.ToInt32(textBox4.Text), textBox1.Text,
         Convert.ToInt32(textBox2.Text),textBox3.Text);
     new PersonAction().add(p);
     Form myForm = new Form3();
     myForm.ShowDialog();
 }
Пример #2
0
        public void add(Person p)
        {
            MySqlConnection conn = DBSource.getConn();

            String sqlInsert = "insert into person(id,name,age,descs) values("+p.Id+",'"+p.Name+"',"+p.Age+",'"+p.Desc+"')";
            MySqlCommand mysqlinsert = new MySqlCommand(sqlInsert,conn);
            conn.Open();
            mysqlinsert.ExecuteNonQuery();
            conn.Close();
        }
 public fAltersvorsorgerechner()
 {
     InitializeComponent();
     Personen[0] = new Person();
     Personen[0].Farbe = Color.GreenYellow;
     Personen[1] = new Person();
     Personen[1].Farbe = Color.Goldenrod;
     pSichtblende.Location = new Point(6, 160);
     pSichtblende.BringToFront();
     nudGAInRenteGehenImJahr.Minimum = DateTime.Today.Year;
     nudGAInRenteGehenImJahr.Maximum = DateTime.Today.Year + 50;
     nudGaZPInRenteGehenImJahr.Minimum = DateTime.Today.Year;
     nudGaZPInRenteGehenImJahr.Maximum = DateTime.Today.Year + 50;
 }
Пример #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            //传递给update()
            Person p = new Person();
            p.Id = Convert.ToInt32(richTextBox1.Text);
            p.Medicine = richTextBox2.Text;
            new PersonAction().update(p);

            Person p1 = new PersonAction().queryOne(Convert.ToInt32(richTextBox1.Text));
            String str = "挂号业务ID:" + p1.Id + "\n"
                                           + "姓名:" + p1.Name + "\n"
                                           + "年龄:" + p1.Age + "\n"
                                           + "症状:" + p1.Desc + "\n"
                                           + "诊疗方法和建议: " + p1.Medicine + "\n";
            Form5 myForm = new Form5(str);
            myForm.ShowDialog();
        }
Пример #5
0
        public List<Person> query()
        {
            MySqlConnection conn = DBSource.getConn();
            String sqlSearch = "select * from person";
            MySqlCommand mysqlcommand = new MySqlCommand(sqlSearch, conn);
            conn.Open();
            MySqlDataReader reader = mysqlcommand.ExecuteReader();
            List<Person> person = new List<Person>();
            Person p = null;
            try
            {
                while (reader.Read())
                {
                    p = new Person();
                    if (reader.HasRows)
                    {
                        p.Id = reader.GetInt32(0);
                        p.Name = reader.GetString(1);
                        p.Age = reader.GetInt32(2);
                        p.Desc = reader.GetString(3);
                        p.Medicine = reader.GetString(4);
                        //Console.WriteLine(" 姓名:  " + reader.GetString(1) + "  编号  " + reader.GetInt32(0) + "  地址  " + reader.GetString(2));
                    }
                    person.Add(p);
                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine("查询失败!" + ex.Message);
            }
            finally
            {
                reader.Close();
            }
            conn.Close();

               return person;
        }
Пример #6
0
        private void FormInterface_Load(object sender, EventArgs e)
        {
            IOperation operation;
            Person p = new Person();

            IPerson person = p as IPerson;
            operation = p as IOperation;

            person.Lastname = "Cajandig";
            person.Firstname = "Mikel";
            //operation.Save();



            Customer c = new Customer();
            Icustomer customer = c as Icustomer;
            operation = c as IOperation;
            customer.LastName = "tininin";
            operation.Save();

             
           
        }
Пример #7
0
 public void update(Person p)
 {
     PersonDao personDao = new PersonDao();
     personDao.update(p);
 }
Пример #8
0
 public void add(Person p)
 {
     PersonDao personDao = new PersonDao();
     personDao.add(p);
 }
Пример #9
0
        static void Main()
        {
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());
            #region 擴充方法練習
            int money = 123456789;
            int date = 20151022;
            double p = 0.123453333;
            Console.WriteLine(money.FormatForMoney());
            Console.WriteLine(date.FormatForDate());
            Console.WriteLine(p.FormatPercent());
            #endregion

            #region list 多型 委派 練習
            List<Student> std = GetStudent();
            Console.WriteLine(std[0].id);
            std.Add(AddStudent("007", "王八"));
            foreach (Student element in std)
            {
                Console.WriteLine(element.id);
                Console.WriteLine(element.name);
            }
            Console.WriteLine("------------------------------");
            std.ForEach(delegate(Student name)
            {
                Console.WriteLine(name.id);
                Console.WriteLine(name.name);
            });
            Person jeff = new Person("jeff") { Age = 11 };
            List<Person> people = new List<Person>
            {
                new Person("aaa") {Age = 1},
                new Person("bbb") {Age = 2},
                new Person("ccc") {Age = 3}
            };

            people.ForEach(delegate(Person element)
            {
                Console.WriteLine("name:" + element.name);
                Console.WriteLine("Age:" + element.Age);
            });

            IEnumerable<int> aaa = GetCollection();
            aaa = GetCollection3(aaa);
            foreach (int element in aaa)
            {
                Console.WriteLine(element);
            }
            #endregion
            Bitmap bm = GenerateImage("2345");
            bm.Save("aaa.bmp", ImageFormat.Bmp);
        }
Пример #10
0
        public Person queryOne(int id)
        {
            MySqlConnection conn = DBSource.getConn();
            String sqlSearch = "select * from person where id = " + id + "";
            MySqlCommand mysqlcommand = new MySqlCommand(sqlSearch, conn);
            conn.Open();
            MySqlDataReader reader = mysqlcommand.ExecuteReader();
            Person p = null;
            try
            {
                while (reader.Read())
                {
                    p = new Person();
                    if (reader.HasRows)
                    {
                        p.Id = reader.GetInt32(0);
                        p.Name = reader.GetString(1);
                        p.Age = reader.GetInt32(2);
                        p.Desc = reader.GetString(3);
                        p.Medicine = reader.GetString(4);
                    }
                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine("查询失败!" + ex.Message);
            }
            finally
            {
                reader.Close();
            }
            conn.Close();

            return p;
        }
Пример #11
0
 public void update(Person p)
 {
     MySqlConnection conn = DBSource.getConn();
     String sqlUpdate = "update person set medicine = '" + p.Medicine + "' where id =" + p.Id + "";
     MySqlCommand mysqlupdate = new MySqlCommand(sqlUpdate, conn);
     conn.Open();
     mysqlupdate.ExecuteNonQuery();
     conn.Close();
 }