Example #1
0
        public override bool Buscar(int IdBuscado)
        {
            DbConexion conexion = new DbConexion();
            DataTable  dt       = new DataTable();
            DataTable  dt2      = new DataTable();
            bool       retornar = true;

            try
            {
                dt = conexion.ObtenerDatos("SELECT * FROM Solicitudes WHERE IdSolicitud=" + IdBuscado);
                if (dt.Rows.Count > 0)
                {
                    this.IdSolicitud = (int)dt.Rows[0]["IdSolicitud"];
                    this.Fecha       = dt.Rows[0]["Fecha"].ToString();
                    this.Razon       = dt.Rows[0]["Razon"].ToString();
                    this.Total       = Convert.ToSingle(dt.Rows[0]["Total"]);

                    dt2 = conexion.ObtenerDatos("SELECT * FROM SolicitudesDetalle WHERE IdSolicitud=" + IdBuscado);
                    foreach (DataRow item in dt2.Rows)
                    {
                        this.InsertarMaterial(IdBuscado, (int)item["IdMaterial"], (int)item["Cantidad"], (float)item["Precio"]);
                    }
                }
                return(dt.Rows.Count > 0);
            }
            catch (Exception)
            {
                retornar = false;
            }
            return(retornar);
        }
Example #2
0
        public override bool Buscar(int IdBuscar)
        {
            DbConexion cone     = new DbConexion();
            DataTable  dt       = new DataTable();
            DataTable  dt2      = new DataTable();
            bool       Retornar = false;

            try
            {
                dt = cone.ObtenerDatos("Select * from Ventas where ventaId = " + IdBuscar);
                if (dt.Rows.Count > 0)
                {
                    this.VetaId = (int)dt.Rows[0]["VentaId"];
                    this.Monto  = Convert.ToSingle(dt.Rows[0]["Monto"]);
                    this.Fecha  = dt.Rows[0]["Fecha"].ToString();

                    dt2 = cone.ObtenerDatos(String.Format("Select * from VentasDetalle where VentaId = {0}", IdBuscar));
                    foreach (DataRow row in dt2.Rows)
                    {
                        AgregarArticulos((int)row["ArticuloId"], (int)row["Cantidad"], Convert.ToSingle(row["Precio"]));
                    }
                }
                return(dt.Rows.Count > 0);
            }catch (Exception)
            {
                Retornar = false;
            }
            return(Retornar);
        }
Example #3
0
        public override bool Buscar(int IdBuscar)
        {
            DataTable  dt        = new DataTable();
            DataTable  dtDetalle = new DataTable();
            DbConexion cone      = new DbConexion();

            try
            {
                dt = cone.ObtenerDatos(String.Format("Select * from Material where MaterialId=)" + IdBuscar));
                this.MaterialId = (int)dt.Rows[0]["MaterialId"];
                this.Razon      = dt.Rows[0]["Razon"].ToString();

                dtDetalle = cone.ObtenerDatos(String.Format("Select * from MaterialDetalle where MaterialId+", IdBuscar));
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dtDetalle.Rows)
                    {
                        AgregarMateriales(row[0].ToString(), (int)row[0]);
                    }
                }
            }catch (Exception ex)
            {
                throw ex;
            }
            return(dt.Rows.Count > 0);
        }
Example #4
0
        public void AbrirTest()
        {
            DbConexion sesultado = new DbConexion("localhost", "root", "toor", "bdvt");
            bool       esperado  = true;
            bool       resultado = sesultado.Abrir();

            Assert.AreEqual(esperado, resultado);
        }
Example #5
0
        public override DataTable Listado(string Campos, string Condicion, string Orden)
        {
            DbConexion conexion = new DbConexion();
            string     ordenar  = "";

            if (!Orden.Equals(""))
            {
                ordenar = " orden by  " + Orden;
            }
            return(conexion.ObtenerDatos(("SELECT " + Campos + " FROM Solicitudes WHERE " + Condicion + ordenar)));
        }
Example #6
0
        public override DataTable Listar(string Campo, string Condicion, string Orden)
        {
            throw new NotImplementedException();
            DbConexion cone       = new DbConexion();
            string     OrdenFinal = "";

            if (!Orden.Equals(""))
            {
                OrdenFinal = "Orden by" + Orden;
            }
            return(cone.ObtenerDatos("Select " + Campo + "from MaterialesDetalle where " + Condicion + Orden));
        }
Example #7
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);
        }
Example #8
0
        public override DataTable Listar(string Campo, string Condicion, string Orden)
        {
            DataTable  dt         = new DataTable();
            DbConexion cone       = new DbConexion();
            string     OrdenFinal = "";

            if (!Orden.Equals(""))
            {
                OrdenFinal = "Order by " + Orden;
            }

            return(cone.ObtenerDatos(String.Format("Select " + Campo + " from Ventas as v inner join VentasDetalle d on v.ventasId = d.VentasId " + Condicion + " " + OrdenFinal)));
        }
Example #9
0
        public DataTable Listar(string Campo, string Condicion, string Orden)
        {
            DataTable  dt         = new DataTable();
            DbConexion cone       = new DbConexion();
            string     OrdenFinal = "";

            if (!Orden.Equals(""))
            {
                OrdenFinal = "Order by " + Orden;
            }

            return(dt = cone.ObtenerDatos(String.Format("Select * from Articulos ")));
        }
Example #10
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);
        }
Example #11
0
        public override bool Insertar()
        {
            DbConexion conexion = new DbConexion();
            int        retorno  = 0;

            try
            {
                conexion.ObtenerValor(String.Format("INSERT INTO Materiales (Descripcion, Precio) VALUES ('{0}',{1})", this.Descripcion, this.Precio));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(retorno > 0);
        }
Example #12
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);
        }
Example #13
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);
        }
Example #14
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);
        }
Example #15
0
        public void ObtenerDatosArticulo(int Articulo)
        {
            DbConexion cone = new DbConexion();
            DataTable  dt   = new DataTable();

            try
            {
                dt = cone.ObtenerDatos(String.Format("Select * from Articulos where ArticuloId ={0}", Articulo));
                if (dt.Rows.Count > 0)
                {
                    this.ArticuloId = (int)dt.Rows[0]["ArticuloId"];
                    this.Precio     = Convert.ToSingle(dt.Rows[0]["Precio"]);
                    this.Existencia = (int)dt.Rows[0]["Existencia"];
                }
            }catch (Exception ex)
            {
                throw ex;
            }
        }
Example #16
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);
        }
Example #17
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);
        }
Example #18
0
        public override bool Buscar(int IdBuscado)
        {
            DbConexion conexion = new DbConexion();
            DataTable  dt       = new DataTable();
            bool       retornar = true;

            try
            {
                dt = conexion.ObtenerDatos("SELECT * FROM Materiales WHERE IdMaterial=" + IdBuscado);
                if (dt.Rows.Count > 0)
                {
                    this.IdMaterial  = (int)dt.Rows[0]["IdMaterial"];
                    this.Descripcion = dt.Rows[0]["Descripcion"].ToString();
                    this.Precio      = Convert.ToSingle(dt.Rows[0]["Precio"]);
                }
            }catch (Exception)
            {
                retornar = false;
            }
            return(retornar);
        }
Example #19
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);
        }
Example #20
0
        public string PrecioDetalle(string material)
        {
            string     retorno  = "";
            DbConexion conexion = new DbConexion();
            DataTable  dt       = new DataTable();
            bool       retornar = true;

            try
            {
                dt = conexion.ObtenerDatos("SELECT * FROM Materiales WHERE Descripcion =" + material);
                if (dt.Rows.Count > 0)
                {
                    this.IdMaterial  = (int)dt.Rows[0]["IdMaterial"];
                    this.Descripcion = dt.Rows[0]["Descripcion"].ToString();
                    this.Precio      = Convert.ToSingle(dt.Rows[0]["Precio"]);
                }
            }
            catch (Exception)
            {
                retornar = false;
            }
            return(retorno);
        }
Example #21
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;
            }
        }
Example #22
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);
        }
Example #23
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);
        }