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 buttonConfirm_Click(object sender, EventArgs e) { int countCheck = 0; string command = "UPDATE patients SET "; List <string> paramList = new List <string>(); List <object> valueList = new List <object>(); if (checkBoxCnp.Checked) { selectedPatient.getCnpDetails(maskedTextBoxID.Text); command += "cnp=@cnp, sex=@sex, DOB=@DOB, RomanianCountry=@RomanianCountry, age=@age"; paramList.Add("@cnp"); valueList.Add(selectedPatient.CNP); paramList.Add("@sex"); valueList.Add(selectedPatient.Sex); paramList.Add("@DOB"); valueList.Add(selectedPatient.DateOfBirth.ToString("dd - MMM - yyyy")); paramList.Add("@RomanianCountry"); valueList.Add(selectedPatient.BirthPlace); paramList.Add("@age"); valueList.Add(selectedPatient.Age); countCheck++; } if (checkBoxName.Checked) { if (countCheck > 0) { command += ", "; } command += "name=@name"; paramList.Add("@name"); valueList.Add(textBoxName.Text); countCheck++; } if (checkBoxLastName.Checked) { if (countCheck > 0) { command += ", "; } command += "lastname=@lastname"; paramList.Add("@lastname"); valueList.Add(textBoxLastName.Text); countCheck++; } if (checkBoxMI.Checked) { if (countCheck > 0) { command += ", "; } command += "MI=@MI"; paramList.Add("@MI"); valueList.Add(textBoxMI.Text); countCheck++; } if (checkBoxEmail.Checked) { if (countCheck > 0) { command += ", "; } command += "email=@email"; paramList.Add("@email"); valueList.Add(textBoxEmail.Text); countCheck++; } if (checkBoxOccupation.Checked) { if (countCheck > 0) { command += ", "; } command += "occupation=@occupation"; paramList.Add("@occupation"); valueList.Add(textBoxOccupation.Text); countCheck++; } if (checkBoxAddress.Checked) { if (countCheck > 0) { command += ", "; } command += "address=@address"; paramList.Add("@address"); valueList.Add(textBoxAddress.Text); countCheck++; } if (checkBoxWeight.Checked) { if (countCheck > 0) { command += ", "; } command += "weight=@weight"; paramList.Add("@weight"); valueList.Add(double.Parse(textBoxWeight.Text)); } if (checkBoxHeight.Checked) { if (countCheck > 0) { command += ", "; } command += "height=@height"; paramList.Add("@height"); valueList.Add(double.Parse(textBoxHeight.Text)); } if (checkBoxAllergies.Checked) { if (countCheck > 0) { command += ", "; } command += "allergies=@allergies"; paramList.Add("@allergies"); valueList.Add(textBoxAllergies.Text); countCheck++; } command += " WHERE ID=@ID"; paramList.Add("@ID"); valueList.Add(selectedPatient.ID); if (connectionClass.sqlCommand(command, paramList, valueList, "Patient could not be modified!")) { buttonDiscard_Click(sender, e); selectedPatient = connectionClass.updatePatient(selectedPatient.ID); patientDetails(true); } }
private void buttonAddP_Click(object sender, EventArgs e) { string email = textBoxEmail.Text; if (!helperForm.isValidEmail(email)) { MessageBox.Show("Email format is not correct!"); return; } string cnp = maskedTextBoxID.Text; string name = textBoxName.Text; string lastname = textBoxLastName.Text; string MI = textBoxMI.Text; string address = textBoxAddress.Text; double weight = double.Parse(textBoxWeight.Text); double height = double.Parse(textBoxHeight.Text); string bloodType = (radioButton0I.Checked) ? "O (I)" : ( (radioButtonAII.Checked) ? "A (II)" : ( (radioButtonBIII.Checked) ? "B (III)" : "AB (IV)")); string rh = (radioButtonPositive.Checked) ? "POSITIVE" : "NEGATIVE"; string occupation = (radioButtonNoOccupation.Checked) ? "NO OCCUPATION" : ( (radioButtonStudent.Checked) ? "STUDENT" : ( (radioButtonRetired.Checked) ? "RETIRED" : ( (radioButtonUnemployed.Checked) ? "UNEMPLOYED" : textBoxOccupation.Text))); string allergies = textBoxAllergies.Text; string command = "INSERT INTO patients(IDDoc,name,MI,lastname,cnp,email,address,"; command += "occupation,sex,DOB,RomanianCountry,age,weight,height,bloodType,rh,allergies) "; command += "VALUES(@IDDoc,@name,@MI,@lastname,@cnp,@email,@address,"; command += "@occupation,@sex,@DOB,@RomanianCountry,@age,@weight,@height,@bloodType,@rh,@allergies)"; List <string> paramList = new List <string>(); List <object> valueList = new List <object>(); paramList.Add("@IDDoc"); valueList.Add(IdDoc); paramList.Add("@name"); valueList.Add(name); paramList.Add("@MI"); valueList.Add(MI); paramList.Add("@lastname"); valueList.Add(lastname); paramList.Add("@cnp"); valueList.Add(cnp); paramList.Add("@email"); valueList.Add(email); paramList.Add("@address"); valueList.Add(address); paramList.Add("@occupation"); valueList.Add(occupation); paramList.Add("@sex"); valueList.Add(labelSex.Text); paramList.Add("@DOB"); valueList.Add(labelDOB.Text); paramList.Add("@RomanianCountry"); valueList.Add(labelBirthPlace.Text); paramList.Add("@age"); valueList.Add(int.Parse(labelAge.Text)); paramList.Add("@weight"); valueList.Add(weight); paramList.Add("@height"); valueList.Add(height); paramList.Add("@bloodType"); valueList.Add(bloodType); paramList.Add("@rh"); valueList.Add(rh); paramList.Add("@allergies"); valueList.Add(allergies); if (connectionClass.sqlCommand(command, paramList, valueList, "Patient CNP already exists!")) { newPatient = connectionClass.checkCNP(cnp); newPatient.getDoc(connectionClass); result = MessageBox.Show("Successfully inserted!"); emptyFields(); } else { maskedTextBoxID.Text = string.Empty; } }