public IHttpActionResult Putmedicamento(int id, medicamento medicamento) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != medicamento.id) { return(BadRequest()); } db.Entry(medicamento).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!medicamentoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create([Bind(Include = "id,nombre,descripcion")] medicamento medicamento) { if (ModelState.IsValid) { bool f = false; medicamento.nombre = medicamento.nombre.ToUpperInvariant(); var medicamentos = db.medicamento.Select(a => a.nombre); foreach (var a in medicamentos) { if (a == medicamento.nombre) { ViewBag.Error = "Medicamento ya Existe"; f = true; } } if (f == true) { return(View(medicamento)); } else { if (ModelState.IsValid) { db.medicamento.Add(medicamento); db.SaveChanges(); return(RedirectToAction("Inicio")); } } } return(View(medicamento)); }
private void txtBuscar_TextChanged(object sender, EventArgs e) { medicamento p = new medicamento(); DataSet ds = new DataSet(); ds = p.buscarPorNombre(txtBuscar.Text); dataGridView1.DataSource = ds; dataGridView1.DataMember = "tm"; }
private void button3_Click(object sender, EventArgs e) { medicamento c = new medicamento(); DataSet ds = new DataSet(); ds = c.buscarPorNombre(txtBuscar.Text); dataGridView1.DataSource = ds; dataGridView1.DataMember = "tm"; }
private void txtMedicamento_TextChanged(object sender, EventArgs e) { medicamento p = new medicamento(); DataSet ds = new DataSet(); ds = p.buscarPorNombre(txtMedicamento.Text); dgvMedicamento.DataSource = ds; dgvMedicamento.DataMember = "tm"; //dgv.Visible = true; }
private void button2_Click(object sender, EventArgs e) { medicamento med = new medicamento(); med.Nombre = txtNombre.Text; med.Cod_categoria = int.Parse(txtCategoria.Text); med.Stock = int.Parse(txtStock.Text); med.Precio = double.Parse(txtPrecio.Text); med.guardar(); }
public IHttpActionResult Getmedicamento(int id) { medicamento medicamento = db.medicamento.Find(id); if (medicamento == null) { return(NotFound()); } return(Ok(medicamento)); }
public IHttpActionResult Postmedicamento(medicamento medicamento) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.medicamento.Add(medicamento); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = medicamento.id }, medicamento)); }
// GET: Medicamento/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } medicamento medicamento = db.medicamento.Find(id); if (medicamento == null) { return(HttpNotFound()); } return(View(medicamento)); }
public IHttpActionResult Deletemedicamento(int id) { medicamento medicamento = db.medicamento.Find(id); if (medicamento == null) { return(NotFound()); } db.medicamento.Remove(medicamento); db.SaveChanges(); return(Ok(medicamento)); }
public HttpResponseMessage AgregarMedicamento(medicamento medicamento) { using (gasStationBDEntities entities = new gasStationBDEntities()) { if (ModelState.IsValid) { try { entities.InsertarMedicamento(medicamento.nombre, medicamento.precio, medicamento.prescripcion, medicamento.proveedor); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (DataException) { return(Request.CreateResponse(HttpStatusCode.Unauthorized)); } } return(Request.CreateResponse(HttpStatusCode.NotFound)); } }
public ActionResult DeleteConfirmed(int id) { medicamento medicamento = db.medicamento.Find(id); try { db.medicamento.Remove(medicamento); db.SaveChanges(); return(RedirectToAction("Inicio")); } catch { ViewBag.Error = "No se puede eliminar debido a que existen datos asociados"; } return(View(medicamento)); }