Пример #1
0
        public RespuestaServicio <PEDIDO> Eliminar(int Id)
        {
            RespuestaServicio <PEDIDO> respuesta = new RespuestaServicio <PEDIDO>();

            try
            {
                if (Id <= 0)
                {
                    throw new Exception("El Id es invalido");
                }

                using (var bd = new FarmaciaEntities())
                {
                    var _Pedido = bd.PEDIDO.Find(Id);
                    _Pedido.Estatus         = false;
                    bd.Entry(_Pedido).State = System.Data.Entity.EntityState.Modified;
                    bd.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                respuesta.Error   = true;
                respuesta.Mensaje = ex.Message;
            }
            return(respuesta);
        }
Пример #2
0
        public RespuestaServicio <PEDIDO> Modificar(PEDIDO _item)
        {
            RespuestaServicio <PEDIDO> respuesta = new RespuestaServicio <PEDIDO>();

            try
            {
                if (_item.Id <= 0)
                {
                    throw new Exception("El Id es invalido");
                }

                using (var bd = new FarmaciaEntities())
                {
                    _item.Fecha_Modificacion = DateTime.Now;
                    bd.Entry(_item).State    = System.Data.Entity.EntityState.Modified;
                    bd.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                respuesta.Error   = true;
                respuesta.Mensaje = ex.Message;
            }
            return(respuesta);
        }
Пример #3
0
        public bool atualizarCliente(tb_clientes_farmacia objCliente)
        {
            var db = new FarmaciaEntities();

            db.Entry <tb_clientes_farmacia>(objCliente).State = System.Data.Entity.EntityState.Modified;

            #region .: db.SaveChanges :.

            try
            {
                db.SaveChanges();
                return(true);
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                var raise = (from validationErrors in dbEx.EntityValidationErrors
                             from validationError in validationErrors.ValidationErrors
                             select string.Format("{0}:{1}", validationErrors.Entry.Entity, validationError.ErrorMessage))
                            .Aggregate <string, Exception>(dbEx,
                                                           (current, message) => new InvalidOperationException(message, current));
                throw raise;
            }

            #endregion
        }
Пример #4
0
        public RespuestaServicio <ARTICULO> Eliminar(int Id)
        {
            RespuestaServicio <ARTICULO> respuesta = new RespuestaServicio <ARTICULO>();

            try
            {
                if (Id <= 0)
                {
                    throw new Exception("El Id es invalido");
                }

                using (var bd = new FarmaciaEntities())
                {
                    var _articulo = bd.ARTICULO.Find(Id);
                    _articulo.Estatus            = false;
                    _articulo.Fecha_Modificacion = DateTime.Now;
                    bd.Entry(_articulo).State    = System.Data.Entity.EntityState.Modified;
                    bd.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                respuesta.Error   = true;
                respuesta.Mensaje = ex.Message;
            }
            return(respuesta);
        }
Пример #5
0
        public RespuestaServicio<CLIENTE> Modificar(CLIENTE _cliente)
        {
            RespuestaServicio<CLIENTE> respuesta = new RespuestaServicio<CLIENTE>();
            try
            {
                if (_cliente.Id <= 0)
                    throw new Exception("El Id es invalido");

                using (var bd = new FarmaciaEntities())
                {

                    bd.Entry(_cliente).State = System.Data.Entity.EntityState.Modified;
                    bd.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                respuesta.Error = true;
                respuesta.Mensaje = ex.Message;
            }
            return respuesta;
        }
Пример #6
0
        public RespuestaServicio<CLIENTE> Eliminar(int Id)
        {
            RespuestaServicio<CLIENTE> respuesta = new RespuestaServicio<CLIENTE>();
            try
            {
                if (Id <= 0)
                    throw new Exception("El Id es invalido");

                using (var bd = new FarmaciaEntities())
                {
                    var _cliente = bd.CLIENTE.Find(Id);
                    _cliente.Estatus = false;
                    bd.Entry(_cliente).State = System.Data.Entity.EntityState.Modified;
                    bd.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                respuesta.Error = true;
                respuesta.Mensaje = ex.Message;
            }
            return respuesta;
        }