private bool checkAllNotEmptyFields() { var emailValid = (checkBoxEmail.Checked) ? helperForm.isValidEmail(textBoxEmail.Text) : true; return(helperForm.checkedAndNotEmpty(textBoxName, null, checkBoxName) && helperForm.checkedAndNotEmpty(textBoxLastName, null, checkBoxLastName) && helperForm.checkedAndNotEmpty(null, maskedTextBoxID, checkBoxCnp) && helperForm.checkedAndNotEmpty(textBoxMI, null, checkBoxMI) && helperForm.checkedAndNotEmpty(textBoxOccupation, null, checkBoxOccupation) && helperForm.checkedAndNotEmpty(textBoxEmail, null, checkBoxEmail) && emailValid && helperForm.checkedAndNotEmpty(textBoxAddress, null, checkBoxAddress) && helperForm.checkedAndNotEmpty(textBoxHeight, null, checkBoxHeight) && helperForm.checkedAndNotEmpty(textBoxWeight, null, checkBoxWeight) && helperForm.checkedAndNotEmpty(textBoxAllergies, null, checkBoxAllergies)); }
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; } }