private void btnGuardarDoctor_Click(object sender, EventArgs e) { int habilitado = 1; bool flag = true; Doctor doctor = new Doctor(); doctor.nombreDoctor = txtNombreDoc.Text; doctor.apellidoDoctor = txtApellidoDoc.Text; doctor.edadDoctor = Int32.Parse(txtEdadDoc.Text); doctor.especialidad = cmbEspecialidad.Text; doctor.universidad = txtUniversidadDoc.Text; doctor.idClinica = Convert.ToInt32(cmbClinica.SelectedValue.ToString()); doctor.dhabilitado = habilitado; while (String.IsNullOrWhiteSpace(txtNombreDoc.Text) || String.IsNullOrWhiteSpace(txtApellidoDoc.Text) || String.IsNullOrWhiteSpace(txtEdadDoc.Text) || String.IsNullOrWhiteSpace(cmbEspecialidad.Text) || String.IsNullOrWhiteSpace(txtUniversidadDoc.Text) || String.IsNullOrWhiteSpace(cmbClinica.Text)) { MessageBox.Show("Llena todos los campos"); flag = false; break; } if (flag == false) { return; } else { int resultado = _dataAccessLayer.guardarDoctor( "insertarDoctor", new ArrayList { "@nombreDoctor", "@apellidoDoctor", "@edadDoctor", "@especialidad", "@universidad", "@idClinica", "@dhabilitado" }, new ArrayList { doctor.nombreDoctor, doctor.apellidoDoctor, doctor.edadDoctor, doctor.especialidad, doctor.universidad, doctor.idClinica, doctor.dhabilitado }); if (resultado == 1) { MessageBox.Show("Registro incertado"); llenarTablaDoctores(); } } }
private void btnGuardarMed_Click(object sender, EventArgs e) { int habilitado = 1; bool flag = true; Medicamento medicamento = new Medicamento(); medicamento.nombre = txtNombreMed.Text; medicamento.laboratorio = txtLaboratorio.Text; medicamento.administracion = txtAdministracion.Text; medicamento.especialidad = cmbEspecialidad.Text; medicamento.habilitado = habilitado; while (String.IsNullOrWhiteSpace(txtNombreMed.Text) || String.IsNullOrWhiteSpace(txtLaboratorio.Text) || String.IsNullOrWhiteSpace(txtAdministracion.Text) || String.IsNullOrWhiteSpace(cmbEspecialidad.Text) || String.IsNullOrWhiteSpace(cmbEspecialidad.Text)) { MessageBox.Show("Llena todos los campos"); flag = false; break; } if (flag == false) { return; } else { int resultado = _dataAccessLayer.guardarDoctor( "insertarMedicamento", new ArrayList { "@nombreMedicamento", "@laboratorio", "@administracion", "@habilitado", "@especialidad" }, new ArrayList { medicamento.nombre, medicamento.laboratorio, medicamento.administracion, medicamento.habilitado, medicamento.especialidad }); if (resultado == 1) { MessageBox.Show("Registro insertado"); llenarTablaMedicamentos(); } } }