Esempio n. 1
0
 public ArrayList getUser()
 {
     string query = "SELECT * from tbl_user";
     list = new ArrayList();
     openConnection();
     MySqlCommand cmd = new MySqlCommand(query, connection);
     try
     {
         MySqlDataReader dataReader = cmd.ExecuteReader();
         while (dataReader.Read())
         {
             User u = new User();
             u.id = dataReader.GetString(0);
             u.name = dataReader.GetString(1);
             u.department = dataReader.GetString(2);
             u.contactWith = dataReader.GetString(3);
             u.idCard = dataReader.GetString(4);
             u.placeOfIdCard = dataReader.GetString(5);
             u.dateOfIdCard = dataReader.GetString(6);
             u.image = dataReader.GetString(7);
             list.Add(u);
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("Unable To Connect To Database!", "Database Warning!");
     }
     closeConnection();
     return list;
 }
Esempio n. 2
0
 public void addUser(User u)
 {
     if (db.addUser(u))
     {
         message = "Add Compeleted!";
     }
     else message = "Add Error!";
 }
Esempio n. 3
0
 private void addUser()
 {
     User u = new User();
     u.id = tbId.Text;
     u.name = tbName.Text;
     u.department = tbDepartment.Text;
     u.contactWith = tbContactWith.Text;
     u.idCard = tbIdCard.Text;
     u.placeOfIdCard = tbPlaceOfIdCard.Text;
     u.dateOfIdCard = tbDateOfIdCard.Text;
     u.image = Path.GetFileName(filePath);
     um.addUser(u);
     copyImage(filePath);
     MessageBox.Show(um.getMessage(), "System");
 }
Esempio n. 4
0
 public bool addUser(User u)
 {
     if (openConnection())
     {
         MySqlCommand cmd = connection.CreateCommand();
         cmd.CommandText = "INSERT INTO tbl_User values (@id, @name, @department, @contactWith, @idCard, @placeOfIdCard, @dateOfIdCard, @image)";
         cmd.Parameters.AddWithValue("@id", u.id);
         cmd.Parameters.AddWithValue("@name", u.name);
         cmd.Parameters.AddWithValue("@department", u.department);
         cmd.Parameters.AddWithValue("@contactWith", u.contactWith);
         cmd.Parameters.AddWithValue("@idCard", u.idCard);
         cmd.Parameters.AddWithValue("@placeOfIdCard", u.placeOfIdCard);
         cmd.Parameters.AddWithValue("@dateOfIdCard", u.dateOfIdCard);
         cmd.Parameters.AddWithValue("@image", u.image);
         cmd.ExecuteNonQuery();
         closeConnection();
         return true;
     }
     return false;
 }