예제 #1
0
        public override bool Eliminar()
        {
            DbConexion conexion = new DbConexion();
            bool       retorno  = false;

            try
            {
                retorno = conexion.Ejecutar(String.Format("DELETE FROM SolicitudesDetalle WHERE IdSolicitud={0}", this.IdSolicitud));
                if (retorno)
                {
                    conexion.Ejecutar(String.Format("DELETE FROM Solicitudes WHERE IdSolicitud={0}", this.IdSolicitud));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(retorno);
        }
예제 #2
0
        public override bool Editar()
        {
            DbConexion conexion = new DbConexion();
            bool       retorno  = false;

            try
            {
                retorno = conexion.Ejecutar(string.Format("UPDATE Solicitudes SET Fecha='{0}', Total={1} ,Razon ='{2}' WHERE IdSolicitud={3}", this.Fecha, this.Total, this.Razon, this.IdSolicitud));
                if (retorno)
                {
                    conexion.Ejecutar(String.Format("DELETE FROM SolicitudesDetalle WHERE IdSolicitud={0}", this.IdSolicitud));
                    foreach (SolicitudesDetalle item in this.Detalle)
                    {
                        conexion.Ejecutar(string.Format("Insert Into SolicitudesDetalle (IdSolicitud,Cantidad,Precio) VALUES ({0},{1},{2})", IdSolicitud, item.Cantidad, item.Precio));
                    }
                }
            }
            catch (Exception ex) { throw ex; }
            return(retorno);
        }
예제 #3
0
        public override bool Eliminar()
        {
            int        retornar = 0;
            DbConexion cone     = new DbConexion();

            try
            {
                retornar = Convert.ToInt16(cone.Ejecutar(String.Format("delete from Material where MaterialId =" + this.MaterialId)));

                if (retornar > 0)
                {
                    cone.Ejecutar(String.Format("delete from MaterialDetalle where MaterialId =" + this.MaterialId));
                }
            }catch (Exception ex)
            {
                throw ex;
            }

            return(retornar > 0);
        }
예제 #4
0
        public override bool Editar()
        {
            DbConexion conexion = new DbConexion();
            bool       retorno  = false;

            try
            {
                retorno = conexion.Ejecutar(String.Format("UPDATE Materiales SET Descripcion='{0}', Precio={1} WHERE IdMaterial={2}", this.Descripcion, this.Precio, this.IdMaterial));
            }
            catch (Exception ex) { throw ex; }
            return(retorno);
        }
예제 #5
0
        public override bool Insertar()
        {
            DbConexion cone     = new DbConexion();
            int        Retornar = 0;
            DataTable  dt       = new DataTable();

            try
            {
                Retornar = Convert.ToInt32(cone.Ejecutar(String.Format("Insert Into Material(Razon) Values('{0}') Select @@IDENTITY", this.Razon)));
                if (Retornar > 0)
                {
                    foreach (MaterialesDetalle item in Detalle)
                    {
                        cone.Ejecutar(String.Format("Insert Into MaterialDetalle(Material,Cantidad,MaterialId) Values('{0}','{1}',{2})", item.Material, item.Cantidad, Retornar));
                    }
                }
            }catch (Exception ex)
            {
                throw ex;
            }
            return(Retornar > 0);
        }
예제 #6
0
        public override bool Eliminar()
        {
            bool       Retornar = false;
            DbConexion cone     = new DbConexion();

            try
            {
                Retornar = cone.Ejecutar(String.Format("Delete from VentasDetalle where VentaId = {0}; " + "Delete from Ventas where VentaId = {0}", this.VetaId));
            }catch (Exception ex)
            {
                throw ex;
            }
            return(Retornar);
        }
예제 #7
0
        public override bool Actualizar()
        {
            bool       Retornar = false;
            DbConexion cone     = new DbConexion();

            try
            {
                Retornar = cone.Ejecutar(String.Format("Update Ventas set Fecha='{0}',Monto={1} where VentaId={2}", this.Fecha, this.Monto, this.VetaId));

                if (Retornar)
                {
                    cone.Ejecutar("Delete from VentasDetalle where VentaId =" + this.VetaId);
                    foreach (VentasDetalle item in this.Detalle)
                    {
                        cone.Ejecutar(String.Format("Insert into VentasDetalle(VentaId,ArticuloId,Cantidad,Precio) Values({0},{1},{2},{3})", this.VetaId, item.ArticuloId, item.Cantidad, item.Precio));
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Retornar);
        }
예제 #8
0
        public override bool Eliminar()
        {
            DbConexion conexion = new DbConexion();
            bool       retorno  = false;

            try
            {
                retorno = conexion.Ejecutar(String.Format("DELETE FROM Materiales WHERE IdMaterial={0}", this.IdMaterial));
                //if (retorno)
                //    conexion.Ejecutar(String.Format("DELETE FROM Materiales WHERE IdMaterial={0}", this.IdMaterial));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(retorno);
        }
예제 #9
0
        public bool AfectarExistencia()
        {
            DbConexion cone     = new DbConexion();
            bool       Retornar = false;

            try
            {
                foreach (Articulos ar in this.Lista)
                {
                    Retornar = cone.Ejecutar(String.Format("Update Articulos set Existencia={0} where ArticuloId = {1}", ar.Existencia - ar.Cantidad, ar.ArticuloId));
                }
            }
            catch (Exception)
            {
            }
            return(Retornar);
        }
예제 #10
0
        public override bool Insertar()
        {
            DbConexion cone    = new DbConexion();
            int        retorno = 0;
            object     Identity;

            try
            {
                Identity = cone.ObtenerValor(string.Format("INSERT INTO Solicitudes (Fecha, Razon,Total) VALUES ('{0}','{1}',{2}) SELECT @@Identity", this.Fecha, this.Razon, this.Total));
                int.TryParse(Identity.ToString(), out retorno);
                if (retorno > 0)
                {
                    foreach (SolicitudesDetalle item in this.Detalle)
                    {
                        cone.Ejecutar(string.Format("Insert Into SolicitudesDetalle(IdSolicitud,Cantidad,Precio) VALUES ({0},{1},{2})", retorno, retorno, item.Cantidad, item.Precio));
                    }
                }
                return(retorno > 0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #11
0
        public override bool Insertar()
        {
            int        Retornar = 0;
            object     Identity = null;
            DbConexion cone     = new DbConexion();

            try
            {
                Identity = cone.ObtenerValor(String.Format("Insert into Ventas(Fecha,Monto) Values('{0}',{1}) SELECT @@Identity", this.Fecha, this.Monto));
                int.TryParse(Identity.ToString(), out Retornar);

                if (Retornar > 0)
                {
                    foreach (VentasDetalle item in this.Detalle)
                    {
                        cone.Ejecutar(String.Format("Insert into VentasDetalle(VentaId,ArticuloId,Cantidad,Precio) Values({0},{1},{2},{3})", Retornar, item.ArticuloId, item.Cantidad, item.Precio));
                    }
                }
            }catch (Exception ex)
            {
                throw ex;
            }
            return(Retornar > 0);
        }