protected void btn_Guardar_Click(object sender, EventArgs e) { try { Entidad.Paciente p = new Entidad.Paciente(); p.Nombres = tb_nombres.Text.Trim().ToUpper(); p.Apellidos = tb_apellidos.Text.Trim().ToUpper(); p.Fecha_nacimiento = Convert.ToDateTime(tb_fechaNacimiento.Text); p.Direccion = tb_direccion.Text.Trim().ToUpper(); p.Telefono = tb_telefono.Text; p.Celular = tb_celular.Text; Negocio.pacienteNegocio pn = new Negocio.pacienteNegocio(); int existe = pn.ValidarPaciente(p); if (existe == 0) { pn.InsertarPaciente(p); lb_mensajes.ForeColor = System.Drawing.Color.Green; lb_mensajes.Text = "Paciente insertado correctamente!!!"; CleanControl(this.Controls); } else { lb_mensajes.ForeColor = System.Drawing.Color.Red; lb_mensajes.Text = "Paciente ya existe!!!"; } } catch (Exception err) { throw new Exception(err.Message); } }
protected void btn_Guardar_Click(object sender, EventArgs e) { try { Entidad.Paciente p = new Entidad.Paciente(); p.Nombres = tb_nombres.Text.Trim().ToUpper(); p.Apellidos = tb_apellidos.Text.Trim().ToUpper(); p.Fecha_nacimiento = Convert.ToDateTime(tb_fechaNacimiento.Text); p.Direccion = tb_direccion.Text.Trim().ToUpper(); p.Telefono = tb_telefono.Text; p.Celular = tb_celular.Text; Negocio.pacienteNegocio pn = new Negocio.pacienteNegocio(); int existe = pn.ValidarPaciente(p); if (existe == 0) { string error = ""; error = pn.InsertarPaciente(p); if (error != "") { string mensaje = "MostrarMensaje('ERROR','La fecha de nacimiento no puede ser mayor a la fecha actual!!!')"; ScriptManager.RegisterStartupScript(this, GetType(), "mensaje", mensaje, true); } else { //lb_mensajes.ForeColor = System.Drawing.Color.Green; //lb_mensajes.Text = "Paciente insertado correctamente!!!"; string mensaje = "MostrarMensaje('SUCCESS','Registro insertado satisfactoriamente!!!')"; ScriptManager.RegisterStartupScript(this, GetType(), "mensaje", mensaje, true); CleanControl(this.Controls); } } else { //lb_mensajes.ForeColor = System.Drawing.Color.Red; //lb_mensajes.Text = "Paciente ya existe!!!"; string mensaje = "MostrarMensaje('ERROR','El paciente ya existe, por favor verifique!!!')"; ScriptManager.RegisterStartupScript(this, GetType(), "mensaje", mensaje, true); } } catch (Exception err) { throw new Exception(err.Message); } }