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 void updateDependentDetails() { DependentDetails dd = new DependentDetails(); dd.dd_id = this.dd_id; dd.birth_certificate = this.depend_birth_certificate.Text; dd.setDate_of_post(this.depend_date_of_post_date.Value.Date); dd.education = this.depend_education.Text; dd.full_name = this.depend_full_name.Text; dd.marriage_certificate = this.depend_marriage_certificate.Text; dd.nic_no = this.depend_nic_no.Text; dd.note = this.depend_note.Text; dd.office_tp = this.depend_office_tp.Text; dd.official_address = this.depend_official_address.Text; dd.personal_address = this.depend_personal_address.Text; dd.personal_tp = this.depend_personal_tp.Text; dd.relation = this.depend_relation.Text; dd.salutation = this.depend_salutation.Text; dd.status = this.depend_status.Text; bool state = DependentDetailsHandler.updateDependentDetails(dd); Console.Write(state + "\n"); }
public static DependentDetails getDependentDetails() { //try //{ DBConnector dbcon = new DBConnector(); if (dbcon.openConnection()) { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = "SELECT * FROM dependent_details WHERE employee_idemployee=" + Employee.employee_id; cmd.Connection = dbcon.connection; MySqlDataReader reader = cmd.ExecuteReader(); Console.Write(Employee.employee_id + "\n"); DependentDetails dd = null; if (reader.Read()) { dd = new DependentDetails(); dd.dd_id = int.Parse(reader["iddependent_details"].ToString()); dd.birth_certificate = reader["birth_certificate"].ToString(); dd.setDate_of_post(Convert.ToDateTime(reader["date_of_post"])); if (reader["deathade"].ToString() == "True") { dd.deathade = true; } else { dd.deathade = false; } if (reader["doctor"].ToString() == "True") { dd.doctor = true; } else { dd.doctor = false; } dd.full_name = reader["full_name"].ToString(); dd.marriage_certificate = reader["marriage_certificate"].ToString(); dd.nic_no = reader["nic_no"].ToString(); dd.note = reader["note"].ToString(); dd.office_tp = reader["office_tp"].ToString(); dd.official_address = reader["official_address"].ToString(); dd.personal_address = reader["personal_address"].ToString(); dd.personal_tp = reader["personal_tp"].ToString(); dd.relation = reader["relation"].ToString(); dd.salutation = reader["salutation"].ToString(); dd.status = reader["status"].ToString(); dd.education = reader["education"].ToString(); } reader.Close(); dbcon.closeConnection(); return dd; } else { return null; } //} //catch (MySqlException e) //{ //int errorcode = e.Number; //return null; //} }
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; //} }
private void btnSave3_Click(object sender, EventArgs e) { DependentDetails dd = new DependentDetails(); dd.birth_certificate = depend_birth_certificate.Text; dd.setDate_of_post(depend_date_of_post_date.Value.Date); dd.education = depend_education.Text; dd.full_name = depend_full_name.Text; dd.marriage_certificate = depend_marriage_certificate.Text; dd.nic_no = depend_nic_no.Text; dd.note = depend_note.Text; dd.office_tp = depend_office_tp.Text; dd.official_address = depend_official_address.Text; dd.personal_address = depend_personal_address.Text; dd.personal_tp = depend_personal_tp.Text; dd.relation = depend_relation.Text; dd.salutation = depend_salutation.Text; dd.status = depend_status.Text; if (depend_deathade.Checked) { dd.deathade = true; } else { dd.deathade = false; } if (depend_medical.Checked) { dd.doctor = true; } else { dd.doctor = false; } bool status = DependentDetailsHandler.addDependentDetails(dd); if (status) { MessageBox.Show("Dependent details added successfully...!"); //btnSave4.Enabled = true; //btnSave5.Enabled = true; } else { MessageBox.Show("Failed to add dependent details...!"); } }