public static bool addDependentDetails(DependentDetails dd) { DBConnector dbcon = new DBConnector(); //try //{ if (dbcon.openConnection()) { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = "INSERT INTO dependent_details (salutation, full_name, relation, date_of_post, nic_no, personal_tp, office_tp, personal_address, official_address, education, status, note, birth_certificate, marriage_certificate, deathade, doctor, employee_idemployee) VALUES (N'" + dd.salutation + "', N'" + dd.full_name + "', N'" + dd.relation + "', '" + dd.getDate_of_post().ToString("yyyy-MM-dd") + "', N'" + dd.nic_no + "', N'" + dd.personal_tp + "', N'" + dd.office_tp + "', N'" + dd.personal_address + "', N'" + dd.official_address + "', N'" + dd.education + "', N'" + dd.status + "', N'" + dd.note + "', N'" + dd.birth_certificate + "', N'" + dd.marriage_certificate + "', " + dd.deathade + ", " + dd.doctor + ", " + 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 updateDependentDetails(DependentDetails dd) { //try //{ DBConnector dbcon = new DBConnector(); if (dbcon.openConnection()) { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = "UPDATE dependent_details SET salutation=N'" + dd.salutation + "', full_name=N'" + dd.full_name + "', relation=N'" + dd.relation + "', date_of_post='" + dd.getDate_of_post().ToString("yyyy-MM-dd") + "', nic_no=N'" + dd.nic_no + "', office_tp=N'" + dd.office_tp + "', personal_address=N'" + dd.personal_address + "', official_address=N'" + dd.official_address + "', personal_tp=N'" + dd.personal_tp + "', education=N'" + dd.education + "', status=N'" + dd.status + "', note=N'" + dd.note + "', birth_certificate=N'" + dd.birth_certificate + "', marriage_certificate=N'" + dd.marriage_certificate + "', deathade=" + dd.deathade + ", doctor=" + dd.doctor + " WHERE employee_idemployee=" + Employee.employee_id + " AND iddependent_details=" + dd.dd_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; //} }