public void PutFabricantes(int id, fabricantes fabricantes) { fabricantes.idFabricante = id; if (!repositorio.Update(fabricantes)) { throw new HttpResponseException(HttpStatusCode.NotFound); } }
public fabricantes Add(fabricantes item) { if (item == null) { throw new ArgumentNullException("item"); } Banco.InserirFabricante(item); return(item); }
public void DeleteFabricantes(int id) { fabricantes item = repositorio.Get(id); if (item == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } repositorio.Remove(id); }
public fabricantes GetFabricantes(int id) { fabricantes item = repositorio.Get(id); if (item == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(item); }
private void cargarDatos() { using (tiendaEntities db = new tiendaEntities()) { // consultar datos a editar de la base de datos oFabricantes = db.fabricantes.Find(idfabricante); txtNombre.Text = oFabricantes.nombre_fabricante; txtNombre.Text = oFabricantes.pais_fabricantes; } }
private void BtnEditar_Click(object sender, EventArgs e) { // retornar valor seleccionado en la tabla fabricantes f = getSelectedItem(); if (f != null) { // llamar formulario en modo FrmFabricantesGestion frmFabricantesGestion = new FrmFabricantesGestion(f.id_fabricante); frmFabricantesGestion.ShowDialog(); refrescarTabla(); } }
private fabricantes getSelectedItem() { fabricantes f = new fabricantes(); try { f.id_fabricante = int.Parse(grdDatos.Rows[grdDatos.CurrentRow.Index].Cells[0].Value.ToString()); return(f); } catch { return(null); } }
public IHttpActionResult PostFabricantes([FromBody] fabricantes item) { //item = repositorio.Add(item); //var response = Request.CreateResponse<fabricantes>(HttpStatusCode.Created, item); //string uri = Url.Link("DefaultApi", new { id = item.idFabricante }); //response.Headers.Location = new Uri(uri); //return response; fabricantes fabricante = repositorio.GetAll().FirstOrDefault(l => l.idFabricante == item.idFabricante); if (fabricante != null) { return(ResponseMessage(Request.CreateResponse <string>(HttpStatusCode.Conflict, "Já existe um fabricante cadastrado com esse ID."))); } else { repositorio.Add(item); return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK))); } }
private void BtnGuardar_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtNombre.Text) || this.cboPais.SelectedValue.ToString() == "T") { MessageBox.Show("Los campos marcados con ( * ) son obligatorios"); } else { using (tiendaEntities db = new tiendaEntities()) { // si es modo inserción, inicializamos el objeto de fabricantes if (this.idfabricante == null) { oFabricantes = new fabricantes(); } // armar el objeto con los datos registrados en el formulario oFabricantes.nombre_fabricante = this.txtNombre.Text; oFabricantes.pais_fabricantes = this.cboPais.SelectedValue.ToString(); if (this.idfabricante == null) { // insertar nuevo fabricante db.fabricantes.Add(oFabricantes); } else { // modificar fabricante existente db.Entry(oFabricantes).State = System.Data.Entity.EntityState.Modified; } // confirmar cambios en la BD db.SaveChanges(); // cerrar formulario de gestion de fabricantes this.Close(); } } }
private void BtnEliminar_Click(object sender, EventArgs e) { // Obtener la fila que se va a eliminar fabricantes f = this.getSelectedItem(); // Validar si hubo selección if (f != null) { if (MessageBox.Show("¿Seguro que quiere eliminar el registro ?", "confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { using (tiendaEntities db = new tiendaEntities()) { // buscar en la bd el fabricante a eliminar fabricantes fabEliminar = db.fabricantes.Find(f.id_fabricante); db.fabricantes.Remove(fabEliminar); db.SaveChanges(); } refrescarTabla(); } } }
public bool Update(fabricantes item) { throw new NotImplementedException(); }