public int idInfraccion(int idMotivo) { using (SRI con = new SRI()) { INFRACCION objinf = new INFRACCION(); objinf = con.INFRACCION.Where(i => i.ID_DETALLE_INFRACCION == idMotivo).FirstOrDefault(); return((int)objinf.ID_INFRACCION); } }
public int tipoMoneda(int idMotivo) { using (SRI con = new SRI()) { INFRACCION objinf = new INFRACCION(); objinf = con.INFRACCION.Where(i => i.ID_DETALLE_INFRACCION == idMotivo).FirstOrDefault(); return((int)objinf.ID_TIPO_MONEDA); } }
public int crearInfraccion(INFRACCION objinfrac, String descripcion, int tipo) { try { using (SRI con = new SRI()) { if (tipo > 0) { INFRACCION infra = new INFRACCION(); infra = con.INFRACCION.Where(i => i.ID_INFRACCION == tipo).FirstOrDefault(); infra.ID_GRAVEDAD = objinfrac.ID_GRAVEDAD; infra.MONTO = objinfrac.MONTO; infra.ID_TIPO_MONEDA = objinfrac.ID_TIPO_MONEDA; infra.PUNTAJE_GRAV = objinfrac.PUNTAJE_GRAV; con.SaveChanges(); DETALLE_CARACTERISTICA deta = new DETALLE_CARACTERISTICA(); deta = con.DETALLE_CARACTERISTICA.Where(d => d.ID_DETCAR == infra.ID_DETALLE_INFRACCION).FirstOrDefault(); deta.DETALLE_CAR = descripcion; con.SaveChanges(); return(2); } else { DETALLE_CARACTERISTICA objdetalle = new DETALLE_CARACTERISTICA(); objdetalle.DETALLE_CAR = descripcion; objdetalle.ID_CARACTERISTICA = 9; objinfrac.ID_DETALLE_INFRACCION = DaoDetalleCaracteristica.instancia.CrearDetalleCaracteristica(objdetalle); objinfrac.ID_INFRACCION = retornarNuevoId(); con.INFRACCION.AddObject(objinfrac); con.SaveChanges(); return(1); } } } catch (Exception e) { return(0); } }
public int crearInfraccion(INFRACCION objinfra, String descripcion, int tipo) { return(DaoInfraccion.instancia.crearInfraccion(objinfra, descripcion, tipo)); }
protected void btnGuardarAI_Click(object sender, EventArgs e) { int n = 0; if (txtDescrInfraccionAI.Text == "" || txtDescrInfraccionAI.Text == null) { txtDescrInfraccionAI.BorderColor = System.Drawing.Color.Red; txtDescrInfraccionAI.BorderWidth = 1; n = 1; } else { txtDescrInfraccionAI.BorderColor = System.Drawing.Color.LightGray; txtDescrInfraccionAI.BorderWidth = 1; n = 0; } if (txtValorAI.Text == "" || txtValorAI.Text == null) { txtValorAI.BorderColor = System.Drawing.Color.Red; txtValorAI.BorderWidth = 1; n = 1; } else { txtValorAI.BorderColor = System.Drawing.Color.LightGray; txtValorAI.BorderWidth = 1; n = 0; } if (ddlistGravedadAI.SelectedIndex == 0) { ddlistGravedadAI.BorderColor = System.Drawing.Color.Red; n = 1; } else { ddlistGravedadAI.BorderColor = System.Drawing.Color.LightGray; ddlistGravedadAI.BorderWidth = 1; n = 0; } if (ddlistGravedadAI.SelectedIndex == 0) { ddlistTipoMonedaAI.BorderColor = System.Drawing.Color.Red; n = 1; } else { ddlistTipoMonedaAI.BorderColor = System.Drawing.Color.LightGray; ddlistTipoMonedaAI.BorderWidth = 1; n = 0; } if (n == 1) { lblInfoAdI.Visible = true; lblInfoAdI.Text = "Los campos en Rojo son obligatorios"; lblInfoAdI.ForeColor = System.Drawing.Color.Red; } else { INFRACCION objinfra = new INFRACCION(); objinfra.ID_TIPO_MONEDA = Convert.ToInt32(ddlistTipoMonedaAI.SelectedValue); decimal monto = 0; try { monto = Convert.ToDecimal(txtValorAI.Text); objinfra.MONTO = monto; objinfra.ID_GRAVEDAD = Convert.ToInt32(ddlistGravedadAI.SelectedValue); switch (ddlistGravedadAI.SelectedValue) { //21 = GRAVISIMA //22 =GRAVE //23 LEVE case "21": objinfra.PUNTAJE_GRAV = 6; break; case "22": objinfra.PUNTAJE_GRAV = 3; break; case "23": objinfra.PUNTAJE_GRAV = 1; break; } // tipo 1 actualiza int tipo = 0; if (!String.IsNullOrEmpty(TxtID.Text)) { tipo = 1; } else { tipo = 0; } int newInfraccion = NegocioAdministrador.instancia.crearInfraccion(objinfra, txtDescrInfraccionAI.Text, tipo); switch (newInfraccion) { case 1: lblInfoAdI.Visible = true; lblInfoAdI.Text = "Datos guardados"; lblInfoAdI.ForeColor = System.Drawing.Color.Gray; ddlistGravedadAI.SelectedIndex = 0; ddlistTipoMonedaAI.SelectedIndex = 0; txtDescrInfraccionAI.Text = ""; TxtID.Text = String.Empty; txtValorAI.Text = ""; ddlistGravedadAI.Items.Insert(0, new ListItem("Seleccione", "")); ddlistGravedadAI.BorderColor = System.Drawing.Color.LightGray; ddlistTipoMonedaAI.BorderColor = System.Drawing.Color.LightGray; txtValorAI.BorderColor = System.Drawing.Color.LightGray; txtDescrInfraccionAI.BorderColor = System.Drawing.Color.LightGray; gvInfrAI.Visible = false; ddlistGravedadAI.BorderWidth = 1; ddlistTipoMonedaAI.BorderWidth = 1; txtValorAI.BorderWidth = 1; txtDescrInfraccionAI.BorderWidth = 1; btnGuardarAI.Text = "GUARDAR"; break; case 2: lblInfoAdI.Visible = true; lblInfoAdI.Text = "Datos actualizados"; lblInfoAdI.ForeColor = System.Drawing.Color.Gray; gvInfrAI.Visible = false; btnGuardarAI.Text = "GUARDAR"; lblInfoAdI.ForeColor = System.Drawing.Color.Gray; ddlistGravedadAI.SelectedIndex = 0; ddlistTipoMonedaAI.SelectedIndex = 0; txtDescrInfraccionAI.Text = ""; TxtID.Text = String.Empty; txtValorAI.Text = ""; ddlistGravedadAI.Items.Insert(0, new ListItem("Seleccione", "")); ddlistGravedadAI.BorderColor = System.Drawing.Color.LightGray; ddlistTipoMonedaAI.BorderColor = System.Drawing.Color.LightGray; txtValorAI.BorderColor = System.Drawing.Color.LightGray; txtDescrInfraccionAI.BorderColor = System.Drawing.Color.LightGray; gvInfrAI.Visible = false; ddlistGravedadAI.BorderWidth = 1; ddlistTipoMonedaAI.BorderWidth = 1; txtValorAI.BorderWidth = 1; txtDescrInfraccionAI.BorderWidth = 1; btnGuardarAI.Text = "GUARDAR"; break; default: lblInfoAdI.Visible = true; lblInfoAdI.Text = "Datos no guardados"; lblInfoAdI.ForeColor = System.Drawing.Color.Red; break; } } catch (Exception) { lblInfoAdI.Visible = true; lblInfoAdI.Text = "Monto no valido"; lblInfoAdI.ForeColor = System.Drawing.Color.Red; } } }