private void emptyFields() { if (consultations != null && consultations.Count > 0) { Consultation cons = (Consultation)consultations[0]; numericUpDownSearchID.Value = cons.ID; } else { numericUpDownSearchID.Value = numericUpDownSearchID.Minimum; } textBoxDiagnostic.Text = string.Empty; radioButtonToday.Checked = true; radioButtonAnotherDate.Checked = false; maskedTextBoxDate.Text = string.Empty; labelIdC.Visible = false; checkBoxID.Checked = false; checkBoxDate.Checked = false; checkBoxDiagnostic.Checked = false; updateDataGrid(); buttonConfirm.Enabled = false; }
private void insertConsultation() { string cim = new CimCodes(cims, textBoxDiagnostic.Text, "ID").ID; string date = (radioButtonToday.Checked) ? DateTime.Today.ToString("dd-MM-yyyy") : maskedTextBoxDate.Text; Consultation consultation = new Consultation(currentConsultation, selectedPatient.ID, cim, date); string command = "INSERT INTO consultations(IdPatient,CIM,ConsDate) VALUES(@IdPatient,@CIM,@ConsDate)"; List <string> paramList = new List <string>(); List <object> valueList = new List <object>(); paramList.Add("@IdPatient"); valueList.Add(consultation.IdPatient); paramList.Add("@CIM"); valueList.Add(consultation.CIM); paramList.Add("@ConsDate"); valueList.Add(consultation.Date); if (connectionClass.sqlCommand(command, paramList, valueList, "Invalid operation!")) { currentConsultation += 1; MessageBox.Show("Successfully inserted!"); emptyFields(); visibleAdd(); buttonModify.Enabled = true; buttonRemove.Enabled = true; buttonReport.Enabled = true; } }
private void dataGridViewConsultations_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { selectedConsultation = (Consultation)consultations[e.RowIndex]; if (selectedConsultation != null) { emptyFields(); numericUpDownSearchID.Visible = false; checkBoxDate.Checked = true; checkBoxDiagnostic.Checked = true; labelIdC.Text = selectedConsultation.ID.ToString(); labelIdC.Visible = true; textBoxDiagnostic.Text = new CimCodes(cims, selectedConsultation.CIM, "Diagnostic").Diagnostic; radioButtonToday.Checked = selectedConsultation.Date.Equals(DateTime.Today.ToString("dd-MM-yyyy")); radioButtonAnotherDate.Checked = !selectedConsultation.Date.Equals(DateTime.Today.ToString("dd-MM-yyyy")); if (radioButtonAnotherDate.Checked) { maskedTextBoxDate.Text = selectedConsultation.Date; } buttonConfirm.Enabled = true; } } catch (Exception ex) { MessageBox.Show("Choose a valid row.\n" + ex.ToString()); } }
public ArrayList getConsultationsData(string query) { MySqlDataReader rowReader = null; try { ArrayList listConsultations = new ArrayList(); rowReader = execReader(query); if (rowReader.HasRows) { while (rowReader.Read()) { int ID = int.Parse(rowReader["ID"].ToString()); int IdPatient = int.Parse(rowReader["IdPatient"].ToString()); string CIM = rowReader["CIM"].ToString(); string ConsDate = rowReader["ConsDate"].ToString(); Consultation cons = new Consultation(ID, IdPatient, CIM, ConsDate); listConsultations.Add(cons); } } rowReader.Close(); if (listConsultations.Count != 0) { return(listConsultations); } } catch (Exception ex) { if (rowReader != null) { rowReader.Close(); } Console.Write(ex); } return(null); }
private void buttonDiscard_Click(object sender, EventArgs e) { emptyFields(); buttonConfirm.Enabled = false; selectedConsultation = null; }