public string addVisit(visitData visit) { string idVisit = ""; try { command.CommandText = "Select [Код] from [visit] where [idOrder] = " + visit.IdOrder; using (OleDbDataReader reader = command.ExecuteReader()) { if (reader.HasRows) { reader.Read(); idVisit = reader.GetValue(0).ToString().Trim(); } } if (idVisit == "") { command.CommandText = "Insert into [visit] ([idDoctor],[idPatient],[dateVisit],[idOrder]) values (" + visit.IdDoctor + "," + visit.IdPatient + ",#" + getDate(visit.DateVisit) + "#," + visit.IdOrder + ")"; command.ExecuteNonQuery(); command.CommandText = "select max([Код]) from [visit]"; using (OleDbDataReader reader = command.ExecuteReader()) { reader.Read(); idVisit = reader.GetValue(0).ToString().Trim(); } } } catch { } return(idVisit); }
public visitData loadVisit(string idVisit) { visitData visit = new visitData(); try { command.CommandText = "Select * from [visit_Запрос] where [Код] = " + idVisit; using (OleDbDataReader reader = command.ExecuteReader()) { reader.Read(); visit.DateVisit = reader.GetValue(0).ToString().Trim(); visit.DoctorInfo = ""; for (int i = 0; i < 4; i++) { visit.DoctorInfo += reader.GetValue(i + 1).ToString().Trim() + " "; } visit.Obsl = reader.GetValue(5).ToString().Trim(); visit.Symp = reader.GetValue(6).ToString().Trim(); visit.Recomd = reader.GetValue(7).ToString().Trim(); visit.Medicament = reader.GetValue(8).ToString().Trim(); visit.Diagnose = reader.GetValue(9).ToString().Trim(); } } catch { } return(visit); }
public addVisit(visitData _visit, dataBase _connector) { InitializeComponent(); visit = _visit; connector = _connector; }
public diagnose(string _idVisit, diagnoseControl _cont) { InitializeComponent(); idvisit = new visitData(); cont = _cont; idvisit.Id = _idVisit; }
private void button2_Click(object sender, EventArgs e) { save(); if (comboBox1.Items.Count > 0 && comboBox2.Items.Count > 0) { visitData visit = new visitData(); visit.DateVisit = dateTimePicker1.Value.ToShortDateString(); visit.IdDoctor = idDoctors[comboBox1.SelectedIndex]; visit.IdPatient = idPatients[comboBox2.SelectedIndex]; visit.IdOrder = idOrder; visit.Id = connector.addVisit(visit); this.Visible = false; addVisit showVisit = new addVisit(visit, connector); showVisit.ShowDialog(); this.Visible = true; Close(); } }
public visitData load() { visitData visit = connector.loadVisit(idvisit); return(visit); }