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 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"); }
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...!"); } }