public void put(object obj) { conn = new MySqlConnection(connectionString); conn.Open(); DepttProgram dp = obj as DepttProgram; string cmd = string.Format("insert into programs (id, title, deptt) values ('{0}', '{1}', '{2}');", dp.getId(), dp.getTitle(), dp.getDepartment()); MySqlCommand command = new MySqlCommand(cmd, conn); command.ExecuteNonQuery(); conn.Close(); }
public object get(string id) { conn = new MySqlConnection(connectionString); conn.Open(); string readcmd = string.Format("select * from programs where id = '{0}';", id); MySqlCommand sqlcmd = new MySqlCommand(readcmd, conn); MySqlDataReader reader = sqlcmd.ExecuteReader(); DepttProgram dp = null; while (reader.Read()) { if (reader.GetString(0) == id) { dp = new DepttProgram(reader.GetString(0), reader.GetString(1), reader.GetString(2)); break; } } conn.Close(); return(dp); }
private void button1_Click(object sender, EventArgs e) { Course c = new Course(); c.setId(idText.Text); c.setTitle(titleText.Text); int temp; int.TryParse(creditText.Text, out temp); c.setCredit(temp); int.TryParse(tpcText.Text, out temp); c.setTuitionPerCredit(temp); c.setProgram(comboBox1.Text); DepttProgram dp = new DepttProgram(idText.Text, titleText.Text, comboBox1.Text); PersistenceFacade.getInstance().put(c); PersistenceFacade.getInstance().put(dp); update(); }
public Object get(string id, DepttProgram dp) { DepttProgramMapper map = new DepttProgramMapper(); return(map.get(id) as DepttProgram); }
// DepttProgram public void put(DepttProgram dp) { DepttProgramMapper map = new DepttProgramMapper(); map.put(dp); }