Exemplo n.º 1
0
        public RespuestaServicio <PEDIDO> Guardar(PEDIDO _item)
        {
            RespuestaServicio <PEDIDO> respuesta = new RespuestaServicio <PEDIDO>();

            try
            {
                if (_item.Id_Cliente < 1)
                {
                    throw new Exception("Cliente Invalido");
                }
                if (_item.PEDIDO_DETALLE.Count() < 1)
                {
                    throw new Exception("Almenos debe contener un articulo");
                }
                using (var bd = new FarmaciaEntities())
                {
                    _item.Estatus        = true;
                    _item.Fecha_Pedido   = DateTime.Now;
                    _item.Fecha_Creacion = DateTime.Now;
                    bd.PEDIDO.Add(_item);
                    bd.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                respuesta.Error   = true;
                respuesta.Mensaje = ex.Message;
            }
            return(respuesta);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public bool inserirUsuario(tb_usuarios_farmacia objUsuario)
        {
            var db = new FarmaciaEntities();

            db.tb_usuarios_farmacia.Add(objUsuario);

            #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
        }
Exemplo n.º 5
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
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        //guardamos en base de datos el objeto cliente
        public RespuestaServicio<CLIENTE> Guardar(CLIENTE _item)
        {
            RespuestaServicio<CLIENTE> respuesta = new RespuestaServicio<CLIENTE>();
            try
            {
                using (var bd = new FarmaciaEntities())
                {
                    _item.Estatus = true;
                    bd.CLIENTE.Add(_item);
                    bd.SaveChanges();

                }
            }
            catch (Exception ex)
            {
                respuesta.Error = true;
                respuesta.Mensaje = ex.Message;
            }
            return respuesta;
        }
Exemplo n.º 8
0
        public RespuestaServicio <ARTICULO> Guardar(ARTICULO _item)
        {
            RespuestaServicio <ARTICULO> respuesta = new RespuestaServicio <ARTICULO>();

            try
            {
                using (var bd = new FarmaciaEntities())
                {
                    _item.Estatus        = true;
                    _item.Fecha_Creacion = DateTime.Now;
                    bd.ARTICULO.Add(_item);
                    bd.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                respuesta.Error   = true;
                respuesta.Mensaje = ex.Message;
            }
            return(respuesta);
        }
Exemplo n.º 9
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;
        }
Exemplo n.º 10
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;
        }