public MainWindow() { InitializeComponent(); Models.Employee e = new Models.Employee(); e.name = "base"; }
public void employeeAdd(String email, String password, String name, String address, String dateOfBirth, String gender, String role) { Console.WriteLine(email); DateTime dt = DateTime.Now; dateOfBirth = dt.ToString(); if (email == "") { throw new Exception("email is empty"); } if (password == "") { throw new Exception("password is empty"); } if (name == "") { throw new Exception("name is empty"); } if (address == "") { throw new Exception("address is empty"); } /*if (dateOfBirth == "") * { * throw new Exception("dateOfBirth is empty"); * * }*/ if (gender == "") { throw new Exception("gender is empty"); } if (role == "") { throw new Exception("email is empty"); } Models.Employee emp = new Models.Employee(email, password, name, address, dateOfBirth, gender, role); Dal.DatabaseConnector connector = new Dal.DatabaseConnector(); try { connector.addEmployee(emp); } catch (Exception excp) { throw excp; } }
public void addEmployee(Models.Employee emp) { String query = "INSERT INTO `employee` (`id`, `email`, `password`, `dateOfBirth`, `address`, `role`, `gender`, `name`) VALUES (NULL, '" + emp.email + "', '" + emp.password + "', '" + emp.dateOfBirth + "', '" + emp.address + "', '" + emp.role + "', '" + emp.gender + "', '" + emp.name + "')"; Console.WriteLine(query); MySqlConnection databaseConnection = new MySqlConnection(MysqlConnetionString); MySqlCommand comandDatabase = new MySqlCommand(query, databaseConnection); comandDatabase.CommandTimeout = 60; try { databaseConnection.Open(); MySqlDataReader myReader = comandDatabase.ExecuteReader(); } catch (Exception e) { throw e; } }