public int NuevaSolucion(Solucion solucion) { Cn = ObjCn.getConecta(); Cn.Open(); using (SqlTransaction tr = Cn.BeginTransaction(IsolationLevel.Serializable)) { SqlCommand cmd = new SqlCommand("SP_NUEVASOLUCION", Cn, tr); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@IPR", SqlDbType.Int).Value = solucion.ObjProblema.IdProblema; cmd.Parameters.Add("@DES", SqlDbType.VarChar).Value = solucion.Descripcion; try { int n = cmd.ExecuteNonQuery(); tr.Commit(); return(n); } catch (Exception e) { tr.Rollback(); Console.WriteLine(e); throw; } } }
public async Task <IActionResult> Crear([FromBody] CrearViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Solucion solucion = new Solucion { descripcioniddescripcion = model.iddescripcion, tipofallaidtipofalla = model.idtipofalla, catfallaidcatfalla = model.idcatfalla, causafallaidcausafalla = model.idcausafalla, tiposolidtiposol = model.idtiposol, nomsolucion = model.solucion }; _context.Soluciones.Add(solucion); try { await _context.SaveChangesAsync(); } catch (Exception ex) { return(BadRequest()); } return(Ok()); }
public void Modificar(Solucion solucion, string Conexion, ref int verificador) { try { CapaDatos.CD_Datos CapaDatos = new CapaDatos.CD_Datos(Conexion); string[] Parametros = { "@Id_Emp", "@Id_Sol", "@Id_Area", "@Sol_Descripcion", "@Sol_Potencial", "@Estatus" }; object[] Valores = { solucion.Id_Emp, solucion.Id_Sol, solucion.Id_Area, solucion.Sol_Descripcion, solucion.Sol_Potencial, solucion.Estatus }; SqlCommand sqlcmd = CapaDatos.GenerarSqlCommand("spCatSolucion_Modificar", ref verificador, Parametros, Valores); CapaDatos.LimpiarSqlcommand(ref sqlcmd); } catch (Exception ex) { throw ex; } }
private void Guardar() { try { Solucion solucion = new Solucion(); solucion.Id_Sol = Convert.ToInt32(txtClave.Text); solucion.Id_Area = Convert.ToInt32(cmbArea.SelectedValue); solucion.Sol_Descripcion = txtDescripcion.Text; solucion.Id_Emp = session.Id_Emp; solucion.Sol_Potencial = txtPotencial.Value.Value; solucion.Estatus = chkActivo.Checked; CN_CatSolucion clsCatSolucion = new CN_CatSolucion(); int verificador = -1; if (HF_ID.Value == "") { if (!_PermisoGuardar) { Alerta("No tiene permisos para grabar"); return; } clsCatSolucion.Insertar(solucion, session.Emp_Cnx, ref verificador); if (verificador == 1) { Nuevo(); Alerta("Los datos se guardaron correctamente"); } else { Alerta("La clave ya existe"); } } else { if (!_PermisoModificar) { Alerta("No tiene permisos para modificar"); return; } clsCatSolucion.Modificar(solucion, session.Emp_Cnx, ref verificador); if (verificador == 1) { Alerta("Los datos se modificaron correctamente"); } else { Alerta("Ocurrió un error al intentar modificar los datos"); } } rg1.Rebind(); } catch (Exception ex) { throw ex; } }
public void Modificar(Solucion area, string Conexion, ref int verificador) { try { CD_CatSolucion claseCapaDatos = new CD_CatSolucion(); claseCapaDatos.Modificar(area, Conexion, ref verificador); } catch (Exception ex) { throw ex; } }
public void Lista(Solucion area, string Conexion, ref List <Solucion> List) { try { CD_CatSolucion claseCapaDatos = new CD_CatSolucion(); claseCapaDatos.Lista(area, Conexion, ref List); } catch (Exception ex) { throw ex; } }
public override double evaluarDensidad(Solucion s) { int i = 0; double total = 0.0; foreach (Elemento elemento in elementos) { if (s.vector[i] == 1) { total += elemento.getDensidad(); } i++; } return(total); }
public ActionResult AddSolucion(AddSolucionViewModel model) { using (var db = new Sistema_TicketsEntities()) { var osolucion = db.Solucion.Find(TicketsVarViemModel.idTickets); if (osolucion.ID_Ticket == TicketsVarViemModel.idTickets) { return(Content("2")); } Solucion oSolucion = new Solucion(); oSolucion.Descripcion_en_Pasos = model.Descripcion; oSolucion.Fecha_Solucion = model.fecha; oSolucion.ID_Ticket = TicketsVarViemModel.idTickets; oSolucion.ID_Estratei = UserSession.iduser; try { db.Solucion.Add(oSolucion); db.SaveChanges(); } catch (Exception ex) { return(Content("nooo" + ex.InnerException)); } } using (var db = new Sistema_TicketsEntities()) { Historial_Ticket ohistorial_ticket = new Historial_Ticket(); ohistorial_ticket.Accion_Realizada = "Se agrego solución"; ohistorial_ticket.ID_Estado = 3; ohistorial_ticket.Fecha_Hora_Modificacion = DateTime.Now; ohistorial_ticket.ID_Estratei = UserSession.iduser; ohistorial_ticket.ID_Ticket = TicketsVarViemModel.idTickets; db.Historial_Ticket.Add(ohistorial_ticket); db.SaveChanges(); var oticket = db.Ticket.Find(TicketsVarViemModel.idTickets); oticket.ID_Estado = 3; oticket.Fecha_Hora_Fin = DateTime.Now; db.Entry(oticket).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(Content("1")); }
private List <Solucion> GetList() { try { List <Solucion> List = new List <Solucion>(); CN_CatSolucion clsCatSolucion = new CN_CatSolucion(); Solucion solucion = new Solucion(); solucion.Id_Emp = session.Id_Emp; clsCatSolucion.Lista(solucion, session.Emp_Cnx, ref List); return(List); } catch (Exception ex) { throw ex; } }
/// <summary> /// Ejecuta el algoritmo de Divide y vencerás /// </summary> /// <param name="p"></param> /// <returns></returns> public Solucion DyV(Problema p) { if (this.esCasoBase(p)) { return(this.resuelveCasoBase(p)); } else { Problema[] subproblemas = this.Divide(p); Solucion[] subsoluciones = new Solucion[subproblemas.Length]; for (int i = 0; i < subproblemas.Length; i++) { subsoluciones[i] = this.DyV(subproblemas[i]); } return(this.Combina(subsoluciones)); } }
private void btnGuardar_Click(object sender, EventArgs e) { if (ObjProb.IdProblema != -1) { try { Solucion Obj = new Solucion(); Obj.Descripcion = txtDescripcion.Text; Obj.ObjProblema = ObjProb; int i = solucionNE.CrearSolucion(Obj); MessageBox.Show("Registro OK"); this.Close(); } catch (Exception exception) { MessageBox.Show("Ocurrio un error " + exception.Message); } } }
public void Lista(Solucion solucion, string Conexion, ref List <Solucion> List) { try { SqlDataReader dr = null; CapaDatos.CD_Datos CapaDatos = new CapaDatos.CD_Datos(Conexion); string[] Parametros = { "@Id_Emp" }; object[] Valores = { solucion.Id_Emp }; SqlCommand sqlcmd = CapaDatos.GenerarSqlCommand("spCatSolucion_Lista", ref dr, Parametros, Valores); while (dr.Read()) { solucion = new Solucion(); solucion.Id_Sol = (int)dr.GetValue(dr.GetOrdinal("Id_Sol")); solucion.Id_Area = (int)dr.GetValue(dr.GetOrdinal("Id_Area")); solucion.Sol_Descripcion = (string)dr.GetValue(dr.GetOrdinal("Sol_Descripcion")); solucion.Id_Seg = (int)dr.GetValue(dr.GetOrdinal("Id_Seg")); solucion.Id_Uen = (int)dr.GetValue(dr.GetOrdinal("Id_Uen")); solucion.Sol_Potencial = Convert.ToDouble(dr.GetValue(dr.GetOrdinal("Sol_Potencial"))); solucion.Estatus = Convert.ToBoolean(dr.GetValue(dr.GetOrdinal("Sol_Activo"))); if (Convert.ToBoolean(solucion.Estatus)) { solucion.EstatusStr = "Activo"; } else { solucion.EstatusStr = "Inactivo"; } List.Add(solucion); } CapaDatos.LimpiarSqlcommand(ref sqlcmd); } catch (Exception ex) { throw ex; } }
/// <summary> /// Verifica los permisos para hacer cambios en el segmento y tipo de incidencia /// en caso que no tengan permiso no se muestran los campos /// </summary> protected void VerifyEditSegmentType() { try { Solucion resp = new Solucion(); string valueParam = string.Empty; valueParam = resp.GetParam("EDITAR_SEGM_OP"); //lblMessage.Text = lblMessage.Text + " ::::: Valor Parámetro: " + valueParam; if (valueParam == "1") { // lblMessage.Text = lblMessage.Text + " Pasó por el Parámetro "; if (hdfEdit.Value.ToString().ToUpper().Equals("EDITAR_SEGM")) { // lblMessage.Text = lblMessage.Text + " :::: Pasó por hdfEdit "; if (hdfEditRol.Value.ToString().ToUpper().Equals("TRUE")) { //lblMessage.Text = lblMessage.Text + " ::: Pasó por hdfEditRol "; applyVisible(true); } else { applyVisible(false); } } else { applyVisible(false); } } else { applyVisible(false); } } catch { } }
static void Main(string[] args) { /* PARA GENERAR LOS REPORTES... * Archivo datos, reporte_mbpso2, reporte_mbpso1; * //int opc = -1; * for (int i = 4; i < 5; i++) * { * try * { * Random r2, r1; * datos = new Archivo("knapsack" + (i + 1) + ".txt", 0); * double[] config = datos.configuracion(); * * int semilla1, semilla2, s = (new Random(100)).Next(0,1001); * * r1 = new Random(s); * semilla1 = 560; * r2 = new Random(s); * semilla2 = 560 * int swarmSize, dimensiones, ni_mbpso2, opcionArreglo, ni_mbpso1, * velocidadMaxima, numIteracionesBL; * double peso, factorMejorLocal, factorMejorGlobal; * FuncionObjetivo fx; * Elemento[] elem; * dimensiones = (int)config[0]; * peso = config[1]; * elem = datos.getElementos(); * ni_mbpso2 = 100; * ni_mbpso1 = 100; * opcionArreglo = 1; * factorMejorGlobal = 2.0; * factorMejorLocal = 2.0; * velocidadMaxima = 4; * swarmSize = 50; * numIteracionesBL = 100; * fx = new FuncionMochila(elem); * fx.maximizar(); * reporte_mbpso2 = new Archivo("reporte_knapsack" + (i + 1) + "_2.txt", 1); * for (int j = 0; j < 30; j++) * { * semilla2++; * r2 = new Random(semilla2); * long tiempoIi = Environment.TickCount; * MBPSO_II algoritmo = new MBPSO_II(r2); * algoritmo.inicializar(swarmSize, dimensiones, fx, ni_mbpso2, peso, opcionArreglo, factorMejorLocal, factorMejorGlobal, velocidadMaxima, numIteracionesBL); * Solucion optimizado = algoritmo.ejecutarBusquedaLocal(algoritmo.ejecutar()); * long tiempoEf = Environment.TickCount; * string resultado2 = optimizado.getPeso() + " " + optimizado.getValor() + " " + (tiempoEf - tiempoIi) + " " + semilla2; * reporte_mbpso2.agregarLinea(resultado2); * } * reporte_mbpso2.close(); * Console.WriteLine("reporte_knapsack" + (i + 1) + "_2.txt"); * reporte_mbpso1 = new Archivo("reporte_knapsack" + (i + 1) + "_1.txt", 1); * for (int j = 0; j < 30; j++) * { * semilla1++; * r1 = new Random(semilla1); * long tiempoIi = Environment.TickCount; * ModifiedBinaryParticleSwarmOptimization alg = new ModifiedBinaryParticleSwarmOptimization(r1); * alg.inicializar(swarmSize, dimensiones, fx, ni_mbpso1, peso, opcionArreglo, factorMejorLocal, factorMejorGlobal, velocidadMaxima); * Solucion optimizado = alg.ejecutar(); * long tiempoEf = Environment.TickCount; * string resultado1 = optimizado.getPeso() + " " + optimizado.getValor() + " " + (tiempoEf - tiempoIi) + " " + semilla1; * reporte_mbpso1.agregarLinea(resultado1); * } * reporte_mbpso1.close(); * Console.WriteLine("reporte_knapsack" + (i + 1) + "_1.txt"); * datos.close(); * } * catch (Exception e) { Console.WriteLine("Error: " + e.Message + "\n" + e.StackTrace); Console.ReadLine(); } * } * } * } * }*/ Archivo datos; int opc = -1; datos = new Archivo("knapsack6.txt", 0); double[] config = datos.configuracion(); do { try { int swarmSize, dimensiones, numIteraciones, semilla, opcionArreglo, velocidadMaxima, numIteracionesBL; double peso, factorMejorLocal, factorMejorGlobal; FuncionObjetivo fx; Elemento[] elem; Random r; dimensiones = (int)config[0]; peso = config[1]; elem = datos.getElementos(); //Parametros a afinar semilla = 789;//(new Random()).Next(1, 1001); numIteraciones = 100; opcionArreglo = 1; //Parametros MBPSO factorMejorGlobal = 0.3; factorMejorLocal = 1.0 - factorMejorGlobal; velocidadMaxima = 4; swarmSize = 20; // un número alto permitirá mejor exploración del espacio de busqueda // pero aumenta el tiempo de ejecucion. //Parametros busqueda local numIteracionesBL = 500; if (semilla == -1) { r = new Random(); } else { r = new Random(semilla); } fx = new FuncionMochila(elem); //maximizar o minimizar fx.maximizar(); Console.WriteLine("Elementos Disponibles: " + elem.Length + " Peso máximo: " + peso + "\nNúmero iteraciones: " + numIteraciones + " Semilla: " + semilla); Console.WriteLine("inicializando..."); Console.WriteLine("Tamaño del Enjambre: " + swarmSize); long tiempoInicial = Environment.TickCount; MBPSO_II algoritmo = new MBPSO_II(r); algoritmo.inicializar(swarmSize, dimensiones, fx, numIteraciones, peso, opcionArreglo, factorMejorLocal, factorMejorGlobal, velocidadMaxima, numIteracionesBL); Solucion mejor = algoritmo.ejecutar(); long tiempoFinal = Environment.TickCount; Console.WriteLine("Peso máximo: " + peso); Console.WriteLine("Tiempo ejecución: " + (tiempoFinal - tiempoInicial) + " ms"); Console.WriteLine("Mejor Solución"); mejor.mostrar(); //Solucion optimizado = algoritmo.ejecutarBusquedaLocal(mejor); //Console.WriteLine("Mejor Solución Optimizado"); //optimizado.mostrar(); } catch (Exception e) { Console.WriteLine("Error: " + e.Message + "\n" + e.StackTrace); } Console.Write("Presiona 0 para salir...\nOtra tecla para volver a ejecutar..."); try { opc = Int32.Parse(Console.ReadKey(false).KeyChar.ToString()); } catch (Exception e) { } Console.Clear(); } while (opc != 0); datos.close(); }
public int CrearSolucion(Solucion solucion) { return(solucionDAO.NuevaSolucion(solucion)); }
void AnalizaDatos() { cfg = ikarus.ReadConfigAutopilot(); int numCanales; ConErrores = false; textBox1.Text = ""; cfg.tipo_mezcla = (byte)Singleton.Mezclas.Normal; // Motor numCanales = canales[(int)Mandos.THR].getNumCanales(); if (numCanales != 1) { ConErrores = true; textBox1.Text += "El motor no puede tener " + numCanales + " canales" + Environment.NewLine; } else { cfg.thr_ch = (byte)(canales[(int)Mandos.THR].getCanales()[0]); cfg.servo_thr.reverse = (byte)((canales[(int)Mandos.THR].getReverses()[0]) ? 1 : 0); textBox1.Text += "Rev THR " + canales[(int)Mandos.THR].getReverses()[0] + Environment.NewLine; } // Alerones numCanales = canales[(int)Mandos.AIL].getNumCanales(); if (numCanales == 1) { cfg.ail_ch = (byte)(canales[(int)Mandos.AIL].getCanales()[0]); cfg.servo_ail.reverse = (byte)((canales[(int)Mandos.AIL].getReverses()[0]) ? 1 : 0); textBox1.Text += "Rev AIL " + canales[(int)Mandos.AIL].getReverses()[0] + Environment.NewLine; } else if (numCanales != 2) { ConErrores = true; textBox1.Text += "El motor no puede tener " + numCanales + " canales" + Environment.NewLine; } else if (canales[(int)Mandos.AIL].Compare(canales[(int)Mandos.ELE])) // Elevon { cfg.ail_ch = (byte)(canales[(int)Mandos.AIL].getCanales()[0]); cfg.ele_ch = (byte)(canales[(int)Mandos.AIL].getCanales()[1]); cfg.tipo_mezcla = (byte)Singleton.Mezclas.Elevon; Solucion sol = new Solucion(canales[(int)Mandos.AIL], canales[(int)Mandos.ELE]); cfg.rev_mezcla = (byte)(sol.rev_mix ? 1 : 0); cfg.servo_ail.reverse = (byte)(sol.rev_out1 ? 1 : 0); cfg.servo_ele.reverse = (byte)(sol.rev_out2 ? 1 : 0); textBox1.Text += "Elevon:" + Environment.NewLine; textBox1.Text += "REV Mix" + sol.rev_mix + Environment.NewLine; textBox1.Text += "REV Ail" + sol.rev_out1 + Environment.NewLine; textBox1.Text += "REV Ele" + sol.rev_out2 + Environment.NewLine; } else // Es flaperon { cfg.ail_ch = (byte)(canales[(int)Mandos.AIL].getCanales()[0]); cfg.servo_ail.reverse = (byte)((canales[(int)Mandos.AIL].getReverses()[0]) ? 1 : 0); cfg.aux_ch = (byte)(canales[(int)Mandos.AIL].getCanales()[1]); cfg.servo_aux.reverse = (byte)((canales[(int)Mandos.AIL].getReverses()[1]) ? 1 : 0); cfg.CanalAuxMode = (byte)(Singleton.ModoCanalAux.AIL2); textBox1.Text += "Flaperones" + Environment.NewLine; textBox1.Text += "Rev AIL " + canales[(int)Mandos.AIL].getReverses()[0] + Environment.NewLine; textBox1.Text += "Rev AUX " + canales[(int)Mandos.AIL].getReverses()[1] + Environment.NewLine; } // Elevador numCanales = canales[(int)Mandos.ELE].getNumCanales(); if (numCanales == 1) { cfg.ele_ch = (byte)(canales[(int)Mandos.ELE].getCanales()[0]); cfg.servo_ele.reverse = (byte)((canales[(int)Mandos.ELE].getReverses()[0]) ? 1 : 0); textBox1.Text += "Rev ELE " + canales[(int)Mandos.ELE].getReverses()[0] + Environment.NewLine; } else if (numCanales != 2) { ConErrores = true; textBox1.Text += "El elevador no puede tener " + numCanales + " canales" + Environment.NewLine; } else if (canales[(int)Mandos.ELE].Compare(canales[(int)Mandos.TAIL])) // Es V-Tail { cfg.ele_ch = (byte)(canales[(int)Mandos.ELE].getCanales()[0]); cfg.tail_ch = (byte)(canales[(int)Mandos.ELE].getCanales()[1]); cfg.tipo_mezcla = (byte)Singleton.Mezclas.V_Tail; Solucion sol = new Solucion(canales[(int)Mandos.ELE], canales[(int)Mandos.TAIL]); cfg.rev_mezcla = (byte)(sol.rev_mix ? 1 : 0); cfg.servo_ele.reverse = (byte)(sol.rev_out1 ? 1 : 0); cfg.servo_tail.reverse = (byte)(sol.rev_out2 ? 1 : 0); textBox1.Text += "Elevon:" + Environment.NewLine; textBox1.Text += "REV Mix" + sol.rev_mix + Environment.NewLine; textBox1.Text += "REV Ele" + sol.rev_out1 + Environment.NewLine; textBox1.Text += "REV Tail" + sol.rev_out2 + Environment.NewLine; } else if (!canales[(int)Mandos.AIL].Compare(canales[(int)Mandos.ELE])) // No es Elevon { ConErrores = true; textBox1.Text += "Mezcla Elevador no reconocida" + Environment.NewLine; } // Cola numCanales = canales[(int)Mandos.TAIL].getNumCanales(); if (numCanales == 1) { cfg.tail_ch = (byte)(canales[(int)Mandos.TAIL].getCanales()[0]); cfg.servo_tail.reverse = (byte)((canales[(int)Mandos.TAIL].getReverses()[0]) ? 1 : 0); textBox1.Text += "Rev TAIL " + canales[(int)Mandos.TAIL].getReverses()[0] + Environment.NewLine; } else if (numCanales != 2) { ConErrores = true; textBox1.Text += "La Cola no puede tener " + numCanales + " canales" + Environment.NewLine; } else if (!canales[(int)Mandos.ELE].Compare(canales[(int)Mandos.TAIL])) // Si no es V-Tail { ConErrores = true; textBox1.Text += "Mezcla Cola no reconocida" + Environment.NewLine; } if (!ConErrores) { textBox1.Text += "OK" + Environment.NewLine; } else { textBox1.Text += "Errores!" + Environment.NewLine; } }
void AnalizaDatos() { cfg = ikarus.ReadConfigAutopilot(); int numCanales; ConErrores = false; textBox1.Text = ""; cfg.tipo_mezcla = (byte)Singleton.Mezclas.Normal; // Motor numCanales =canales[(int)Mandos.THR].getNumCanales(); if (numCanales != 1) { ConErrores = true; textBox1.Text += "El motor no puede tener "+numCanales+" canales"+Environment.NewLine; } else { cfg.thr_ch = (byte)(canales[(int)Mandos.THR].getCanales()[0]); cfg.servo_thr.reverse = (byte)((canales[(int)Mandos.THR].getReverses()[0]) ? 1 : 0); textBox1.Text += "Rev THR " + canales[(int)Mandos.THR].getReverses()[0] + Environment.NewLine; } // Alerones numCanales = canales[(int)Mandos.AIL].getNumCanales(); if (numCanales == 1) { cfg.ail_ch = (byte)(canales[(int)Mandos.AIL].getCanales()[0]); cfg.servo_ail.reverse = (byte)((canales[(int)Mandos.AIL].getReverses()[0]) ? 1 : 0); textBox1.Text += "Rev AIL " + canales[(int)Mandos.AIL].getReverses()[0] + Environment.NewLine; } else if (numCanales != 2) { ConErrores = true; textBox1.Text += "El motor no puede tener " + numCanales + " canales"+Environment.NewLine; } else if (canales[(int)Mandos.AIL].Compare(canales[(int)Mandos.ELE])) // Elevon { cfg.ail_ch = (byte)(canales[(int)Mandos.AIL].getCanales()[0]); cfg.ele_ch = (byte)(canales[(int)Mandos.AIL].getCanales()[1]); cfg.tipo_mezcla = (byte)Singleton.Mezclas.Elevon; Solucion sol = new Solucion(canales[(int)Mandos.AIL], canales[(int)Mandos.ELE]); cfg.rev_mezcla = (byte)(sol.rev_mix ? 1 : 0); cfg.servo_ail.reverse = (byte)(sol.rev_out1 ? 1 : 0); cfg.servo_ele.reverse = (byte)(sol.rev_out2 ? 1 : 0); textBox1.Text += "Elevon:"+Environment.NewLine; textBox1.Text += "REV Mix" + sol.rev_mix+Environment.NewLine; textBox1.Text += "REV Ail" + sol.rev_out1 + Environment.NewLine; textBox1.Text += "REV Ele" + sol.rev_out2 + Environment.NewLine; } else // Es flaperon { cfg.ail_ch = (byte)(canales[(int)Mandos.AIL].getCanales()[0]); cfg.servo_ail.reverse = (byte)((canales[(int)Mandos.AIL].getReverses()[0]) ? 1 : 0); cfg.aux_ch = (byte)(canales[(int)Mandos.AIL].getCanales()[1]); cfg.servo_aux.reverse = (byte)((canales[(int)Mandos.AIL].getReverses()[1]) ? 1 : 0); cfg.CanalAuxMode = (byte)(Singleton.ModoCanalAux.AIL2); textBox1.Text += "Flaperones"+Environment.NewLine; textBox1.Text += "Rev AIL " + canales[(int)Mandos.AIL].getReverses()[0] + Environment.NewLine; textBox1.Text += "Rev AUX " + canales[(int)Mandos.AIL].getReverses()[1] + Environment.NewLine; } // Elevador numCanales = canales[(int)Mandos.ELE].getNumCanales(); if (numCanales == 1) { cfg.ele_ch = (byte)(canales[(int)Mandos.ELE].getCanales()[0]); cfg.servo_ele.reverse = (byte)((canales[(int)Mandos.ELE].getReverses()[0]) ? 1 : 0); textBox1.Text += "Rev ELE " + canales[(int)Mandos.ELE].getReverses()[0] + Environment.NewLine; } else if (numCanales != 2) { ConErrores = true; textBox1.Text += "El elevador no puede tener " + numCanales + " canales"+Environment.NewLine; } else if (canales[(int)Mandos.ELE].Compare(canales[(int)Mandos.TAIL])) // Es V-Tail { cfg.ele_ch = (byte)(canales[(int)Mandos.ELE].getCanales()[0]); cfg.tail_ch = (byte)(canales[(int)Mandos.ELE].getCanales()[1]); cfg.tipo_mezcla = (byte)Singleton.Mezclas.V_Tail; Solucion sol = new Solucion(canales[(int)Mandos.ELE], canales[(int)Mandos.TAIL]); cfg.rev_mezcla = (byte)(sol.rev_mix ? 1 : 0); cfg.servo_ele.reverse = (byte)(sol.rev_out1 ? 1 : 0); cfg.servo_tail.reverse = (byte)(sol.rev_out2 ? 1 : 0); textBox1.Text += "Elevon:" + Environment.NewLine; textBox1.Text += "REV Mix" + sol.rev_mix + Environment.NewLine; textBox1.Text += "REV Ele" + sol.rev_out1 + Environment.NewLine; textBox1.Text += "REV Tail" + sol.rev_out2 + Environment.NewLine; } else if (!canales[(int)Mandos.AIL].Compare(canales[(int)Mandos.ELE])) // No es Elevon { ConErrores = true; textBox1.Text += "Mezcla Elevador no reconocida"+Environment.NewLine; } // Cola numCanales = canales[(int)Mandos.TAIL].getNumCanales(); if (numCanales == 1) { cfg.tail_ch = (byte)(canales[(int)Mandos.TAIL].getCanales()[0]); cfg.servo_tail.reverse = (byte)((canales[(int)Mandos.TAIL].getReverses()[0]) ? 1 : 0); textBox1.Text += "Rev TAIL " + canales[(int)Mandos.TAIL].getReverses()[0] + Environment.NewLine; } else if (numCanales != 2) { ConErrores = true; textBox1.Text += "La Cola no puede tener " + numCanales + " canales"+Environment.NewLine; } else if (!canales[(int)Mandos.ELE].Compare(canales[(int)Mandos.TAIL])) // Si no es V-Tail { ConErrores = true; textBox1.Text += "Mezcla Cola no reconocida"+Environment.NewLine; } if (!ConErrores) { textBox1.Text += "OK"+Environment.NewLine; } else { textBox1.Text += "Errores!"+Environment.NewLine; } }
protected void txtIncident_TextChanged(object sender, EventArgs e) { try { Int16 l_noincident = Convert.ToInt16(((TextBox)sender).Text.Split('-')[0]); Solucion result = new Solucion(); Segment resp = new Segment(); Level resultLevel = new Level(); DataTable myResult = new DataTable(); String seqLevelT = string.Empty; decimal codSegm = 0; decimal codType = 0; dsIncidentNotification.IN_CAT_MOTIVESDataTable dtMotives = new dsIncidentNotification.IN_CAT_MOTIVESDataTable(); dsIncidentNotificationTableAdapters.IN_CAT_MOTIVESTableAdapter taMotives = new dsIncidentNotificationTableAdapters.IN_CAT_MOTIVESTableAdapter(); taMotives.FillByIncidence(dtMotives, l_noincident); hidIncidentNumber.Value = l_noincident.ToString(); if (dtMotives.Rows.Count > 0) { trState.Visible = true; trSegment.Visible = true; trType.Visible = true; //trStatus.Visible = true; //Se obtiene los valores, código segmento, código tipo y país. myResult = result.GetSegmentType(decimal.Parse(hidIncidentNumber.Value)); if (myResult != null) { //se guardan en variables hdfCountry.Value = myResult.Rows[0]["IN_COUNTRY_PK"].ToString(); codSegm = decimal.Parse(myResult.Rows[0]["COD_SEGMENT"].ToString()); codType = decimal.Parse(myResult.Rows[0]["COD_TYPE"].ToString()); //Se obtienene solamente los segmentos según el país de la incidencia resp.GetSegmentsByCountryAct(decimal.Parse(hdfCountry.Value)); //Se llena el combo de segmentos ddlSegment.DataSource = resp.SegmentsTable.Select("RECORD_STATUS = 1");; ddlSegment.DataValueField = resp.SegmentsTable.COD_SEGMENTColumn.ColumnName; ddlSegment.DataTextField = resp.SegmentsTable.SEGMENT_NAMEColumn.ColumnName; //Se le asigna el valor del segmento al combo ddlSegment.SelectedValue = codSegm.ToString(); ddlSegment_SelectedIndexChanged(null, null); //Se cargan los tipos según el segmento seleccionado try { ddlType.SelectedValue = codType.ToString(); //Se asigna el valor del tipo } catch { } if (String.IsNullOrEmpty(ddlType.SelectedValue.ToString())) { codLevelChg = resultLevel.GetCodLevelType(decimal.Parse(ddlType.SelectedValue)).ToString(); } else { codLevelChg = "0"; } } //Verificar si están todas las configuraciones para mostrar los datos de Segmento y Tipo VerifyEditSegmentType(); lblState.Text = dtMotives.Rows[0][1].ToString(); populateGridComments(l_noincident); if (lblState.Text.Trim().Contains("FIN")) { txtComment.Enabled = false; sendButton.Enabled = false; ddlSegment.Enabled = false; ddlType.Enabled = false; //trStatus.Visible = false; } else { txtComment.Enabled = true; sendButton.Enabled = true; ddlSegment.Enabled = true; ddlType.Enabled = true; // trStatus.Visible = true; } } else { trState.Visible = false; } } catch (Exception ex) { } }