public static bool addMembership(Membership m) { DBConnector dbcon = new DBConnector(); try { if (dbcon.openConnection()) { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = "INSERT INTO membership (institute, post_name, method, member_id, contribution, begin_date, renewal_date, status, personal_payment, active_date_person, institutional_payment, active_date_insti, employee_idemployee) VALUES (N'" + m.institute + "', N'" + m.post_name + "', N'" + m.method + "', N'" + m.member_id + "', N'" + m.contribution + "', '" + m.getBegin_date().ToString("yyyy-MM-dd") + "', '" + m.getRenewal_date().ToString("yyyy-MM-dd") + "', N'" + m.status + "', " + m.personal_payment + ", '" + m.getActive_date_person().ToString("yyyy-MM-dd") + "', " + m.institutional_payment + ", '" + m.getActive_date_insti().ToString("yyyy-MM-dd") + "', " + Employee.employee_id + ")"; cmd.Connection = dbcon.connection; cmd.Prepare(); cmd.ExecuteNonQuery(); dbcon.closeConnection(); return true; } else { dbcon.closeConnection(); return false; } } catch (MySqlException e) { int errorcode = e.Number; dbcon.closeConnection(); return false; } }
public static bool updateMembership(Membership m) { //try //{ DBConnector dbcon = new DBConnector(); if (dbcon.openConnection()) { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = "UPDATE membership SET institute=N'" + m.institute + "', post_name=N'" + m.post_name + "', method=N'" + m.method + "', member_id=N'" + m.member_id + "', contribution=N'" + m.contribution + "', begin_date='" + m.getBegin_date().ToString("yyyy-MM-dd") + "', renewal_date='" + m.getRenewal_date().ToString("yyyy-MM-dd") + "', status=N'" + m.status + "', personal_payment=" + m.personal_payment + ", active_date_person='" + m.getActive_date_person().ToString("yyyy-MM-dd") + "', institutional_payment=" + m.institutional_payment + ", active_date_insti='" + m.getActive_date_insti().ToString("yyyy-MM-dd") + "' WHERE employee_idemployee=" + Employee.employee_id + " AND idmembership=" + m.mem_id; cmd.Connection = dbcon.connection; cmd.Prepare(); cmd.ExecuteNonQuery(); dbcon.closeConnection(); return true; } else { return false; } //} //catch (MySqlException e) //{ //int errorcode = e.Number; //return false; //} }