Esempio n. 1
0
        private static void Save()
        {
            Console.WriteLine("insert id, name, age, wage, active of new Person: ");
            String input = Console.ReadLine();

            try {
                String [] splitted = Regex.Split(input, "\\s*,\\s*");
                dao.Save(SplittedToPerson(splitted));
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
        }
 private void btnSave_MouseClick(object sender, MouseEventArgs e)
 {
     try
     {
         long   id   = Convert.ToInt64(tbId.Text);
         string name = tbName.Text;
         int    age  = Convert.ToInt32(tbAge.Text);
         double wage = Convert.ToDouble(tbWage.Text);
         dao.Save(new Person(id, name, age, wage));
     } catch (Exception ex)
     {
         lblStatus.Text = ex.Message;
     } finally
     {
         this.Dispose();
     }
 }
        public void Save()
        {
            long   id;
            string name;
            int    age;
            double wage;

            Console.WriteLine("insert id, name, age, wage sep by comma: ");
            String input = Console.ReadLine();

            String[] splitted = Regex.Split(input, "\\s*,\\s*");
            try
            {
                id   = Convert.ToInt64(splitted[0]);
                name = splitted[1];
                age  = Convert.ToInt32(splitted[2]);
                wage = Convert.ToDouble(splitted[3]);
                dao.Save(new Person(id, name, age, wage));
            } catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 4
0
 private void Insert()
 {
     dao.Save(new Person(1, "foo", 10, 100.0));
     dao.Save(new Person(2, "bar", 20, 200.0));
 }