private void btn_aceptar_Click(object sender, EventArgs e) { Errores errores = new Errores(); if (cb_dia_mes.SelectedItem == null) { errores.agregarError("El campo dia no puede ser nulo."); } if (cb_hora.SelectedItem == null) { errores.agregarError("El campo hora no puede ser nulo."); } if (errores.huboError()) { MessageBox.Show(errores.stringErrores(), "Clinica-FRBA ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (!pedirTurno()) { MessageBox.Show("No se pudo agregar el turno", "Clinica-FRBA ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Turno agregado correctamente", "Clinica-FRBA", MessageBoxButtons.OK, MessageBoxIcon.Information); } this.cerrar = true; this.Close(); } }
private void btn_cancelar_Click(object sender, EventArgs e) { Errores errores = new Errores(); if ((DateTime)cb_dia_desde.SelectedItem > (DateTime)cb_dia_hasta.SelectedItem) { errores.agregarError("La fecha final de la franja debe ser anterior a la inicial."); } if (tb_motivo.TextLength == 0) { errores.agregarError("Debe escribir un motivo de cancelacion"); } if (errores.huboError()) { MessageBox.Show(errores.stringErrores(), "Clinica-FRBA ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { SqlCommand cancelar = new SqlCommand("ELIMINAR_CAR.cancelarTurnoProfesional", DBConnector.ObtenerConexion()); cancelar.CommandType = CommandType.StoredProcedure; cancelar.Parameters.Add("@matricula", SqlDbType.BigInt).Value = matricula; cancelar.Parameters.Add("@fecha_desde", SqlDbType.Date).Value = (DateTime)cb_dia_desde.SelectedItem; cancelar.Parameters.Add("@fecha_hasta", SqlDbType.Date).Value = (DateTime)cb_dia_hasta.SelectedItem; cancelar.Parameters.Add("@motivo", SqlDbType.VarChar).Value = tb_motivo.Text; cancelar.ExecuteNonQuery(); MessageBox.Show("Franja Cancelada Correctamente", "Clinica-FRBA", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } }
private void button1_Click(object sender, EventArgs e) { Errores errores = new Errores(); if (dt_dia.Value.DayOfWeek == DayOfWeek.Sunday) { errores.agregarError("No se puede realizar una consulta un domingo"); } if (tb_diagnostico.TextLength == 0) { errores.agregarError("El diagnostico no puede ser nulo."); } if (tb_sintomas.TextLength == 0) { errores.agregarError("Los sintomas no pueden ser nulos."); } if (errores.huboError()) { MessageBox.Show(errores.stringErrores(), "Clinica-FRBA ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { SqlCommand insertar = new SqlCommand("ELIMINAR_CAR.registrarConsulta", DBConnector.ObtenerConexion()); insertar.CommandType = CommandType.StoredProcedure; insertar.Parameters.Add("@fecha", SqlDbType.DateTime).Value = dt_dia.Value.Date.Add(dt_hora.Value.TimeOfDay); insertar.Parameters.Add("@turno", SqlDbType.BigInt).Value = ((Turno)dgv_turno.CurrentRow.DataBoundItem).id_turno; insertar.Parameters.Add("@sintomas", SqlDbType.VarChar).Value = tb_sintomas.Text; insertar.Parameters.Add("@diagnostico", SqlDbType.VarChar).Value = tb_diagnostico.Text; insertar.ExecuteNonQuery(); MessageBox.Show("Atencion registrada Correctamente", "Clinica-FRBA", MessageBoxButtons.OK, MessageBoxIcon.Information); ActualizarHora(); ActualizarTurnos(); ActualizarCampos(); } }
private static int verificarErroresLexSin(ParseTree arbol, ParseTreeNode raiz, Errores errores) { int retorno; //1: Hay errores y no se recupero, 2: Hay errores y si se recupero, 3: No hay errores if (arbol.ParserMessages.Count > 0) { if (raiz == null) { errores.agregarError(new Error("Sintáctico", "Error fatal, no se recupero el analizador", "-", 0, 0)); retorno = 1; } else { retorno = 2; } //guardo mensajes List <LogMessage> msjerrores = arbol.ParserMessages; foreach (LogMessage error in msjerrores) { if (error.Message.Contains("Syntax")) { errores.agregarError(new Error("Sintáctico", error.Message, "-", error.Location.Line + 1, error.Location.Column + 1)); } else { errores.agregarError(new Error("Léxico", error.Message, "-", error.Location.Line + 1, error.Location.Column + 1)); } } } else { retorno = 3; } return(retorno); }
public object compilar(Entorno ent, Errores errores) { try { Generator generator = Generator.getInstance(); generator.addComment("Inicia Repeat"); this.condicion.falseLabel = generator.newLabel(); this.condicion.trueLabel = generator.newLabel(); ent.fors.AddLast(new IteFor(false, null)); ent.ycontinue.AddLast(this.condicion.falseLabel); ent.ybreak.AddLast(this.condicion.trueLabel); generator.addLabel(this.condicion.falseLabel); foreach (Instruccion sentencia in sentencias) { sentencia.compilar(ent, errores); } Retorno condition = this.condicion.compilar(ent); if (condition.type.tipo == Tipos.BOOLEAN) { generator.addLabel(condition.trueLabel); ent.fors.RemoveLast(); ent.ycontinue.RemoveLast(); ent.ybreak.RemoveLast(); generator.addComment("Finaliza Repeat"); } else { throw new Error("Semántico", "La condicion a evaluar en el repeat no es de tipo Boolean", ent.obtenerAmbito(), linea, columna); } } catch (Error ex) { errores.agregarError(ex); } return(null); }
private void btn_aceptar_Click(object sender, EventArgs e) { Rango_Atencion rango = new Rango_Atencion(); rango.matricula = profesional.matricula; rango.fecha_desde = franja_inicio.Value.Date; rango.fecha_hasta = franja_fin.Value.Date; Errores errores = new Errores(); if (rango.fecha_desde.Year < 2016 || rango.fecha_hasta.Year < 2016) { errores.agregarError("No se permiten registrar agendas anteriores a 2016"); } if (!rango.esValido()) { errores.agregarError("La fecha de inicio de la franja debe ser anterior a la de fin."); } if (rango.fecha_desde < ClinicaFrba.Utils.Fechas.getCurrentDateTime().Date || rango.fecha_hasta < ClinicaFrba.Utils.Fechas.getCurrentDateTime().Date) { errores.agregarError("Las fechas de inicio y fin de la franja deben ser posteriores o iguales al dia de hoy."); } if (agendas.Any(elem => !elem.esValida())) { errores.agregarError("La hora de fin del turno no puede ser anterior a la de inicio."); } if (agendas.Sum(elem => elem.horasDiarias()) > 48) { errores.agregarError("Esta prohibido trabajar mas de 48hs semanales. Por favor disminuya sus horas diarias."); } if (agendas.Any(elem => elem.id_especialidad == null)) { errores.agregarError("La especialidad no puede ser nula."); } if (agendas.Count == 0) { errores.agregarError("Debe seleccionar por lo menos un dia de la semana."); } if (Rango_Atencion.SeSolapan(profesional.matricula, rango)) { errores.agregarError("El rango seleccionado no puede solaparse con un rango ya registrado."); } if (errores.huboError()) { MessageBox.Show(errores.stringErrores(), "Clinica-FRBA: ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { insert(agendas, rango); MessageBox.Show("Se ha insertado la agenda correctamente.", "Clinica-FRBA", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } }
public object compilar(Entorno ent, Errores errores) { try { this.compilar(ent); } catch (Error ex) { errores.agregarError(ex); } return(null); }
public object compilar(Entorno ent, Errores errores) { try { if (ent.ybreak.Count == 0) { throw new Error("Semántico", "break no viene dentro de un ciclo", ent.obtenerAmbito(), linea, columna); } Generator.getInstance().addGoto(ent.ybreak.Last.Value); } catch (Error ex) { errores.agregarError(ex); } return(null); }
public object compilar(Entorno ent, Errores errores) { try { if (!ent.addStruct(this.id, this.attributes.Count, this.attributes)) { throw new Error("Semántico", "Ya existe un object con el id: " + this.id, ent.obtenerAmbito(), linea, columna); } this.validateParams(ent); } catch (Error ex) { errores.agregarError(ex); } return(null); }
public object compilar(Entorno ent, Errores errores) { try { Generator generator = Generator.getInstance(); generator.addComment("Inicia Case"); //AJUSTANDO UTILIDADES LinkedList <If> listaifs = new LinkedList <If>(); foreach (Opcion opcion in opciones) { opcion.variable = variable; listaifs.AddLast((If)opcion.compilar(ent, errores)); } for (int i = 0; i < listaifs.Count; i++) { If actual; if (i == listaifs.Count - 1) { actual = listaifs.ElementAt(i); if (this.sentenciasElse != null) { actual.sentenciasElse = this.sentenciasElse; } } else { LinkedList <Instruccion> lista = new LinkedList <Instruccion>(); actual = listaifs.ElementAt(i); If siguiente = listaifs.ElementAt(i + 1); lista.AddLast((Instruccion)siguiente); actual.sentenciasElse = lista; } } If ifmaster = listaifs.First.Value; //AREA DE COMPILACION ifmaster.compilar(ent, errores); generator.addComment("Finaliza Case"); } catch (Error ex) { errores.agregarError(ex); } return(null); }
public object compilar(Entorno ent, Errores errores) { try { Generator generator = Generator.getInstance(); generator.addComment("Inicia If"); Retorno condicion = this.condicion.compilar(ent); if (condicion.type.tipo == Tipos.BOOLEAN) { generator.addLabel(condicion.trueLabel); foreach (Instruccion instruccion in sentencias) { instruccion.compilar(ent, errores); } if (sentenciasElse != null) { string tempLbl = generator.newLabel(); generator.addGoto(tempLbl); generator.addLabel(condicion.falseLabel); foreach (Instruccion inselse in sentenciasElse) { inselse.compilar(ent, errores); } generator.addLabel(tempLbl); } else { generator.addLabel(condicion.falseLabel); } generator.addComment("Finaliza If"); } else { throw new Error("Semántico", "La condicion a evaluar en el if no es de tipo Boolean", ent.obtenerAmbito(), linea, columna); } } catch (Error ex) { errores.agregarError(ex); } return(null); }
public object compilar(Entorno ent, Errores errores) { try { Generator generator = Generator.getInstance(); Retorno value = this.value.compilar(ent); Simbolo newVar = ent.addVar(id, value.type, true, false, linea, columna); if (newVar.isGlobal) { if (newVar.type.tipo == Tipos.BOOLEAN) { if (value.getValue().Equals("1")) { generator.addGoto(value.trueLabel); } else { generator.addGoto(value.falseLabel); } string templabel = generator.newLabel(); generator.addLabel(value.trueLabel); generator.addSetStack("" + newVar.position, "1"); generator.addGoto(templabel); generator.addLabel(value.falseLabel); generator.addSetStack("" + newVar.position, "0"); generator.addLabel(templabel); } else { generator.addSetStack("" + newVar.position, value.getValue()); } } } catch (Error ex) { errores.agregarError(ex); } return(null); }
public object compilar(Entorno ent, Errores errores) { try { if (ent.ycontinue.Count == 0) { throw new Error("Semántico", "continue no viene dentro de un ciclo", ent.obtenerAmbito(), linea, columna); } IteFor @for = ent.fors.Last.Value; if (@for.isFor) { Asignacion actualizarVariable = @for.actualizarVariable; actualizarVariable.compilar(ent, errores); } Generator.getInstance().addGoto(ent.ycontinue.Last.Value); } catch (Error ex) { errores.agregarError(ex); } return(null); }
private void btn_agregar_Click(object sender, EventArgs e) { Agenda_Diaria nueva = new Agenda_Diaria(); Errores error = new Errores(); if (cb_dia.SelectedValue == null) { error.agregarError("Debe seleccionar un dia."); } if (l_especialidad.SelectedItem == null) { error.agregarError("La especialidad no puede ser nula."); } if (!error.huboError()) { nueva = new Agenda_Diaria(((Dia)cb_dia.SelectedItem).dia, profesional.matricula, (int)l_desde_h.Value, (int)l_desde_m.Value, (int)l_hasta_h.Value, (int)l_hasta_m.Value, ((Especialidad)l_especialidad.SelectedItem).id_especialidad); if (!nueva.esValida()) { error.agregarError("La hora de fin debe ser posterior a la de inicio."); } if (agendas.Sum(elem => elem.horasDiarias()) + nueva.horasDiarias() > 48) { error.agregarError("Esta prohibido trabajar mas de 48hs semanales. Si quiere agregar mas horas debe eliminar algunas."); } if (Agenda_Diaria.seSuperponen(agendas, nueva)) { error.agregarError("No puede elegir rangos que se superpongan en el mismo dia."); } if (agendas.Any(elem => elem.dia == nueva.dia && elem.id_especialidad == nueva.id_especialidad)) { error.agregarError("No se puede trabajar dos veces con la misma especialidad en el mismo dia."); } } if (!error.huboError()) { agendas.Add(nueva); actualizarAgenda(); } else { MessageBox.Show(error.stringErrores(), "Clinica-FRBA ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public object compilar(Entorno ent, Errores errores) { Generator generator = Generator.getInstance(); generator.addComment("Inicia Writeln"); try { foreach (Expresion expresion in expresiones) { Retorno value = expresion.compilar(ent); switch (value.type.tipo) { case Tipos.INTEGER: if (value.isTemp) { generator.addPrint("d", "(int)" + value.getValue()); } else { generator.addPrint("d", value.getValue()); } break; case Tipos.REAL: generator.addPrint("f", value.getValue()); break; case Tipos.BOOLEAN: if (value.vieneDesdeObjeto) { generator.addIf(value.getValue(), "1", "==", value.trueLabel); generator.addGoto(value.falseLabel); } string templabel = generator.newLabel(); generator.addLabel(value.trueLabel); generator.addPrintTrue(); generator.addGoto(templabel); generator.addLabel(value.falseLabel); generator.addPrintFalse(); generator.addLabel(templabel); break; case Tipos.STRING: generator.addNextEnv(ent.getSize()); generator.addSetStack("SP", value.getValue()); generator.addCall("native_print_str"); generator.addAntEnv(ent.getSize()); break; default: throw new Error("Semántico", "Tipo de dato no soportado en un writeln", ent.obtenerAmbito(), linea, columna); } } if (isLine) { generator.addPrint("c", "10"); } } catch (Error ex) { errores.agregarError(ex); } generator.addComment("Finaliza Writeln"); return(null); }
public object compilar(Entorno ent, Errores errores) { try { Generator generator = Generator.getInstance(); Retorno value; if (this.value != null) { value = this.value.compilar(ent); if (!sameType(this.type, value.type)) { throw new Error("Semántico", "Valor no compatible con el tipo de dato", ent.obtenerAmbito(), linea, columna); } } else //LITERAL POR DEFECTO { switch (type.tipo) { case Tipos.INTEGER: Primitivo defecto = new Primitivo(Tipos.INTEGER, "0", linea, columna); value = defecto.compilar(ent); break; case Tipos.REAL: Primitivo defecto1 = new Primitivo(Tipos.REAL, "0.0", linea, columna); value = defecto1.compilar(ent); break; case Tipos.BOOLEAN: Primitivo defecto2 = new Primitivo(Tipos.BOOLEAN, false, linea, columna); value = defecto2.compilar(ent); break; default: //case Tipos.STRING: PrimitivoString defecto3 = new PrimitivoString(Tipos.STRING, "", linea, columna); value = defecto3.compilar(ent); break; } } this.validateType(ent); foreach (string id in idList) { Simbolo newVar = ent.addVar(id, type, false, false, linea, columna); if (newVar.isGlobal) { if (this.type.tipo == Tipos.BOOLEAN) { //Mi modificacion //para cuando viene mas de una variable en la declaracion if (!idList.ElementAt(0).Equals(id)) { value.trueLabel = generator.newLabel(); value.falseLabel = generator.newLabel(); } if (value.getValue().Equals("1")) { generator.addGoto(value.trueLabel); } else { generator.addGoto(value.falseLabel); } string templabel = generator.newLabel(); generator.addLabel(value.trueLabel); generator.addSetStack("" + newVar.position, "1"); generator.addGoto(templabel); generator.addLabel(value.falseLabel); generator.addSetStack("" + newVar.position, "0"); generator.addLabel(templabel); } else { generator.addSetStack("" + newVar.position, value.getValue()); } } else { string temp = generator.newTemporal(); generator.freeTemp(temp); generator.addExpression(temp, "SP", "" + newVar.position, "+"); if (this.type.tipo == Tipos.BOOLEAN) { //Mi modificacion //para cuando viene mas de una variable en la declaracion if (!idList.ElementAt(0).Equals(id)) { value.trueLabel = generator.newLabel(); value.falseLabel = generator.newLabel(); } if (value.getValue().Equals("1")) { generator.addGoto(value.trueLabel); } else { generator.addGoto(value.falseLabel); } string templabel = generator.newLabel(); generator.addLabel(value.trueLabel); generator.addSetStack(temp, "1"); generator.addGoto(templabel); generator.addLabel(value.falseLabel); generator.addSetStack(temp, "0"); generator.addLabel(templabel); } else { generator.addSetStack(temp, value.getValue()); } } } } catch (Error ex) { errores.agregarError(ex); } return(null); }
private void botonAceptar_Click(object sender, EventArgs e) { Errores errores = new Errores(); if (textBox_NombAfi.TextLength == 0) { errores.agregarError("El nombre del afiliado no puede ser nulo"); } if (textBox_ApAfi.TextLength == 0) { errores.agregarError("El apellido del afiliado no puede ser nulo"); } if (textBox_NumDoc.TextLength == 0) { errores.agregarError("El número de documento del afiliado no puede ser nulo"); } if (PlanMedAfi.SelectedItem == null) { errores.agregarError("El plan médico del afiliado no puede ser nulo"); } SqlCommand cuantosHayConDNI = new SqlCommand("ELIMINAR_CAR.verificar_doc_afiliado", DBConnector.ObtenerConexion()); int cantDNI = 0; cuantosHayConDNI.CommandType = CommandType.StoredProcedure; cuantosHayConDNI.Parameters.AddWithValue("@tipo", (int)comboBox_TipoDoc.SelectedItem); cuantosHayConDNI.Parameters.AddWithValue("@dni", Int64.Parse(textBox_NumDoc.Text)); cuantosHayConDNI.Parameters.AddWithValue("@resultado", cantDNI); cuantosHayConDNI.Parameters["@resultado"].Direction = ParameterDirection.Output; cuantosHayConDNI.ExecuteNonQuery(); cantDNI = (int)cuantosHayConDNI.Parameters["@resultado"].Value; if (cantDNI > 0) { errores.agregarError("El tipo y numero de documento ingresado ya existe."); } if (errores.huboError()) { MessageBox.Show(errores.stringErrores(), "Clinica-FRBA: ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else //Coportamiento si esta todo ok { //Insertar Chabon if (tipo == 0) { SqlCommand insertar = new SqlCommand("ELIMINAR_CAR.insertarAfiliadoRaiz", DBConnector.ObtenerConexion()); insertar.CommandType = CommandType.StoredProcedure; insertar.Parameters.Add(new SqlParameter("@tipo_doc", (Int32)comboBox_TipoDoc.SelectedValue)); insertar.Parameters.Add(new SqlParameter("@n_doc", Decimal.Parse(textBox_NumDoc.Text))); insertar.Parameters.Add(new SqlParameter("@nombre", textBox_NombAfi.Text)); insertar.Parameters.Add(new SqlParameter("@apellido", textBox_ApAfi.Text)); insertar.Parameters.Add(new SqlParameter("@direccion", textBox_DirecAfi.Text)); int telefono; if (Int32.TryParse(textBox_TelAfi.Text, out telefono)) { insertar.Parameters.Add(new SqlParameter("@telefono", Int64.Parse(textBox_TelAfi.Text))); } else { insertar.Parameters.Add(new SqlParameter("@telefono", DBNull.Value)); } insertar.Parameters.Add(new SqlParameter("@mail", textBox_MailAfi.Text)); insertar.Parameters.Add(new SqlParameter("@fecha_nac", dtp_fecha_nac.Value)); insertar.Parameters.Add(new SqlParameter("@estado_civil", (Int32)comboBox_EstadoCivilAfi.SelectedItem)); insertar.Parameters.Add(new SqlParameter("@sexo", (Int32)comboBox_SexoAfi.SelectedItem)); insertar.Parameters.Add(new SqlParameter("@id_plan", ((Plan)PlanMedAfi.SelectedItem).id_plan)); int familiares = 0; //Le ponemos 0 a cargo porque no cuenta el conyuge y al agregar los demas se suman // if (Int32.TryParse(textBox_CantFami.Text, out familiares)) ; //else familiares = 0; insertar.Parameters.Add(new SqlParameter("@familiares_a_cargo", familiares)); insertar.Parameters.Add(new SqlParameter("@id_familia_out", numFam)); Int64 id_afiliado = 0; insertar.Parameters.Add(new SqlParameter("@id_afiliado_out", id_afiliado)); insertar.Parameters["@id_familia_out"].Direction = ParameterDirection.Output; insertar.Parameters["@id_afiliado_out"].Direction = ParameterDirection.Output; insertar.ExecuteNonQuery(); numFam = (Int64)insertar.Parameters["@id_familia_out"].Value; id_afiliado = (Int64)insertar.Parameters["@id_afiliado_out"].Value; } else if (tipo == 1 || tipo == 2) { SqlCommand insertar = new SqlCommand("ELIMINAR_CAR.insertarConyuge", DBConnector.ObtenerConexion()); insertar.CommandType = CommandType.StoredProcedure; insertar.Parameters.Add(new SqlParameter("@id_familia", numFam)); insertar.Parameters.Add(new SqlParameter("@tipo_doc", (Int32)comboBox_TipoDoc.SelectedValue)); insertar.Parameters.Add(new SqlParameter("@n_doc", Decimal.Parse(textBox_NumDoc.Text))); insertar.Parameters.Add(new SqlParameter("@nombre", textBox_NombAfi.Text)); insertar.Parameters.Add(new SqlParameter("@apellido", textBox_ApAfi.Text)); insertar.Parameters.Add(new SqlParameter("@direccion", textBox_DirecAfi.Text)); int telefono; if (Int32.TryParse(textBox_TelAfi.Text, out telefono)) { insertar.Parameters.Add(new SqlParameter("@telefono", Int64.Parse(textBox_TelAfi.Text))); } else { insertar.Parameters.Add(new SqlParameter("@telefono", DBNull.Value)); } insertar.Parameters.Add(new SqlParameter("@mail", textBox_MailAfi.Text)); insertar.Parameters.Add(new SqlParameter("@fecha_nac", dtp_fecha_nac.Value)); insertar.Parameters.Add(new SqlParameter("@estado_civil", (Int32)comboBox_EstadoCivilAfi.SelectedItem)); insertar.Parameters.Add(new SqlParameter("@sexo", (Int32)comboBox_SexoAfi.SelectedItem)); insertar.Parameters.Add(new SqlParameter("@id_plan", ((Plan)PlanMedAfi.SelectedItem).id_plan)); Int64 id_afiliado = 0; insertar.Parameters.Add(new SqlParameter("@id_afiliado_out", id_afiliado)); insertar.Parameters["@id_afiliado_out"].Direction = ParameterDirection.Output; insertar.ExecuteNonQuery(); id_afiliado = (Int64)insertar.Parameters["@id_afiliado_out"].Value; } else { SqlCommand insertar = new SqlCommand("ELIMINAR_CAR.insertarDependiente", DBConnector.ObtenerConexion()); insertar.CommandType = CommandType.StoredProcedure; insertar.Parameters.Add(new SqlParameter("@id_familia", numFam)); insertar.Parameters.Add(new SqlParameter("@tipo_doc", (Int32)comboBox_TipoDoc.SelectedValue)); insertar.Parameters.Add(new SqlParameter("@n_doc", Decimal.Parse(textBox_NumDoc.Text))); insertar.Parameters.Add(new SqlParameter("@nombre", textBox_NombAfi.Text)); insertar.Parameters.Add(new SqlParameter("@apellido", textBox_ApAfi.Text)); insertar.Parameters.Add(new SqlParameter("@direccion", textBox_DirecAfi.Text)); int telefono; if (Int32.TryParse(textBox_TelAfi.Text, out telefono)) { insertar.Parameters.Add(new SqlParameter("@telefono", Int64.Parse(textBox_TelAfi.Text))); } else { insertar.Parameters.Add(new SqlParameter("@telefono", DBNull.Value)); } insertar.Parameters.Add(new SqlParameter("@mail", textBox_MailAfi.Text)); insertar.Parameters.Add(new SqlParameter("@fecha_nac", dtp_fecha_nac.Value)); insertar.Parameters.Add(new SqlParameter("@estado_civil", (Int32)comboBox_EstadoCivilAfi.SelectedItem)); insertar.Parameters.Add(new SqlParameter("@sexo", (Int32)comboBox_SexoAfi.SelectedItem)); insertar.Parameters.Add(new SqlParameter("@id_plan", ((Plan)PlanMedAfi.SelectedItem).id_plan)); Int64 id_afiliado = 0; insertar.Parameters.Add(new SqlParameter("@id_afiliado_out", id_afiliado)); insertar.Parameters["@id_afiliado_out"].Direction = ParameterDirection.Output; insertar.ExecuteNonQuery(); id_afiliado = (Int64)insertar.Parameters["@id_afiliado_out"].Value; } MessageBox.Show("El afiliado fue agregado corrrectamente\n", "Clinica-FRBA", MessageBoxButtons.OK); //Casteo a tipo de dato, porque devuelve object if ((tipo == 0) && ((estado_civil)comboBox_EstadoCivilAfi.SelectedItem == estado_civil.Casado)) { DialogResult res = MessageBox.Show("¿Desea agregar a su conyuge?", "Clinica-FRBA", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { NuevoAfiliado conyuge = new NuevoAfiliado(1, numFam); this.Visible = false; conyuge.ShowDialog(); this.Visible = true; } } if ((tipo == 0) && ((estado_civil)comboBox_EstadoCivilAfi.SelectedItem == estado_civil.Concubinato)) { DialogResult res = MessageBox.Show("¿Desea agregar a su conyuge?", "Clinica-FRBA", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { NuevoAfiliado conyuge = new NuevoAfiliado(2, numFam); this.Visible = false; conyuge.ShowDialog(); this.Visible = true; } } if ((tipo == 0) && textBox_CantFami.TextLength > 0 && (int.Parse(textBox_CantFami.Text) > 0)) { int cantFamiliares = int.Parse(textBox_CantFami.Text); for (int i = 0; i < cantFamiliares; i++) { DialogResult resultado = MessageBox.Show("¿Desea agregar un nuevo familiar a cargo?", "Clinica-FRBA", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (resultado == DialogResult.Yes) { NuevoAfiliado familiar = new NuevoAfiliado(3, numFam); this.Visible = false; familiar.ShowDialog(); this.Visible = true; } else { break; } } } this.Close(); } }
public object compilar(Entorno ent, Errores errores) { //CREO MIS UTILIDADES //ASIGNACION INICIAL AsignacionId target = new AsignacionId(id, null, linea, columna); Asignacion asignacionInicial = new Asignacion(target, primero, linea, columna); //ACTUALIZACION DE LA VARIABLE Y CONDICION A EVALUAR Asignacion actualizarVariable; Primitivo valorFAD = new Primitivo(Tipos.INTEGER, "1", linea, columna); Expresion condicion; AccessId left = new AccessId(id, null, linea, columna); if (fad.Equals("to")) { Less menorIgual = new Less(true, left, segundo, linea, columna); condicion = (Expresion)menorIgual; Suma suma = new Suma(left, valorFAD, linea, columna); actualizarVariable = new Asignacion(target, (Expresion)suma, linea, columna); } else //downto { Greater mayorIgual = new Greater(true, left, segundo, linea, columna); condicion = (Expresion)mayorIgual; Resta resta = new Resta(left, valorFAD, linea, columna); actualizarVariable = new Asignacion(target, (Expresion)resta, linea, columna); } //INICIO LA COMPILACION try { Generator generator = Generator.getInstance(); generator.addComment("Inicia FOR"); asignacionInicial.compilar(ent, errores); string lblFor = generator.newLabel(); generator.addLabel(lblFor); Retorno retcondicion = condicion.compilar(ent); if (retcondicion.type.tipo == Tipos.BOOLEAN) { ent.fors.AddLast(new IteFor(true, actualizarVariable)); ent.ybreak.AddLast(retcondicion.falseLabel); ent.ycontinue.AddLast(lblFor); generator.addLabel(retcondicion.trueLabel); foreach (Instruccion sentencia in sentencias) { sentencia.compilar(ent, errores); } actualizarVariable.compilar(ent, errores); generator.addGoto(lblFor); generator.addLabel(retcondicion.falseLabel); ent.fors.RemoveLast(); ent.ybreak.RemoveLast(); ent.ycontinue.RemoveLast(); generator.addComment("Finaliza FOR"); } else { throw new Error("Semántico", "La condicion a evaluar en el for no es de tipo Boolean", ent.obtenerAmbito(), linea, columna); } } catch (Error ex) { errores.agregarError(ex); } return(null); }
public object compilar(Entorno ent, Errores errores) { try { Generator generator = Generator.getInstance(); generator.addComment("Inicia Asignacion"); if (ent.ambito.Equals("FUNCTION")) { SimboloFunction symFunc = ent.actualFunc; if (symFunc != null) { AsignacionId mytarget = (AsignacionId)this.target; if (mytarget.id.ToLower().Equals(symFunc.id.ToLower())) //Es un Return { Return @return = new Return(this.value, linea, columna); @return.isAsignacion = true; return(@return.compilar(ent, errores)); } } } Retorno target = this.target.compilar(ent); Retorno value = this.value.compilar(ent); Simbolo symbol = target.symbol; if (symbol.isConst) { throw new Error("Semántico", "No se puede cambiar el valor de una constante", ent.obtenerAmbito(), linea, columna); } if (!sameType(target.type, value.type)) { throw new Error("Semántico", "No coincide el tipo de dato de la variable con el tipo de valor a asignar", ent.obtenerAmbito(), linea, columna); } if (symbol.isHeap == false) //ES GLOBAL { if (target.type.tipo == Tipos.BOOLEAN) { //Mi modificacion if (value.getValue().Equals("1")) { generator.addGoto(value.trueLabel); } else { generator.addGoto(value.falseLabel); } string templabel = generator.newLabel(); generator.addLabel(value.trueLabel); generator.addSetStack(target.getValue(), "1"); generator.addGoto(templabel); generator.addLabel(value.falseLabel); generator.addSetStack(target.getValue(), "0"); generator.addLabel(templabel); } else { generator.addSetStack(target.getValue(), value.getValue()); } } else if (symbol.isHeap) { if (target.type.tipo == Tipos.BOOLEAN) { //Mi modificacion if (value.getValue().Equals("1")) { generator.addGoto(value.trueLabel); } else { generator.addGoto(value.falseLabel); } string templabel = generator.newLabel(); generator.addLabel(value.trueLabel); generator.addSetHeap(target.getValue(), "1"); generator.addGoto(templabel); generator.addLabel(value.falseLabel); generator.addSetHeap(target.getValue(), "0"); generator.addLabel(templabel); } else { generator.addSetHeap(target.getValue(), value.getValue()); } } generator.addComment("Finaliza Asignacion"); } catch (Error ex) { errores.agregarError(ex); } return(null); }