public static void SalvarInstrumento(Instrumento ins) { List <object> param = new List <object>(); param = ins.GetList(false); string sql = "INSERT INTO instrumento " + "(nome, tipo)" + "VALUES ("; for (int i = 0; i < param.Count(); i++) { sql += "@" + (i + 1); if (i < param.Count() - 1) { sql += ", "; } } sql += ");"; Connection.Open(); Connection.Run(sql, param); Connection.Close(); }
public List <Instrumento> listadeinstrumentos() { con.ConnectionString = @"Data Source=BLACKHORDENOT;Initial Catalog=casademusica;Integrated Security=True"; string consultasql = @"select * from instrumentos"; con.Open(); cmd = new SqlCommand(consultasql, con); dr = cmd.ExecuteReader(); List <Instrumento> lista = new List <Instrumento>(); while (dr.Read()) { Instrumento i = new Instrumento(); i.Idinstrumento = int.Parse(dr["idInstrumento"].ToString()); i.Nombre = dr["nombre"].ToString(); i.Descripcion = dr["descripcion"].ToString(); i.Stock = int.Parse(dr["stock"].ToString()); i.Precio = double.Parse(dr["precio"].ToString()); i.Idtipo = int.Parse(dr["idTipo"].ToString()); lista.Add(i); } dr.Close(); con.Close(); return(lista); }
public static long SalvarInstrumentoId(Instrumento ins) { List <object> param = new List <object>(); param = ins.GetList(false); string sql = "INSERT INTO instrumento " + "(nome, tipo)" + "VALUES ("; for (int i = 0; i < param.Count(); i++) { sql += "@" + (i + 1); if (i < param.Count() - 1) { sql += ", "; } } sql += ") RETURNING id_instrumento;"; Connection.Open(); NpgsqlDataReader dr = Connection.Select(sql, param); dr.Read(); long id = dr.GetInt64(0); Connection.Close(); return(id); }
void atualizaCampos() { long id_instrumento = 0; string ins_sel = cmbInstrumento.Text; int strindex = ins_sel.IndexOf(" - "); id_instrumento = Convert.ToInt64(ins_sel.Substring(0, strindex)); instrumento = Servico.BuscarInstrumento(id_instrumento); if (instrumento.Id_Instrumento == 0) { cmbInstrumento.SelectedIndex = -1; listarInstrumentos(); limpaDGV(); return; } lblTipo.Visible = true; lblTipoLegenda.Visible = true; lblNenhum.Visible = false; lblTipo.Text = instrumento.Tipo; string sql = "SELECT id_campo, nome, " + "CASE WHEN tipo = 'vint' THEN 'Nº Inteiro' WHEN tipo = 'vdate' THEN 'Data' WHEN tipo = 'vdouble' THEN 'Nº decimal' ELSE 'Texto' END, " + "'' FROM campo WHERE excluido = false AND id_instrumento = " + instrumento.Id_Instrumento + " "; dgvCampos.DataSource = Servico.PopDataTable(sql); ajustesDGV(); }
public ActionResult RegistraPresenca(int Cod_Usuario, string Nome, int Cod_Instrumento, bool Aluno, DateTime Data, int Cod_Comum) { var instrutor = UserSession.Get(Request.HttpContext).Usuario; if (Cod_Comum == 0 || !instrutor.Admin) { Cod_Comum = instrutor.Cod_Comum; } int Cod_Presenca = 0; if (instrutor.Instrutor) { Cod_Presenca = GetCodPresenca(new int[] { Cod_Usuario }, Data, Cod_Comum)[0]; } return(View("Situacao", new UsuarioPresenca() { Cod_Presenca = Cod_Presenca, Cod_Justificativa = 0, Cod_Usuario = Cod_Usuario, Nome = Nome, Instrumento = Cod_Instrumento == 0 ? "" : Instrumento.Find(Cod_Instrumento).Nome, Aluno = Aluno })); }
private void btnCadastrarInstrumento_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(TxtNomeInstrumento.Text) && !string.IsNullOrEmpty(TxtPrecoInstrumento.Text) && !string.IsNullOrEmpty(TxtQtdInstrumento.Text)) { //Gravar instrumento = new Instrumento { Nome = TxtNomeInstrumento.Text, Preço = Convert.ToDouble(TxtPrecoInstrumento.Text), Quantidade = Convert.ToInt32(TxtQtdInstrumento.Text) }; if (InstrumentoDAO.CadastrarInstrumento(instrumento)) { MessageBox.Show("Instrumento cadastrado com sucesso!", "Escola de Musica", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Esse Instrumento já existe!", "Escola de Musica", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Favor preencher os campos corretamente!", "Escola de Musica", MessageBoxButton.OK, MessageBoxImage.Error); } LimpaCampos(); }
public async Task <IActionResult> Edit(long?id, [Bind("InstrumentoID, Nome, Marca, Modelo, Serie, Cor ")] Instrumento instrumento) { if (id != instrumento.InstrumentoID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(instrumento); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InstrumentoExists(instrumento.InstrumentoID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(IndexInstrumento))); } return(View(instrumento)); }
public Form1() { ins = new Guitarra(); ve = new Vehiculo(); fun = new Vehiculo(); InitializeComponent(); }
public static void Exercicio1B_Update(string isin, DateTime date, int val) { try { using (var ts = new TransactionScope()) { RegistoKey key = new RegistoKey(isin, date.Date); IMapperRegisto mapperRegisto = new MapperRegisto(); IMapperValoresMercado mapperValoresMercado = new MapperValoresMercado(); IMapperInstrumento mapperInstrumento = new MapperInstrumento(); Instrumento instrumento = mapperInstrumento.Read(isin); Console.WriteLine("Informação de valores de mercado antes do update:"); Console.WriteLine(mapperValoresMercado.Read(new ValoresMercadoKey(instrumento.CodigoMercado, date)).ToString()); //Update Registo registo = mapperRegisto.Read(key); registo.ValorAbertura = val; mapperRegisto.Update(registo); Console.WriteLine("\nUpdate\n"); Console.WriteLine("Informação de valores de mercado depois do update:"); Console.WriteLine(mapperValoresMercado.Read(new ValoresMercadoKey(instrumento.CodigoMercado, date)).ToString() + "\n"); ts.Complete(); } } catch (Exception ex) { Console.WriteLine("Excepção apanhada : " + ex.Message); } }
private void btnBuscaNomeCurso_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(txtBuscaNomeInstrumento.Text)) { instrumento = new Instrumento { Nome = txtBuscaNomeInstrumento.Text }; instrumento = InstrumentoDAO.BuscarInstrumentoPorNome(instrumento); if (instrumento != null) { txtNomeInstrumento.Text = instrumento.Nome; txtPrecoInstrumento.Text = instrumento.Preço.ToString(); txtQuantidadeInstrumento.Text = instrumento.Quantidade.ToString(); HabilitarCampos(true); } else { MessageBox.Show("Esse Instrumento não existe!", "Escola de Musica", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Favor preencher o nome!", "Escola de Musica", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnBuscar_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(txtNomeInstrumentoBuscar.Text)) { instrumento = new Instrumento { Nome = txtNomeInstrumentoBuscar.Text }; instrumento = InstrumentoDAO.BuscarInstrumentoPorNome(instrumento); if (instrumento != null) { //Mostrar os dados HabilitarCampos(true); } else { MessageBox.Show("Esse Instrumento não existe!", "Escola de Musica", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Favor preencher o nome!", "Escola de Musica", MessageBoxButton.OK, MessageBoxImage.Error); } }
public FrmProbar(Instrumento instrumento) { InitializeComponent(); if(instrumento is Bajo) { Bajo bajo = (Bajo)instrumento; switch (bajo.Tipo) { case Bajo.ETipoBajo.Activo: this.player = new SoundPlayer("Sample4.wav"); break; case Bajo.ETipoBajo.Pasivo: this.player = new SoundPlayer("Sample3.wav"); break; } } if (instrumento is Guitarra) { Guitarra guitarra = (Guitarra)instrumento; switch (guitarra.Tipo) { case Guitarra.ETipoGuitarra.Electrica: this.player = new SoundPlayer("Sample.wav"); break; case Guitarra.ETipoGuitarra.Acustica: this.player = new SoundPlayer("Sample2.wav"); break; } } }
static void Main(string[] args) { Orquesta orquesta1 = new Orquesta(); //orquesta1.ImprimirOrquesta(); Orquesta orquesta2 = new Orquesta("Orquesta2", "lugarS", "sinfonica"); //orquesta2.ImprimirOrquesta(); Instrumento instrumento1 = new Instrumento(); instrumento1.ImprimirInstrumento(); Instrumento instrumento2 = new Instrumento("Violin", "Cuerda"); instrumento2.ImprimirInstrumento(); Musico musico1 = new Musico("Pepe", "Fafa", 23, orquesta2, instrumento2); musico1.ImprimirMusico(); ArrayList listaOrquesta = new ArrayList(); listaOrquesta.Add(orquesta1); listaOrquesta.Add(orquesta2); foreach (Orquesta elemento in listaOrquesta) { elemento.ImprimirOrquesta(); } }
public IActionResult GuardarInstrumento([FromBody] FormInstrumento entrada) { Instrumento elInstrumento = null; if (entrada.Id > 0) { elInstrumento = _context.Instrumentos.Find(entrada.Id); elInstrumento.Codigo = entrada.CodigoInstrumento; elInstrumento.Nombre = entrada.NombreInstrumento; elInstrumento.Marca = _context.Marcas.Find(entrada.Marca); elInstrumento.Estado = entrada.Estado; elInstrumento.Descripcion = entrada.Descripcion; } else { elInstrumento = new Instrumento(); elInstrumento.Nombre = entrada.NombreInstrumento; elInstrumento.Codigo = entrada.CodigoInstrumento; elInstrumento.Marca = _context.Marcas.Find(entrada.Marca); elInstrumento.Estado = entrada.Estado; elInstrumento.Descripcion = entrada.Descripcion; elInstrumento.Activa = true; _context.Instrumentos.Add(elInstrumento); } _context.SaveChanges(); return(Ok()); }
private void btnSalvar_Click(object sender, EventArgs e) { if (!cons()) { Util.Alert("Alguns campos obrigatórios ficaram sem ser preenchidos!", MessageBoxIcon.Error); } else { Instrumento instrumento = new Instrumento(); string nome = txtNomeInstrumento.Text; string tipo = cmbTipoAval.Text; instrumento.SetProperties(0, nome, tipo, false); if (Servico.ExisteInstrumento(nome)) { if (!Util.Confirm("Já existe um instrumento cadastrado com esse nome (" + nome + ")!\nDeseja cadastrar mesmo assim?")) { return; } } long id_instrumento = Servico.SalvarInstrumentoId(instrumento); foreach (DataGridViewRow row in dgvCampos.Rows) { Campo novo_campo = new Campo(); string nome_campo = row.Cells[0].Value.ToString(); string tipo_campo = row.Cells[1].Value.ToString(); if (tipo_campo == "Data") { tipo_campo = "vdate"; } else if (tipo_campo == "Número inteiro") { tipo_campo = "vint"; } else if (tipo_campo == "Número decimal") { tipo_campo = "vdouble"; } else { tipo_campo = "vtext"; } novo_campo.SetProperties(0, id_instrumento, nome_campo, tipo_campo, false); Servico.SalvarCampo(novo_campo); } Util.Alert("Instrumento " + instrumento.Nome + " cadastrado com sucesso!", MessageBoxIcon.Information); Util.CleanFields(Controls); limpaDGV(); } }
public ActionResult DeleteConfirmed(int id) { Instrumento instrumento = db.Instrumentos.Find(id); db.Instrumentos.Remove(instrumento); db.SaveChanges(); return(RedirectToAction("Index")); }
// Inserta un instrumento dado su modelo // public string Insertar_Instrumento(Instrumento Inst) { if (Inst.Tipo_Ubicacion == "1") { Diccionario_ID_Existe = new Dictionary <int, int> { { 1, Inst.ID_Estuche }, { 3, Inst.ID_Proveedor } }; } else { Diccionario_ID_Existe = new Dictionary <int, int> { { 1, Inst.ID_Estuche }, { 3, Inst.ID_Proveedor }, { 4, Convert.ToInt32(Inst.ID_Aula) } }; } Dictionary <int, int> Diccionario_ID_No_Existe = new Dictionary <int, int> { { 2, Inst.ID_Instrumento } }; if (Instancia_BBDD.Abrir_Conexion_BBDD() == true) { if (Validar_ID_Controlador_Inventario(Diccionario_ID_Existe, 1) == 0 & Validar_ID_Controlador_Inventario(Diccionario_ID_No_Existe, 0) == 0) { CMD = new SqlCommand("I_Insertar_Instrumento", Instancia_BBDD.Conexion); CMD.CommandType = CommandType.StoredProcedure; CMD.Parameters.Add("@V_ID_Instrumento", SqlDbType.Int).Value = Inst.ID_Instrumento; CMD.Parameters.Add("@V_Nombre", SqlDbType.VarChar).Value = Inst.Nombre; CMD.Parameters.Add("@V_Material", SqlDbType.VarChar).Value = Inst.Material; CMD.Parameters.Add("@V_Color", SqlDbType.VarChar).Value = Inst.Color; CMD.Parameters.Add("@V_Imagen", SqlDbType.VarChar).Value = Inst.Imagen; CMD.Parameters.Add("@V_Marca", SqlDbType.VarChar).Value = Inst.Marca; CMD.Parameters.Add("@V_Descripcion", SqlDbType.VarChar).Value = Inst.Descripcion; CMD.Parameters.Add("@V_Esta_En_Bodega", SqlDbType.Bit).Value = Convert.ToInt32(Inst.Tipo_Ubicacion); CMD.Parameters.Add("@V_Estado", SqlDbType.VarChar).Value = Inst.Estado; CMD.Parameters.Add("@V_ID_Estuche", SqlDbType.Int).Value = Inst.ID_Estuche; CMD.Parameters.Add("@V_ID_Proveedor", SqlDbType.Int).Value = Inst.ID_Proveedor; if (Inst.Tipo_Ubicacion == "1") { CMD.Parameters.Add("@V_Estante ", SqlDbType.Int).Value = Inst.Estante; CMD.Parameters.Add("@V_Gaveta ", SqlDbType.Int).Value = Inst.Gaveta; } else { CMD.Parameters.Add("@V_ID_Aula", SqlDbType.Int).Value = Inst.ID_Aula; } CMD.ExecuteNonQuery(); CMD.Dispose(); Instancia_BBDD.Cerrar_Conexion(); return("{\"Cod_Resultado\": 1,\"Mensaje\": \"Se inserto el nuevo registro\"}"); } else { return(Errores + "}"); } } else { return("{\"Cod_Resultado\": -1,\"Mensaje\": \"No se pudo conectar con la base de datos\"}"); } }
// Devuelve la lista total de todos los instrumentos // public string Devolver_Lista_Todos_Instrumentos(int Bandera = 1, int ID_Instrumento = 0) { if (Instancia_BBDD.Abrir_Conexion_BBDD() == true) { CMD = new SqlCommand("I_Listado_Instrumentos", Instancia_BBDD.Conexion); CMD.CommandType = CommandType.StoredProcedure; CMD.Parameters.Add("@ID_Instrumento", SqlDbType.Int).Value = ID_Instrumento; CMD.Parameters.Add("@Bandera", SqlDbType.Bit).Value = Bandera; SqlReader = CMD.ExecuteReader(); List <Instrumento> Lista_Instrumento = new List <Instrumento>(); if (SqlReader.HasRows) { while (SqlReader.Read()) { Instrumento Nuevo_Instrumento = new Instrumento(); Nuevo_Instrumento.ID_Instrumento = SqlReader.GetInt32(0); Nuevo_Instrumento.Nombre = SqlReader.GetString(1); Nuevo_Instrumento.Material = SqlReader.GetString(2); Nuevo_Instrumento.Color = SqlReader.GetString(3); Nuevo_Instrumento.Imagen = SqlReader.GetString(4); Nuevo_Instrumento.Marca = SqlReader.GetString(5); Nuevo_Instrumento.Descripcion = SqlReader.GetString(6); Nuevo_Instrumento.Estado = SqlReader.GetString(7); Nuevo_Instrumento.ID_Estuche = SqlReader.GetInt32(8); Nuevo_Instrumento.Nombre_Estuche = SqlReader.GetString(9); Nuevo_Instrumento.ID_Proveedor = SqlReader.GetInt32(10); Nuevo_Instrumento.Proveedor = SqlReader.GetString(11); Nuevo_Instrumento.Tipo_Ubicacion = SqlReader.GetString(16); if (Nuevo_Instrumento.Tipo_Ubicacion == "Bodega") { Nuevo_Instrumento.Estante = SqlReader.GetInt32(12); Nuevo_Instrumento.Gaveta = SqlReader.GetInt32(13); } else { Nuevo_Instrumento.Piso = SqlReader.GetInt32(15); Nuevo_Instrumento.Numero_Aula = SqlReader.GetInt32(14); } Lista_Instrumento.Add(Nuevo_Instrumento); } CMD.Dispose(); Instancia_BBDD.Cerrar_Conexion(); return(JsonConvert.SerializeObject(Lista_Instrumento, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); } else { return("{\"Cod_Resultado\": 0,\"Mensaje\": \"La consulta no devolvio resultados\"}"); } } else { return("{\"Cod_Resultado\": -1,\"Mensaje\": \"No se pudo conectar con la base de datos\"}"); } }
/// <summary> /// Funcion para cargar la lista de la clase Carrito usando los datos de cada fila para cada tipo de instrumento, para luego usar en cuando guardo la factura en txt o para serializar /// </summary> private void CargarCarrito() { Instrumento i = default; this.carrito = new Carrito(); try { foreach (DataRow fila in this.dt.Rows) // Recorro todos las filas, pasandole los valores a cada instrumento { if (fila["tipo"].ToString() == "Guitarra Electrica") { i = new Guitarra(int.Parse(fila["id"].ToString()), fila["tipo"].ToString(), fila["marca"].ToString(), fila["modelo"].ToString(), fila["estado"].ToString(), float.Parse(fila["precio"].ToString())); } else if (fila["tipo"].ToString() == "Bajo") { i = new Bajo(int.Parse(fila["id"].ToString()), fila["tipo"].ToString(), fila["marca"].ToString(), fila["modelo"].ToString(), fila["estado"].ToString(), float.Parse(fila["precio"].ToString())); } else if (fila["tipo"].ToString() == "Bateria") { i = new Bajo(int.Parse(fila["id"].ToString()), fila["tipo"].ToString(), fila["marca"].ToString(), fila["modelo"].ToString(), fila["estado"].ToString(), float.Parse(fila["precio"].ToString())); } else if (fila["tipo"].ToString() == "Violin") { i = new Bajo(int.Parse(fila["id"].ToString()), fila["tipo"].ToString(), fila["marca"].ToString(), fila["modelo"].ToString(), fila["estado"].ToString(), float.Parse(fila["precio"].ToString())); } this.carrito += i; // agrego cada instrumento a la lista de la Clase Carrito con el operador += } } catch (Exception e) { MessageBox.Show(e.Message); } }
/// <summary> /// Elige el instrumento que se desea probar o comprar, y lo envia al frm principal. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSeleccionar_Click(object sender, EventArgs e) { if (this.SeleccionInstrumento != null) { Instrumento seleccion = (Instrumento)this.listInstrumentos.SelectedItem; this.SeleccionInstrumento.Invoke(seleccion); } this.Close(); }
public Visualizar(Relatorio relatorio, Avaliacao avaliacao) { InitializeComponent(); this.relatorio = relatorio; this.avaliacao = avaliacao; instrumento = Servico.BuscarInstrumento(avaliacao.Id_Instrumento); string sql = "SELECT id_campo, nome, tipo, '' FROM campo WHERE false = true "; cleandt = Servico.PopDataTable(sql); }
public ActionResult Editar(int idinstrumento) { GestorDatos.GestorDatos gestor = new GestorDatos.GestorDatos(); Instrumento i = gestor.buscarinstrumento(idinstrumento); DTOinstrumento dto = new DTOinstrumento(); dto.I = i; dto.Listatipos = gestor.listadetipos(); return(View(dto)); }
public static bool CadastrarInstrumento(Instrumento instrumento) { if (BuscarInstrumentoPorNome(instrumento) == null) { ctx.Instrumentos.Add(instrumento); ctx.SaveChanges(); return(true); } return(false); }
public static void InstrumentoExcluido(Instrumento i, bool excluido) { string sql = "UPDATE instrumento" + " SET excluido = " + excluido + " WHERE id_instrumento = " + i.Id_Instrumento + ";"; Connection.Open(); Connection.Run(sql); Connection.Close(); }
// // GET: /Instrumento/Delete/5 public ActionResult Delete(int id = 0) { Instrumento instrumento = db.Instrumentos.Find(id); if (instrumento == null) { return(HttpNotFound()); } return(View(instrumento)); }
public ActionResult Edit(Instrumento instrumento) { if (ModelState.IsValid) { db.Entry(instrumento).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(instrumento)); }
/// <summary> /// Constructor q recibe un instrumento y asigna los parametros de cada textbox /// </summary> /// <param name="inst"></param> public frmInstrumentos(Instrumento inst) : this() { this.inst = inst; this.cmbTipo.SelectedItem = inst.Tipo.ToString(); this.textMarca.Text = inst.Marca.ToString(); this.textModelo.Text = inst.Modelo.ToString(); this.cboEstado.SelectedItem = inst.Estado.ToString(); this.textPrecio.Text = inst.Precio.ToString(); }
public string Put([FromBody] Instrumento Ins) { if (ModelState.IsValid && Ins != null) { return(Instancia_OP.Actualizar_Instrumento(Ins)); } else { return("{\"Exito\":\"false\",\"Mensaje_Cabecera\":\"Error\",\"Mensaje_Usuario\":\"Asegurate de ingresar bien los datos\",\"Descripcion_Error\":\"El modelo enviado al servidor no es correcto\"}"); } }
public ActionResult Create(Instrumento instrumento) { if (ModelState.IsValid) { db.Instrumentos.Add(instrumento); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(instrumento)); }
public string Put([FromBody] Instrumento Ins) { if (ModelState.IsValid && Ins != null) { return(Instancia_OP.Actualizar_Instrumento(Ins)); } else { return("{\"Cod_Resultado\": -1,\"Mensaje\": \"El modelo no es correcto, asegurate de enviar bien los datos\"}"); } }