예제 #1
0
        // Get a single employee
        public Employee get(string fullName)
        {
            string[] FullNameArr = Regex.Split(fullName, @"\s+").Where(s => s != string.Empty).ToArray();
            string   FirstName   = FullNameArr[0];
            string   LastName    = FullNameArr[1];

            BangazonConnection conn = new BangazonConnection();
            Employee           e    = null;

            conn.execute(@"select 
				EmployeeId,
				FirstName, 
				LastName, 
				DepartmentName,
                FROM Employee,
                WHERE FirstName = '" + FirstName + "' AND " + "LastName = '" + LastName + "'",
                         (SqliteDataReader reader) => {
                while (reader.Read())
                {
                    e = new Employee
                    {
                        EmployeeId     = reader.GetInt32(0),
                        FirstName      = reader[1].ToString(),
                        LastName       = reader[2].ToString(),
                        DepartmentName = reader[3].ToString()
                    };
                }
            });

            return(e);
        }
        public void save()
        {
            BangazonConnection conn = new BangazonConnection();

            Employee emp = new Employee();

            string query = string.Format(@"
			insert into Employee 
			  (FirstName, LastName, EmployeeId, DepartmentName)
			values 
			  ('{0}', '{1}', '{2}', '{3}');
			"            ,
                                         this.FirstName,
                                         this.LastName,
                                         this.EmployeeId,
                                         this.DepartmentName
                                         );

            conn.insert(query);
        }