public void UpdateTienda(string nombreTienda, int tiendaID) { tienda objTienda = new tienda(); tienda objTiendaVerificar = new tienda(); using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull()) { objTiendaVerificar = VerificarTiendaEntidad.tiendas.Where(s => s.nombre == nombreTienda).FirstOrDefault <tienda>(); } if (objTiendaVerificar == null) { using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull()) { objTienda = TiendaEntidad.tiendas.Where(s => s.id_tienda == tiendaID).FirstOrDefault <tienda>(); } objTienda.nombre = txtN.Text.ToString(); objTienda.direccion = txtD.Text.ToString(); objTienda.telefono = txtT.Text.ToString(); using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull()) { TiendaEntidad.Entry(objTienda).State = System.Data.EntityState.Modified; TiendaEntidad.SaveChanges(); } HideButtom(); ShowNotification("Su registro a sido actualizado!"); } else { ShowNotification("Ya existe una tienda con ese nomnbre!"); } }
public void UpdateProducto(string nombre, string detalle, string precio, int productoID, int proveedorID) { producto objproducto = new producto(); producto objTiendaVerificar = new producto(); using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull()) { objTiendaVerificar = VerificarTiendaEntidad.productoes .Where(s => s.id_producto != productoID && (s.nombre_producto == nombre)) .FirstOrDefault <producto>(); } if (objTiendaVerificar == null) { using (agrosysEntitiesFull productoEntidad = new agrosysEntitiesFull()) { objproducto = productoEntidad.productoes.Where(s => s.id_producto == productoID).FirstOrDefault <producto>(); } int tiendaId = Convert.ToInt32(comboBox1.SelectedValue); objproducto.nombre_producto = nombre; objproducto.precio = precio; objproducto.detalle_producto = detalle; objproducto.proveedor_id_proveedor = proveedorID; using (agrosysEntitiesFull productoEntidad = new agrosysEntitiesFull()) { productoEntidad.Entry(objproducto).State = System.Data.EntityState.Modified; productoEntidad.Entry(objproducto.proveedor).State = System.Data.EntityState.Modified; productoEntidad.SaveChanges(); } HideButtom(); ShowNotification("Su registro a sido actualizado!"); } else { ShowNotification("Ya existe producto con ese Nombre!"); } }
public void UpdateCliente(string NITCliente, int clienteID, string dpi) { cliente objCliente = new cliente(); cliente objTiendaVerificar = new cliente(); using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull()) { objTiendaVerificar = VerificarTiendaEntidad.clientes .Where(s => s.id_cliente != clienteID && (s.nit == NITCliente || s.dpi == dpi)) .FirstOrDefault <cliente>(); } if (objTiendaVerificar == null) { using (agrosysEntitiesFull ClienteEntidad = new agrosysEntitiesFull()) { objCliente = ClienteEntidad.clientes.Where(s => s.id_cliente == clienteID).FirstOrDefault <cliente>(); } objCliente.primer_nombre = txtN.Text.ToString(); objCliente.segundo_nombre = txtN2.Text.ToString(); objCliente.primer_apellido = txtA.Text.ToString(); objCliente.segundo_apellido = txtA2.Text.ToString(); objCliente.telefono = txtT.Text.ToString(); objCliente.nit = txtNIT.Text.ToString(); objCliente.direccion = txtNIT.Text.ToString(); objCliente.dpi = txtDPI.Text.ToString(); using (agrosysEntitiesFull ClienteEntidad = new agrosysEntitiesFull()) { ClienteEntidad.Entry(objCliente).State = System.Data.EntityState.Modified; ClienteEntidad.SaveChanges(); } HideButtom(); ShowNotification("Su registro a sido actualizado!"); } else { ShowNotification("Ya existe cliente con ese NIT!"); } }
public void UpdateProveedor(string NITproveedor, int proveedorID) { proveedor objProveedor = new proveedor(); proveedor objProveedorVerificar = new proveedor(); using (agrosysEntitiesFull VerificarProveedorEntidad = new agrosysEntitiesFull()) { objProveedorVerificar = VerificarProveedorEntidad.proveedors .Where(s => s.id_proveedor != proveedorID || s.nit == NITproveedor) .FirstOrDefault <proveedor>(); } if (objProveedorVerificar == null) { using (agrosysEntitiesFull proveedorEntidad = new agrosysEntitiesFull()) { objProveedor = proveedorEntidad.proveedors.Where(s => s.id_proveedor == proveedorID).FirstOrDefault <proveedor>(); } objProveedor.nombre_proveedor = txtN.Text.ToString(); objProveedor.telefono = txtT.Text.ToString(); objProveedor.nit = txtNIT.Text.ToString(); objProveedor.direccion = txtD.Text.ToString(); using (agrosysEntitiesFull proveedorEntidad = new agrosysEntitiesFull()) { proveedorEntidad.Entry(objProveedor).State = System.Data.EntityState.Modified; proveedorEntidad.SaveChanges(); } ShowNotification("Su registro a sido actualizado!"); } else { ShowNotification("Ya existe proveedor con ese NIT!"); } }
public void UpdateProveedor(string NITproveedor, int proveedorID) { proveedor objProveedor = new proveedor(); proveedor objProveedorVerificar = new proveedor(); using (agrosysEntitiesFull VerificarProveedorEntidad = new agrosysEntitiesFull()) { objProveedorVerificar = VerificarProveedorEntidad.proveedors .Where(s => s.id_proveedor != proveedorID || s.nit == NITproveedor ) .FirstOrDefault<proveedor>(); } if (objProveedorVerificar == null) { using (agrosysEntitiesFull proveedorEntidad = new agrosysEntitiesFull()) { objProveedor = proveedorEntidad.proveedors.Where(s => s.id_proveedor == proveedorID).FirstOrDefault<proveedor>(); } objProveedor.nombre_proveedor = txtN.Text.ToString(); objProveedor.telefono = txtT.Text.ToString(); objProveedor.nit = txtNIT.Text.ToString(); objProveedor.direccion = txtD.Text.ToString(); using (agrosysEntitiesFull proveedorEntidad = new agrosysEntitiesFull()) { proveedorEntidad.Entry(objProveedor).State = System.Data.EntityState.Modified; proveedorEntidad.SaveChanges(); } ShowNotification("Su registro a sido actualizado!"); } else { ShowNotification("Ya existe proveedor con ese NIT!"); } }
public void UpdateCliente(string NITCliente, int clienteID, string dpi) { cliente objCliente= new cliente(); cliente objTiendaVerificar = new cliente(); using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull()) { objTiendaVerificar = VerificarTiendaEntidad.clientes .Where(s => s.id_cliente != clienteID &&( s.nit == NITCliente || s.dpi == dpi)) .FirstOrDefault<cliente>(); } if (objTiendaVerificar == null) { using (agrosysEntitiesFull ClienteEntidad = new agrosysEntitiesFull()) { objCliente = ClienteEntidad.clientes.Where(s => s.id_cliente == clienteID).FirstOrDefault<cliente>(); } objCliente.primer_nombre = txtN.Text.ToString(); objCliente.segundo_nombre = txtN2.Text.ToString(); objCliente.primer_apellido = txtA.Text.ToString(); objCliente.segundo_apellido = txtA2.Text.ToString(); objCliente.telefono = txtT.Text.ToString(); objCliente.nit = txtNIT.Text.ToString(); objCliente.direccion = txtNIT.Text.ToString(); objCliente.dpi = txtDPI.Text.ToString(); using (agrosysEntitiesFull ClienteEntidad = new agrosysEntitiesFull()) { ClienteEntidad.Entry(objCliente).State = System.Data.EntityState.Modified; ClienteEntidad.SaveChanges(); } HideButtom(); ShowNotification("Su registro a sido actualizado!"); } else { ShowNotification("Ya existe cliente con ese NIT!"); } }
public void UpdateProducto(string nombre, string detalle, string precio, int productoID, int proveedorID) { producto objproducto = new producto(); producto objTiendaVerificar = new producto(); using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull()) { objTiendaVerificar = VerificarTiendaEntidad.productoes .Where(s => s.id_producto != productoID && (s.nombre_producto == nombre )) .FirstOrDefault<producto>(); } if (objTiendaVerificar == null) { using (agrosysEntitiesFull productoEntidad = new agrosysEntitiesFull()) { objproducto = productoEntidad.productoes.Where(s => s.id_producto == productoID).FirstOrDefault<producto>(); } int tiendaId = Convert.ToInt32(comboBox1.SelectedValue); objproducto.nombre_producto = nombre; objproducto.precio = precio; objproducto.detalle_producto = detalle; objproducto.proveedor_id_proveedor = proveedorID; using (agrosysEntitiesFull productoEntidad = new agrosysEntitiesFull()) { productoEntidad.Entry(objproducto).State = System.Data.EntityState.Modified; productoEntidad.Entry(objproducto.proveedor).State = System.Data.EntityState.Modified; productoEntidad.SaveChanges(); } HideButtom(); ShowNotification("Su registro a sido actualizado!"); } else { ShowNotification("Ya existe producto con ese Nombre!"); } }
public void UpdateTienda(string nombreTienda,int tiendaID) { tienda objTienda = new tienda(); tienda objTiendaVerificar = new tienda(); using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull()) { objTiendaVerificar = VerificarTiendaEntidad.tiendas.Where(s => s.nombre == nombreTienda).FirstOrDefault<tienda>(); } if (objTiendaVerificar == null) { using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull()) { objTienda = TiendaEntidad.tiendas.Where(s => s.id_tienda == tiendaID).FirstOrDefault<tienda>(); } objTienda.nombre = txtN.Text.ToString(); objTienda.direccion = txtD.Text.ToString(); objTienda.telefono = txtT.Text.ToString(); using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull()) { TiendaEntidad.Entry(objTienda).State = System.Data.EntityState.Modified; TiendaEntidad.SaveChanges(); } HideButtom(); ShowNotification("Su registro a sido actualizado!"); } else { ShowNotification("Ya existe una tienda con ese nomnbre!"); } }