//--------------------------------------------------------------------------------------------------------------------------------------- ///<summary> Adiciona un nuevo fabricante o modifica uno ya existente (si maker.Id==0 crea uno nuevo) </summary> private int AddModifyMaker(IFormFile fileFoto, Fabricante maker) { var nuevo = maker.Id == 0; // Indica que es un registro nuevo (no una modificación) var makers = new Fabricantes(HttpContext); // Obtiene objetos para operaciones con los fabricantes var Id = makers.Change(maker); // Si maker.Id == 0, se interpreta como una marca nueva if (Id <= 0) { return(Id); } try { var fName = SaveFile("Logos", maker.Nombre, fileFoto); // Guarda al fichero del logo en el directorio 'Logos' if (fName == null && nuevo) // Si no se cargo un Logo y si es un registro nuevo { fName = CopyFile(maker.Logo, "Logos", maker.Nombre); // Hace un duplicado del fichero del logo } if (fName != null) // Si se cambio el logo { makers.ChangeLogo(Id, fName); // Modifica localizacion y nombre del logo } } catch (Exception) { } // Ignora cualquier error guardando la imagen return(Id); }
public async Task <IActionResult> PutFabricantes(int id, Fabricantes fabricantes) { if (id != fabricantes.Codigo) { return(BadRequest()); } _context.Entry(fabricantes).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FabricantesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public bool Save(Fabricantes fab) { try { if (!Valid(fab)) { return(false); } if (db.Find(fab.Id) == null) { fab.Id = db.NextId(f => f.Id); db.Save(fab); } else { db.Update(fab); } db.Commit(); BStatus.Success("Fabricante salvo"); return(true); } catch { return(false); } }
public async Task <ActionResult <Fabricantes> > PostFabricantes(Fabricantes fabricantes) { _context.Fabricantes.Add(fabricantes); await _context.SaveChangesAsync(); return(CreatedAtAction("GetFabricantes", new { id = fabricantes.Codigo }, fabricantes)); }
public bool FabricantesUpdate(Fabricantes oFab) { try { Conexion oConexion = new Conexion(); OracleConnection cn = oConexion.getConexion(); cn.Open(); ds = new DataSet(); cmd = new OracleCommand( "update Fabricantes " + "SET FAB_DESCRIPCION='" + oFab.FabDescripcion + "', EST_CODIGO='" + oFab.FabHabilitado + //"', EMP_NUMERO='" + oFab.EmpNumero + "', USR_NUMERO='" + oFab.UsrNumero + "', FAB_FECHA_CARGA='" + oFab.FabFechaCarga.ToShortDateString() + "' WHERE FAB_NUMERO=" + oFab.FabNumero, cn); adapter = new OracleDataAdapter(cmd); response = cmd.ExecuteNonQuery(); cn.Close(); return(response > 0); } catch (Exception ex) { throw ex; } }
public List <Fabricantes> FabricantesGetAll() { List <Fabricantes> lstFabricantes = new List <Fabricantes>(); try { ds = new DataSet(); Conexion oConexion = new Conexion(); OracleConnection cn = oConexion.getConexion(); cn.Open(); string sqlSelect = "select * from Fabricantes "; cmd = new OracleCommand(sqlSelect, cn); adapter = new OracleDataAdapter(cmd); cmd.ExecuteNonQuery(); adapter.Fill(ds); DataTable dt = new DataTable(); dt = ds.Tables[0]; if (dt.Rows.Count > 0) { for (int i = 0; dt.Rows.Count > i; i++) { DataRow dr = dt.Rows[i]; Fabricantes NewEnt = new Fabricantes(); NewEnt = CargarFabricantes(dr); lstFabricantes.Add(NewEnt); } } return(lstFabricantes); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> Edit(int id, [Bind("id,nombreFabricante,pais")] Fabricantes fabricantes) { if (id != fabricantes.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(fabricantes); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FabricantesExists(fabricantes.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(fabricantes)); }
public Fabricantes FabricantesGetById(long Id) { try { DataSet ds = new DataSet(); Conexion oConexion = new Conexion(); OracleConnection cn = oConexion.getConexion(); cn.Open(); string sqlSelect = "select * from Fabricantes " + "WHERE FAB_NUMERO=" + Id; cmd = new OracleCommand(sqlSelect, cn); adapter = new OracleDataAdapter(cmd); cmd.ExecuteNonQuery(); adapter.Fill(ds); DataTable dt; dt = ds.Tables[0]; Fabricantes NewEnt = new Fabricantes(); if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; NewEnt = CargarFabricantes(dr); } return(NewEnt); } catch (Exception ex) { throw ex; } }
//Revisar public void Inicializar() { // ACA SE DEVERIA CARGAR LOS VALORES DEL COMBOBOX /* DataTable test = new DataTable(empresa.EmpresasGetAll()); * test. * oUtil.CargarCombo(_vista.empNumero, );*/ if (_vista.fabNumero != 0) { Fabricantes oFabricante = new Fabricantes(); FabricantesBus oFabreicanteBus = new FabricantesBus(); oFabricante = oFabreicanteBus.FabricantesGetById(_vista.fabNumero); _vista.fabDescripcion = oFabricante.FabDescripcion; Controles.datos.chkBox auxFbHabilitado = new Controles.datos.chkBox(); auxFbHabilitado.Text = "Habilitado"; _vista.fabHabilitado = auxFbHabilitado; switch (oFabricante.FabHabilitado) { case "H": _vista.fabHabilitado.Checked = true; break; case "I": _vista.fabHabilitado.Checked = false; break; } _vista.fabFechaCarga = new Controles.Fecha.dtpFecha(); _vista.fabFechaCarga.Value = oFabricante.FabFechaCarga; _vista.usrNumero = oFabricante.UsrNumero; _vista.fabNumero = oFabricante.FabNumero; } }
//REVISAR public void Guardar() { Fabricantes oFabricante = new Fabricantes(); FabricantesBus oFabreicanteBus = new FabricantesBus(); oFabricante.FabDescripcion = _vista.fabDescripcion; oFabricante.FabFechaCarga = _vista.fabFechaCarga.Value; if (_vista.fabHabilitado.Checked == true) { oFabricante.FabHabilitado = "H"; } else { oFabricante.FabHabilitado = "I"; } //Se tendra que remplazar con el numero de usuario que este logeado oFabricante.UsrNumero = 1; //REVISAR!!!!!!! TENGO QUE RECUPERAR EL NUMERO DE LA EMPRESA SELECCIONADA!! oFabricante.EmpNumero = _vista.empNumero.SelectedIndex; if (_vista.fabNumero == 0) { oFabreicanteBus.FabricantesAdd(oFabricante); } else { oFabricante.FabNumero = _vista.fabNumero; oFabreicanteBus.FabricantesUpdate(oFabricante); } }
//--------------------------------------------------------------------------------------------------------------------------------------- /// <summary> Construye el objeto y obtiene los datos de la base de datos </summary> public RecambiosDatosModel(int id, HttpContext HttpCtx, DataInfo tipo) : base(HttpCtx, id) { if (tipo == DataInfo.All || tipo == DataInfo.Items) // Obtiene datos sobre los Items { Fabricantes = new Fabricantes(HttpCtx).ListIdName(); var cat = new Categorias(HttpCtx); Categorias = cat.ListIdName(); SubCategorias = cat.getSubCategorias(); Items = new Recambios(HttpCtx).FindByDatos("0/0/0/0/0/Order-4/Range-0-10000").Items; } if (tipo == DataInfo.All || tipo == DataInfo.Coches) // Obtiene datos sobre los coches { Marcas = new Marcas(HttpCtx).ListIdName(); Modelos = new Modelos(HttpCtx).ListModelos(); if (tipo != DataInfo.Coches) { Motores = new Motores(HttpCtx).FindForCoche("en uso", null); } else { Motores2 = new Motores(HttpCtx).ListMotores(); } Coches = new RecambioUsos(0, HttpCtx).UsoInCoches().Coches; } }
public frmUpdFab() { InitializeComponent(); f = new Fabricantes(); txt_id.Text = Convert.ToString(f.getId()); txt_nome.Text = f.getNome(); controller = new UpdFabController(); }
public bool Eliminar(long idFabricante) { Fabricantes oFabricante = new Fabricantes(); FabricantesBus oFabreicanteBus = new FabricantesBus(); oFabricante = oFabreicanteBus.FabricantesGetById(idFabricante); oFabricante.FabHabilitado = "B"; return(oFabreicanteBus.FabricantesUpdate(oFabricante)); }
private void FillFabricante(Fabricantes f) { if (f == null) { return; } txCod.Text = f.Id.ToString(); txNome.Text = f.Nome; }
private bool Valid(Fabricantes fab) { if (string.IsNullOrWhiteSpace(fab.Nome)) { BStatus.Alert("O nome do fabricante é obrigatório"); return(false); } return(true); }
public long FabricantesAdd(Fabricantes oFab) { try { Conexion oConexion = new Conexion(); OracleConnection cn = oConexion.getConexion(); cn.Open(); // Clave Secuencia FAB_NUMERO ds = new DataSet(); string query = " DECLARE IDTEMP NUMBER(10,0); " + " BEGIN " + " SELECT(PKG_SECUENCIAS.FNC_PROX_SECUENCIA('FAB_NUMERO')) into IDTEMP from dual; " + "insert into Fabricantes (FAB_NUMERO,FAB_DESCRIPCION, " + "EST_CODIGO, USR_NUMERO, FAB_FECHA_CARGA) " + "values(IDTEMP,'" + oFab.FabDescripcion + "','" + oFab.FabHabilitado + "'," + oFab.UsrNumero + ",'" + oFab.FabFechaCarga.ToShortDateString() + "')RETURNING IDTEMP INTO :id;END;"; /* * ACA ESTARIA LA IMPLEMENTACION PARA CUANDO SE ULTILICE EL NUMERO DE LA EMPRESA * * string query = " DECLARE IDTEMP NUMBER(10,0); " + * " BEGIN " + * " SELECT(PKG_SECUENCIAS.FNC_PROX_SECUENCIA('FAB_NUMERO')) into IDTEMP from dual; " + * "insert into Fabricantes (FAB_NUMERO,FAB_DESCRIPCION, " + * "EST_CODIGO, EMP_NUMERO, USR_NUMERO, FAB_FECHA_CARGA) " + * "values(IDTEMP,'" + oFab.FabDescripcion + "','" + oFab.FabHabilitado + "'," + * oFab.EmpNumero + "," + oFab.UsrNumero + ",'" + oFab.FabFechaCarga.ToShortDateString() + "')RETURNING IDTEMP INTO :id;END;"; */ cmd = new OracleCommand(query, cn); adapter = new OracleDataAdapter(cmd); cmd.Parameters.Add(new OracleParameter { ParameterName = ":id", OracleDbType = OracleDbType.Int64, Direction = ParameterDirection.Output }); adapter = new OracleDataAdapter(cmd); cmd.ExecuteNonQuery(); response = long.Parse(cmd.Parameters[":id"].Value.ToString()); cn.Close(); return(response); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> Create([Bind("id,nombreFabricante,pais")] Fabricantes fabricantes) { if (ModelState.IsValid) { _context.Add(fabricantes); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(fabricantes)); }
private void prev_Click(object sender, RoutedEventArgs e) { if ((int.Parse(txCod.Text) - 1) <= 0) { LimparCampos(); return; } Fabricantes f = controller.Prev(int.Parse(txCod.Text)); FillFabricante(f); }
public async Task <IHttpActionResult> PutFabricantes(Fabricantes fabricantes) { try { this.fabricantesServicios.Edit(fabricantes); return(this.Ok(fabricantes)); } catch (Exception ex) { return(this.BadRequest(ex.Message)); } }
private void fabricantesToolStripMenuItem_Click(object sender, EventArgs e) { if (Application.OpenForms["Fabricantes"] != null) { Application.OpenForms["Fabricantes"].Activate(); } else { Fabricantes frm = new Fabricantes(); frm.MdiParent = this; frm.Show(); } }
/// <summary>The edit fabricantes.</summary> /// <param name="fabricantes">The fabricantes.</param> /// <exception cref="ValidationException"></exception> public void Edit(Fabricantes fabricantes) { var editFabricantesValidador = new EditFabricantesValidador(this.unidadDeTrabajoAdministracion.FabricantesRepositorio); var editFabricantesValidadorResultado = editFabricantesValidador.Validate(fabricantes); if (!editFabricantesValidadorResultado.IsValid) { throw new ValidationException(editFabricantesValidadorResultado.Errors); } this.unidadDeTrabajoAdministracion.FabricantesRepositorio.Actualizar(fabricantes); this.unidadDeTrabajoAdministracion.Confirmar(); }
/// <summary>The add fabricantes.</summary> /// <param name="fabricantes">The fabricantes.</param> public void Add(Fabricantes fabricantes) { var addFabricantesValidador = new AddFabricantesValidador(this.unidadDeTrabajoAdministracion.FabricantesRepositorio); var addFabricantesValidadorResultado = addFabricantesValidador.Validate(fabricantes); if (!addFabricantesValidadorResultado.IsValid) { throw new ValidationException(addFabricantesValidadorResultado.Errors); } this.unidadDeTrabajoAdministracion.FabricantesRepositorio.Insertar(fabricantes); this.unidadDeTrabajoAdministracion.Confirmar(); }
//--------------------------------------------------------------------------------------------------------------------------------------- /// <summary> Construye el objeto y obtiene los datos de la base de datos </summary> public FindRecambioModel(HttpContext HttpCtx) : base(HttpCtx) { Marcas = new Marcas(HttpCtx).ListIdName(); Modelos = new Modelos(HttpCtx).ListModelos(); Motores = new Motores(HttpCtx).FindForCoche("en uso", null); Fabricantes = new Fabricantes(HttpCtx).ListIdName(); var cat = new Categorias(HttpCtx); Categorias = cat.ListIdName(); SubCategorias = cat.getSubCategorias(); }
private void btSalvar_Click(object sender, RoutedEventArgs e) { Fabricantes f = (int.Parse(txCod.Text) == 0 ? new Fabricantes() : controller.Find(int.Parse(txCod.Text))); f.Id = int.Parse(txCod.Text); f.Nome = txNome.Text; if (controller.Save(f)) { LimparCampos(); } }
public IActionResult Post([FromBody] Fabricantes value) { using (var context = new FacturaContext()) { try { context.Fabricantes.FromSql($" exec Insertar_Fabricantes {value.IdFabricantes}, {value.Nombre},{value.Estado}").FirstOrDefault(); } catch (Exception e) { return(BadRequest(e.Message)); } } return(CreatedAtAction("Get", value)); }
private void Selecionar() { Fabricantes f = (Fabricantes)dataGrid.SelectedItem; if (f == null) { return; } if (f.Id == 0) { return; } Selecionado = f; Close(); }
private Fabricantes CargarFabricantes(DataRow dr) { try { Fabricantes oObjeto = new Fabricantes(); oObjeto.FabNumero = int.Parse(dr["FAB_NUMERO"].ToString()); oObjeto.FabDescripcion = dr["FAB_DESCRIPCION"].ToString(); oObjeto.FabHabilitado = dr["EST_CODIGO"].ToString(); if (dr["EMP_NUMERO"].ToString() != "") { oObjeto.EmpNumero = long.Parse(dr["EMP_NUMERO"].ToString()); } oObjeto.UsrNumero = int.Parse(dr["USR_NUMERO"].ToString()); oObjeto.FabFechaCarga = DateTime.Parse(dr["FAB_FECHA_CARGA"].ToString()); return(oObjeto); } catch (Exception ex) { throw ex; } }
public frmFab() { InitializeComponent(); f = new Fabricantes(); controller = new CadFabController(); }
public void Delete(Fabricantes fabricantes) { this.fabricantesServicios.Delete(fabricantes); }
public async Task <IHttpActionResult> PostFabricantes(Fabricantes id) { this.fabricantesServicios.Add(id); return(this.Ok(id)); }