public void VerificarSiSobrepasaStock() { //Creo lista de Producto List <Producto> pruebaDeProductos = new List <Producto>(); //HardcodeoProductos Instrumentos i1 = new Instrumentos(6, "Teclado Yamaha", 55000, 5, "China", 2007); Instrumentos i2 = new Instrumentos(8, "Bateria Ludwig ", 90000, 5, "EEUU", 1999); Accesorio a1 = new Accesorio(10001, "Puas Fender *24 ", 550, 28, 0, 0); Accesorio a2 = new Accesorio(10005, "Palillos Logan ", 350, 34, (EGama)2, (ETipo)1); Accesorio a3 = new Accesorio(10005, "Palillos Logan ", 350, 34, (EGama)2, (ETipo)1); ///Agrego los diferentes productos a la lista pruebaDeProductos.Add(i1); pruebaDeProductos.Add(i2); pruebaDeProductos.Add(a1); pruebaDeProductos.Add(a2); pruebaDeProductos.Add(a3); try { Venta.VerificarStock(pruebaDeProductos); } catch (SobrepasaStockException e) { Assert.IsInstanceOfType(e, typeof(SobrepasaStockException)); } }
public static void Main(string[] args) { //Creo lista de Producto List <Producto> productos = new List <Producto>(); //HardcodeoProductos Instrumentos i1 = new Instrumentos(2, "Bateria Sonor", 100000, 5, "China", 1999); Instrumentos i2 = new Instrumentos(3, "Bajo Gibson", 50000, 5, "Otro", 2005); Accesorio a1 = new Accesorio(10002, "Correa Guitarra classic ", 550, 5, 0, 0); Accesorio a2 = new Accesorio(10005, "banquillo Yamaha ", 8500, 4, (EGama)2, (ETipo)1); Accesorio a3 = new Accesorio(10005, "banquillo Yamaha ", 8500, 4, (EGama)2, (ETipo)1); ///Agrego los diferentes productos a la lista productos.Add(i1); productos.Add(i2); productos.Add(a1); productos.Add(a2); productos.Add(a3); foreach (Producto producto in productos) { Console.Write(producto); } try { Venta.VerificarStock(productos); Console.Write("Se verifico el stock correctamente \n"); Venta.modificarStock(productos); Console.Write("Se modifico el stock correctamente \n"); Console.Write("Se creo Ticket correctamente."); } catch (SobrepasaStockException e) { Console.Write(e.Message); } catch (Exception e) { Console.Write(e.Message); } Console.ReadLine(); }
public static void saveIntrumento(int id, string nombre, string subtitulo, string prefijo, int estado, int orden, int aplicado) { Repository <Instrumentos> crudIntrumentos = new Repository <Instrumentos>(); try { Instrumentos itemObject = new Instrumentos(); if (id != -1) { itemObject.id = id; } itemObject.nombre = nombre; itemObject.subtitulo = subtitulo; itemObject.prefijo = prefijo; itemObject.estado = estado; itemObject.orden = orden; itemObject.aplicado = aplicado; itemObject.fechaCreacion = DateTime.Now; using (TransactionScope tran = new TransactionScope()) { // Boolean exist = crudIntrumentos.Retrieve(f => f.id == 1) != null; if (id != -1) { Instrumentos data = crudIntrumentos.Retrieve(u => u.id == id); data.nombre = nombre; data.subtitulo = subtitulo; data.prefijo = prefijo; data.estado = estado; data.orden = orden; data.aplicado = aplicado; data.fechaCreacion = DateTime.Now; crudIntrumentos.Update(data); } else { crudIntrumentos.Create(itemObject); } tran.Complete(); } } catch (Exception es) { var exeption = es; } }
public static List <Instrumentos> getInstrumentoId(int id) { //Repository<InstrumentosDynamic> crudIntrumentos = new Repository<InstrumentosDynamic>(); //crudIntrumentos.GetAll(); List <Instrumentos> lista = new List <Instrumentos>(); using (SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["connectionStringClasses"].ToString())) { var stringQuery = "SELECT instrumentos.*,(select * , (select GruposModulos.idGrupoModulo , GruposComunidad.NombreGrupo from GruposModulos inner join GruposComunidad on GruposComunidad.idGrupo=GruposModulos.idGrupo where GruposModulos.idModulo like modulos.id FOR JSON PATH) as grupos from modulos where instrumentos.id=modulos.id_instrumento FOR JSON PATH) as modulos,(select GruposInstrumentos.idGrupoInstrumento , GruposComunidad.NombreGrupo from GruposInstrumentos inner join GruposComunidad on GruposComunidad.idGrupo=GruposInstrumentos.idGrupo where idInstrumento=instrumentos.id FOR JSON PATH) as grupos FROM instrumentos"; SqlCommand command = new SqlCommand(stringQuery + " where instrumentos.id =" + id, conn); try { conn.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Instrumentos item = new Instrumentos(); item.id = Convert.ToInt32(reader[0].ToString()); try { item.nombre = reader["nombre"].ToString(); item.subtitulo = reader["subtitulo"].ToString(); item.prefijo = reader["prefijo"].ToString(); item.estado = Convert.ToInt32(reader["estado"].ToString()); item.orden = Convert.ToInt32(reader["orden"].ToString()); item.aplicado = Convert.ToInt32(reader["aplicado"].ToString()); } catch (Exception exx) { Console.WriteLine(exx.Message); } try { item.fechaCreacion = Convert.ToDateTime(reader["fechaCreacion"].ToString()); } catch (Exception ex) { Console.WriteLine(ex.Message); } item.modulos = reader["modulos"].ToString(); if (item.nombre != "") { lista.Add(item); } } } } catch (Exception ex) { Console.WriteLine(ex.Message); } } return(lista); }
private void pictureBox1_Paint(object sender, PaintEventArgs e) { Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); //Bitmap bmp =new Bitmap(29 * 12+4, 17 * 18); Graphics g = Graphics.FromImage(bmp); Instrumentos ins; try { ins = new Instrumentos(g, new FileCharset(/*me.default_path + "\\" +*/ textBox1.Text)); } catch (Exception) { MemoryStream stream = new MemoryStream(global::UAVConsole.Properties.Resources.Ikarus); ins = new Instrumentos(g, new FileCharset(new StreamReader(stream))); } if (comboBox1.SelectedIndex == 0) { ins.SetPAL(); } else { ins.SetNTSC(); } string cad; //Image fondo = Bitmap.FromFile("C:\\Documents and Settings\\All Users\\Documentos\\Mis imágenes\\Imágenes de muestra\\Puesta de sol.jpg"); Image fondo; try { fondo = Bitmap.FromFile(me.default_path + "\\background.jpg"); } catch (Exception) { fondo = global::UAVConsole.Properties.Resources.background; } g.DrawImage(fondo, 0, 0, pictureBox1.Width, pictureBox1.Height); //g.DrawImage(fondo, 0, 0, bmp.Width, bmp.Height); if (hud.V1_text.tipo != 0) { cad = string.Format("{0,4:0.0}", v1); ins.printAtStr(hud.V1_text.fila, hud.V1_text.col, cad); ins.writeAtChr(hud.V1_text.fila, hud.V1_text.col + cad.Length, 0xEA); //sprintf(cad, "%4.1fv", ikarusInfo.v1); } if (hud.V1_bar.tipo != 0) { ins.Bar(hud.V1_bar.fila, hud.V1_bar.col, hud.V1_bar.param, (int)((v1 / cells_v1 - 3.2f) * 255)); } // Voltage V2 if (hud.V2_text.tipo != 0) { cad = string.Format("{0,4:0.0}", v2); ins.printAtStr(hud.V2_text.fila, hud.V2_text.col, cad); ins.writeAtChr(hud.V2_text.fila, hud.V2_text.col + cad.Length, 0xEB); //sprintf(cad, "%4.1fv", ikarusInfo.v1); } if (hud.V2_bar.tipo != 0) { ins.Bar(hud.V2_bar.fila, hud.V2_bar.col, hud.V2_bar.param, (int)((v2 / cells_v2 - 3.2f) * 255)); } // Intensidad (A) if (hud.I.tipo != 0) { cad = string.Format("{0,5:0.0}", IA); ins.printAtStr(hud.I.fila, hud.I.col, cad); ins.writeAtChr(hud.I.fila, hud.I.col + cad.Length, 0xE9); //sprintf(cad, "%5.1fA", ikarusInfo.currI); } // Consumo (mAh?) if (hud.mAh.tipo == 1) { //sprintf(cad, "%5.0fmAh", ikarusInfo.consumidos_mAh); cad = string.Format("{0,5}mAh", mAh); ins.printAtStr(hud.mAh.fila, hud.mAh.col, cad); } else if (hud.mAh.tipo == 2) { ins.Bar(hud.mAh.fila, hud.mAh.col, hud.mAh.param, (int)((1 - (float)mAh / cap_mAh) * 255)); } // RSSI if (hud.RSSI.tipo != 0) { cad = string.Format("{0,3}", RSSI); ins.printAtStr(hud.RSSI.fila, hud.RSSI.col, cad); ins.writeAtChr(hud.RSSI.fila, hud.RSSI.col + cad.Length, 0xD7); //sprintf(cad, "%3.0f", ikarusInfo.RSSI); } // Autopilot if (hud.Autopilot.tipo != 0) { if (AutoPilot) { cad = "STAB"; } else { cad = " "; } ins.printAtStr(hud.Autopilot.fila, hud.Autopilot.col, cad); } // Nombre destino if (hud.WptName.tipo != 0) { cad = WptName; ins.printAtStr(hud.WptName.fila, hud.WptName.col, cad); } // DISTANCIA a CASA if (hud.Dist_Home.tipo != 0) { cad = string.Format("{0,5}", distancia_casa); ins.printAtStr(hud.Dist_Home.fila, hud.Dist_Home.col, cad); ins.writeAtChr(hud.Dist_Home.fila, hud.Dist_Home.col + cad.Length, 0xE7); } // DISTANCIA a WPT if (hud.Dist_Wpt.tipo != 0) { cad = string.Format("{0,5}", distancia_wpt); ins.printAtStr(hud.Dist_Wpt.fila, hud.Dist_Wpt.col, cad); ins.writeAtChr(hud.Dist_Wpt.fila, hud.Dist_Wpt.col + cad.Length, 0xE8); } // Número satelites if (hud.NumSats.tipo != 0) { if (NumSats >= 0 && NumSats < 20) { cad = string.Format("{0,2}", NumSats); } else { cad = "EE"; } ins.printAtStr(hud.NumSats.fila, hud.NumSats.col, cad); ins.writeAtChr(hud.NumSats.fila, hud.NumSats.col + 2, 0xD8); } if (hud.PosAntena.tipo == 1) { ins.printAtStr(hud.PosAntena.fila, hud.PosAntena.col, "260"); ins.writeAtChr(hud.PosAntena.fila, hud.PosAntena.col + 3, 0xD6); } else if (hud.PosAntena.tipo == 2) { ins.printAtStr(hud.PosAntena.fila, hud.PosAntena.col, "-100"); ins.writeAtChr(hud.PosAntena.fila, hud.PosAntena.col + 4, 0xD6); } if (hud.PosAntenaV.tipo == 1) { ins.printAtStr(hud.PosAntenaV.fila, hud.PosAntenaV.col, " 30"); ins.writeAtChr(hud.PosAntenaV.fila, hud.PosAntenaV.col + 3, 0xD9); } // LON & LAT if (hud.Lon.tipo != 0) { cad = string.Format("Lon:{0,10:0.00000}", lon); ins.printAtStr(hud.Lon.fila, hud.Lon.col, cad); } if (hud.Lat.tipo != 0) { cad = string.Format("Lat:{0,9:0.00000}", lat); ins.printAtStr(hud.Lat.fila, hud.Lat.col, cad); } // BEARING if (hud.Bearing.tipo == 1) { cad = string.Format("{0,4}", bearing); ins.printAtStr(hud.Bearing.fila, hud.Bearing.col, cad); ins.writeAtChr(hud.Bearing.fila, hud.Bearing.col + cad.Length, 0xe5); } else if (hud.Bearing.tipo == 2) { ins.COMPAS_chr(hud.Bearing.fila, hud.Bearing.col, bearing); } else if (hud.Bearing.tipo == 3) { ins.COMPAS_grp(hud.Bearing.fila, hud.Bearing.col, bearing); } else if (hud.Bearing.tipo == 4) { cad = string.Format("{0,3}", 270); ins.printAtStr(hud.Bearing.fila, hud.Bearing.col, cad); ins.writeAtChr(hud.Bearing.fila, hud.Bearing.col + cad.Length, 0xe5); } // DIBUJA ALTIMETRO if (hud.Altimetro.tipo == 1) { //sprintf(cad, "%4.0fm", var); cad = string.Format("{0,4}", altitud); ins.printAtStr(hud.Altimetro.fila, hud.Altimetro.col, cad); ins.writeAtChr(hud.Altimetro.fila, hud.Altimetro.col + cad.Length, 0xe6); } else if (hud.Altimetro.tipo == 2) { // DIBUJA ALTIMETRO FIGHTER ins.Altimetro(hud.Altimetro.fila, hud.Altimetro.col + 4, hud.Altimetro.param, altitud); //sprintf(cad, "%4.0f", var); cad = string.Format("{0,4}", altitud); ins.printAtStr2(hud.Altimetro.fila + hud.Altimetro.param / 2, hud.Altimetro.col, cad, 4); ins.printAtStr(hud.Altimetro.fila + hud.Altimetro.param / 2 + 1, hud.Altimetro.col + 2, "m"); } // DIBUJA VELOCIMETRO if (hud.Velocimetro.tipo == 1) { //sprintf(cad, "%3.0f", gpsinfo.kmph); cad = string.Format("{0,3}", kmph); ins.printAtStr2(hud.Velocimetro.fila, hud.Velocimetro.col, cad, 3); ins.writeAtChr(hud.Velocimetro.fila, hud.Velocimetro.col + 3, 0xE1); } else if (hud.Velocimetro.tipo == 2) { // DIBUJA VELOCIMETRO FIGHTER ins.Velocimetro(hud.Velocimetro.fila, hud.Velocimetro.col, hud.Velocimetro.param, kmph); //sprintf(cad, "%3.0f", gpsinfo.kmph); cad = string.Format("{0,3}", kmph); ins.printAtStr2(hud.Velocimetro.fila + hud.Velocimetro.param / 2, hud.Velocimetro.col + 1, cad, 3); ins.printAtStr(hud.Velocimetro.fila + hud.Velocimetro.param / 2 + 1, hud.Velocimetro.col + 1, "kmh"); } // Compas if (hud.Compas.tipo == 1) { //sprintf(cad, "%3.0f", gpsinfo.rumbo); cad = string.Format("{0,3}", rumbo); ins.printAtStr(hud.Compas.fila, hud.Compas.col, cad); ins.writeAtChr(hud.Compas.fila, hud.Compas.col + 3, 0xe4); } else if (hud.Compas.tipo == 2) { ins.Compas(hud.Compas.fila, hud.Compas.col, hud.Compas.param, rumbo, bearing); } // DIBUJA VARIOMETRO if (hud.Variometro.tipo == 1) { ins.Variometro1(hud.Variometro.fila, hud.Variometro.col, verticalSpeed); } else if (hud.Variometro.tipo == 2) { ins.Variometro2(hud.Variometro.fila, hud.Variometro.param, hud.Variometro.col, verticalSpeed); } if (hud.MaxAlt.tipo != 0) { cad = string.Format("Altitud MAX: {0,5:0.}m", max_alt); ins.printAtStr(hud.MaxAlt.fila, hud.MaxAlt.col, cad); } if (hud.MaxVelo.tipo != 0) { cad = string.Format("Velocidad Max: {0,3:0.}km/h", max_velo); ins.printAtStr(hud.MaxVelo.fila, hud.MaxVelo.col, cad); } if (hud.MaxDist.tipo != 0) { //sprintf(cad, "Distancia Max: %5.0fm", max_dist); cad = string.Format("Distancia Max: {0,5:0.}m", max_dist); ins.printAtStr(hud.MaxDist.fila, hud.MaxDist.col, cad); } if (hud.TotalDist.tipo == 1) { cad = string.Format("{0,5:0.}m", total_dist); ins.printAtStr(hud.TotalDist.fila, hud.TotalDist.col, cad); } else if (hud.TotalDist.tipo == 2) { cad = string.Format("Dist. Recorrida: {0,5:0.}m", total_dist); ins.printAtStr(hud.TotalDist.fila, hud.TotalDist.col, cad); } if (hud.Hora.tipo != 0) { if (hud.Hora.tipo == 1) { ins.printAtStr(hud.Hora.fila, hud.Hora.col, "18:41"); } else { ins.printAtStr(hud.Hora.fila, hud.Hora.col, "18:41:08"); } } if (hud.TiempoVuelo.tipo != 0) { if (hud.TiempoVuelo.tipo == 1) { ins.printAtStr(hud.TiempoVuelo.fila, hud.TiempoVuelo.col, "00:17"); } else if (hud.TiempoVuelo.tipo == 2) { ins.printAtStr(hud.TiempoVuelo.fila, hud.TiempoVuelo.col, "00:17:41"); } else if (hud.TiempoVuelo.tipo == 3) { ins.printAtStr(hud.TiempoVuelo.fila, hud.TiempoVuelo.col, "Tiempo Vuelo: 00:17:41"); } } // tasa de planeo if (hud.TasaPlaneo.tipo != 0) { ins.printAtStr(hud.TasaPlaneo.fila, hud.TasaPlaneo.col, "17:1"); } // consumo km/Ah o m/mAh (es lo mismo) if (hud.Coste_km_Ah.tipo != 0) { ins.printAtStr(hud.Coste_km_Ah.fila, hud.Coste_km_Ah.col, "4.2km/Ah"); } if (hud.HorizonteArtificial.tipo == 1 || hud.HorizonteArtificial.tipo == 2) { ins.HorizonteArtificial(hud.HorizonteArtificial.fila, hud.HorizonteArtificial.col, hud.HorizonteArtificial.param, pitch, roll, hud.HorizonteArtificial.tipo - 1); } if (hud.Auxiliary.tipo == 1) { // ins.printAtStr(hud.Auxiliary.fila, hud.Auxiliary.col, "Debug Info Here"); // ins.printAtStr(hud.Auxiliary.fila+1, hud.Auxiliary.col, "and prob. here too"); sbyte fila = hud.Auxiliary.fila; sbyte col = hud.Auxiliary.col; float bear = 0.0f; int tmp; if ((hud.Auxiliary.param & 2) != 0) { ins.CharAttrBackGr(); } ins.printAtStr(fila++, col, "ALT 1200/2000 PITCH -10/-30"); ins.printAtStr(fila++, col, "HDG -120/-200 ROLL -20/-30"); if ((hud.Auxiliary.param & 1) != 0) { ins.printAtStr(fila++, col, "A 1500 E 1500 M 1200 T 1500"); } else { ins.printAtStr(fila++, col, "A 0.00 E 0.00 M-0.20 T 0.00"); } ins.CharAttrNoBackGr(); } // Nombre piloto if (hud.NombrePiloto.tipo != 0) { ins.printAtStr(hud.NombrePiloto.fila, hud.NombrePiloto.col, "IkarusOSD_plt"); } if (hud.NombreHUD.tipo != 0) { ins.printAtStr2(hud.NombreHUD.fila, hud.NombreHUD.col, hud.StrNombreHUD, 16); } if (hud.BadRX.tipo != 0) { ins.printAtStr(hud.BadRX.fila, hud.BadRX.col, "BAD RX 09"); } e.Graphics.DrawImage(bmp, 0, 0);//, pictureBox1.Width+11, pictureBox1.Height+11); }
public Aluno(Instrumentos instrumento, string nome, string conhecimento) { this.Instrumentos = instrumento; this.Nome = nome; this.conhecimento = conhecimento; }