示例#1
0
        public override bool Buscar(int IdBuscado)
        {
            DataTable dt        = new DataTable();
            DbVentana cone      = new DbVentana();
            DataTable dtDetalle = new DataTable();

            bool Retornar = false;

            try
            {
                dt = cone.ObtenerDatos("Select * from Proyectos where ProyectoId = " + IdBuscado);
                if (dt.Rows.Count > 0)
                {
                    this.ProyectoId = (int)dt.Rows[0]["ProyectoId"];
                    this.ClienteId  = (int)dt.Rows[0]["ClienteId"];
                    this.Fecha      = dt.Rows[0]["Fecha"].ToString();
                    this.Total      = Convert.ToSingle(dt.Rows[0]["Total"]);

                    dtDetalle = cone.ObtenerDatos(String.Format("Select * from ProyectosDetalle where ProyectoId ={0}", IdBuscado));

                    foreach (DataRow row in dtDetalle.Rows)
                    {
                        AgregarTrabajos(1, Convert.ToInt32(row["ProductoId"]), Convert.ToSingle(row["Ancho"]), Convert.ToSingle(row["Altura"]), Convert.ToSingle(row["Pie"]), Convert.ToSingle(row["Precio"]));
                    }
                }
                return(dt.Rows.Count > 0);
            }
            catch (Exception)
            {
                Retornar = false;
            }
            return(Retornar);
        }
示例#2
0
        public override bool Buscar(int IdBuscado)
        {
            DataTable dt        = new DataTable();
            DataTable dtDetalle = new DataTable();
            DbVentana cone      = new DbVentana();
            bool      Retornar  = false;

            try
            {
                dt = cone.ObtenerDatos(String.Format("Select * from Productos where ProductoId ={0} ", IdBuscado));
                if (dt.Rows.Count > 0)
                {
                    Retornar         = true;
                    this.ProductoId  = (int)dt.Rows[0]["ProductoId"];
                    this.Pie         = Convert.ToSingle(dt.Rows[0]["Pie"]);
                    this.Descripcion = dt.Rows[0]["Descripcion"].ToString();
                    this.MinimoPie   = Convert.ToSingle(dt.Rows[0]["MinimoPie"]);

                    dtDetalle = cone.ObtenerDatos(String.Format("Select * from ProductosDetalle where ProductoId={0}", IdBuscado));
                    foreach (DataRow row in dtDetalle.Rows)
                    {
                        AgregarProducto((int)row["MaterialId"], (int)row["Asociacion"]);
                    }
                }
                return(dt.Rows.Count > 0);
            }catch (Exception)
            {
                Retornar = false;
            }
            return(Retornar);
        }
示例#3
0
        public override bool Buscar(int IdBuscado)
        {
            DataTable dt       = new DataTable();
            DbVentana cone     = new DbVentana();
            bool      Retornar = false;

            try
            {
                dt = cone.ObtenerDatos(String.Format("Select * from Clientes where ClienteId = {0}", IdBuscado));

                if (dt.Rows.Count > 0)
                {
                    this.ClienteId = (int)dt.Rows[0]["ClienteId"];
                    this.Nombre    = dt.Rows[0]["Nombre"].ToString();
                    this.Telefono  = dt.Rows[0]["Telefono"].ToString();
                    this.Cedula    = dt.Rows[0]["Cedula"].ToString();
                    this.Direccion = dt.Rows[0]["Direccion"].ToString();
                    this.Email     = dt.Rows[0]["Email"].ToString();

                    Retornar = true;
                }
            }catch (Exception ex)
            {
                throw ex;
            }
            return(Retornar);
        }
示例#4
0
        public override bool Buscar(int IdBuscado)
        {
            DbVentana cone = new DbVentana();

            bool Retornar = false;

            try
            {
                dt = cone.ObtenerDatos(String.Format("Select * from Usuarios where UsuariosId = {0}", IdBuscado));
                if (dt.Rows.Count > 0)
                {
                    this.UsuarioId   = (int)dt.Rows[0]["UsuariosId"];
                    this.Contrasena  = dt.Rows[0]["Contrasena"].ToString();
                    this.UserName    = dt.Rows[0]["UserName"].ToString();
                    this.Nombre      = dt.Rows[0]["Nombre"].ToString();
                    this.Restriccion = (int)dt.Rows[0]["Restriccion"];
                    Retornar         = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Retornar);
        }
示例#5
0
        public override bool Editar()
        {
            DbVentana cone = new DbVentana();
            DataTable dt   = new DataTable();

            bool Retornar = false;

            try
            {
                Retornar = cone.Ejecutar(String.Format("Update Proyectos set Fecha = Convert(datetime,'{0}',5),Total={1} where ProyectoId={2}", this.Fecha, this.Total, this.ProyectoId));

                if (Retornar)
                {
                    cone.Ejecutar(String.Format("Delete from ProyectosDetalle where ProyectoId = {0}", this.ProyectoId));
                    cone.Ejecutar(String.Format("Delete from ProyectoPresupuesto where ProyectoId = {0}", this.ProyectoId));

                    foreach (ProyectosDetalle item in this.Detalle)
                    {
                        cone.Ejecutar(String.Format("Insert Into ProyectosDetalle(ProyectoId,ProductoId,Pie,Ancho,Altura,Precio) Values({0},{1},{2},{3},{4},{5})", this.ProyectoId, item.ProductoId, item.Pie, item.Ancho, item.Altura, item.Precio));



                        dt = cone.ObtenerDatos(String.Format("Select * from ProductosDetalle where ProductoId ={0}", item.ProductoId));

                        foreach (DataRow row in dt.Rows)
                        {
                            this.ListaMateriales.Add(new ProductosDetalle(Convert.ToInt32(row[2]), Convert.ToInt32(row[3])));
                        }

                        //recorrer lista materiales para insertar cada material y el calculo de su valor o cantidad en la tabla pryecto conduce
                        foreach (ProductosDetalle item2 in this.ListaMateriales)
                        {
                            if (item2.Asociacion == 0)
                            {
                                item2.Cantidad = item.Ancho / 12;
                            }
                            else
                            if (item2.Asociacion == 1)
                            {
                                item2.Cantidad = item.Altura / 12;
                            }
                            else
                            {
                                item2.Cantidad = 1;
                            }

                            cone.Ejecutar(String.Format("Insert Into ProyectoPresupuesto(ProyectoId,MaterialId,Cantidad) Values({0},{1},{2}) ", this.ProyectoId, item2.MaterialId, item2.Cantidad));
                        }
                    }
                }
            }catch (Exception ex)
            {
                throw ex;
            }
            return(Retornar);
        }
示例#6
0
        public override DataTable Listado(string Campos, string Condicion, string Orden)
        {
            DbVentana cone       = new DbVentana();
            string    OrdenFinal = "";

            if (!Orden.Equals(""))
            {
                OrdenFinal = "Orden by " + Orden;
            }
            return(cone.ObtenerDatos("Select " + Campos + " From Usuario where " + Condicion + " --"));
        }
示例#7
0
        public string ValidarContrasena(string Contrasena)
        {
            string    Validar = "";
            DbVentana cone    = new DbVentana();

            dt = cone.ObtenerDatos(String.Format("Select Contrasena from Usuarios where Contrasena='{0}'", Contrasena));
            if (dt.Rows.Count > 0)
            {
                Validar = dt.Rows[0]["Contrasena"].ToString();
            }
            return(Validar);
        }
示例#8
0
        public override DataTable Listado(string Campos, string Condicion, string Orden)
        {
            DataTable dt         = new DataTable();
            DbVentana cone       = new DbVentana();
            string    OrdenFinal = "";

            if (!Orden.Equals(""))
            {
                OrdenFinal = "Orden BY " + Orden;
            }
            return(dt = cone.ObtenerDatos("Select " + Campos + " From Cliente " + Condicion + " " + Orden));
        }
示例#9
0
        public override bool Insertar()
        {
            DbVentana cone     = new DbVentana();
            DataTable dt       = new DataTable();
            int       Retornar = 0;

            object Identity;

            try
            {
                Identity = cone.ObtenerValor(String.Format("Insert Into Proyectos(Fecha,Total,ClienteId) values(Convert(datetime,'{0}',5),{1},{2}) SELECT @@Identity", this.Fecha, this.Total, this.ClienteId));
                int.TryParse(Identity.ToString(), out Retornar);
                if (Retornar > 0)
                {
                    object Identity2;
                    int    Retornar2 = 0;
                    foreach (ProyectosDetalle item in this.Detalle)
                    {
                        //areglar ete insert (poner id del producto)
                        Identity2 = cone.ObtenerValor(String.Format("Insert Into ProyectosDetalle(ProyectoId,ProductoId,Pie,Ancho,Altura,Precio) Values({0},'{1}',{2},{3},{4},{5}) SELECT @@Identity", Retornar, item.ProductoId, item.Pie, item.Ancho, item.Altura, item.Precio));
                        int.TryParse(Identity2.ToString(), out Retornar2);

                        //con el id anterior del producto hacer un select a a la tabla productodetalle y llenar ListaMateriales
                        dt = cone.ObtenerDatos(String.Format("Select * from ProductosDetalle where ProductoId ={0}", item.ProductoId));

                        foreach (DataRow row in dt.Rows)
                        {
                            this.ListaMateriales.Add(new ProductosDetalle(Convert.ToInt32(row[2]), Convert.ToInt32(row[3])));
                        }

                        //recorrer lista materiales para insertar cada material y el calculo de su valor o cantidad en la tabla pryecto conduce
                        foreach (ProductosDetalle item2 in this.ListaMateriales)
                        {
                            if (item2.Asociacion == 0)
                            {
                                item2.Cantidad = item.Ancho / 12;
                            }
                            else
                            if (item2.Asociacion == 1)
                            {
                                item2.Cantidad = item.Altura / 12;
                            }

                            cone.Ejecutar(String.Format("Insert Into ProyectoPresupuesto(ProyectoId,MaterialId,Cantidad) Values({0},{1},{2}) ", Retornar, item2.MaterialId, item2.Cantidad));
                        }
                    }
                }
                return(Retornar > 0);
            }catch (Exception ex)
            {
                throw ex;
            }
        }
示例#10
0
        public override DataTable Listado(string Campos, string Condicion, string Orden)
        {
            DbVentana cone       = new DbVentana();
            DataTable dt         = new DataTable();
            string    OrdenFinal = "";

            if (!Orden.Equals(""))
            {
                OrdenFinal = " Order by " + Orden;
            }
            return(dt = cone.ObtenerDatos(String.Format("Select " + Campos + "from Proyecto as p inner join  ProyectosDetalle pd on p.ProyectoId = pd.ProyectoId where " + Condicion + " " + OrdenFinal)));
        }
示例#11
0
        public string ValidarUserNombre(string UserName)
        {
            string    Validar = "";
            DbVentana cone    = new DbVentana();

            dt = cone.ObtenerDatos(String.Format("Select UserName from Usuarios where UserName='******'", UserName));
            if (dt.Rows.Count > 0)
            {
                Validar = dt.Rows[0]["UserName"].ToString();
            }
            return(Validar);
        }
示例#12
0
        public DataTable ListarProductos(string Campos, string Condicion, string Orden)
        {
            DbVentana cone = new DbVentana();
            DataTable dt   = new DataTable();

            string OrdenFinal = "";

            if (!Orden.Equals(""))
            {
                OrdenFinal = "Order by " + Orden;
            }
            return(dt = cone.ObtenerDatos(String.Format("Select " + Campos + " from Productos " + Condicion + Orden)));
        }
示例#13
0
        public DataTable ListarPresupuesto(string Campos, string Condicion, string Orden)
        {
            DbVentana cone = new DbVentana();
            DataTable dt   = new DataTable();

            string OrdenFinal = "";

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

            return(dt = cone.ObtenerDatos(String.Format("Select " + Campos + " from ProyectoPresupuesto as O inner join Proyectos P on O.ProyectoId = P.ProyectoId inner join Materiales M on M.MaterialId = O.MaterialId " + Condicion + Orden + " GROUP BY M.Detalle ORDER BY M.Detalle;")));
        }
示例#14
0
        public DataTable ListaConsulta(string Campos, string Condicion, string Orden)
        {
            DbVentana cone = new DbVentana();
            DataTable dt   = new DataTable();

            string OrdenFinal = "";

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

            return(dt = cone.ObtenerDatos(String.Format("Select " + Campos + " from ProyectosDetalle as D inner join Proyectos P on D.ProyectoId = P.ProyectoId " + Condicion + Orden)));
        }
示例#15
0
        public static DataTable ConocerUsuario(string UserName, string Contrasena)
        {
            DataTable dt   = new DataTable();
            DbVentana cone = new DbVentana();

            try
            {
                dt = cone.ObtenerDatos(String.Format("Select * from Usuarios where UserName ='******' and Contrasena ='{1}' ", UserName, Contrasena));
            }catch (Exception ex)
            {
                throw ex;
            }
            return(dt);
        }
示例#16
0
        public float ObtenerMinimoPie(string Trabajo)
        {
            DataTable dt   = new DataTable();
            DbVentana cone = new DbVentana();
            float     pie  = 0;


            dt = cone.ObtenerDatos(String.Format("Select * from Productos where Descripcion ='{0}'", Trabajo));
            if (dt.Rows.Count > 0)
            {
                pie = Convert.ToSingle(dt.Rows[0]["MinimoPie"]);
            }
            return(pie);
        }
示例#17
0
        public override DataTable Listado(string Campos, string Condicion, string Orden)
        {
            DbVentana cone  = new DbVentana();
            DataTable dt    = new DataTable();
            string    campo = " '{0}'";

            string OrdenFinal = "";

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

            if (Condicion != string.Empty)
            {
                dt = cone.ObtenerDatos(String.Format("Select " + Campos + " from Materiales " + Condicion + campo, Orden));
            }
            else
            {
                dt = cone.ObtenerDatos(String.Format("Select * from Materiales "));
            }

            return(dt);
        }
示例#18
0
        public void ObtenerProducto(string Producto)
        {
            DataTable dt   = new DataTable();
            DbVentana cone = new DbVentana();

            try
            {
                dt = cone.ObtenerDatos(String.Format("Select * from Productos where Descripcion = '{0}'", Producto));
                if (dt.Rows.Count > 0)
                {
                    this.ProductoId = (int)dt.Rows[0]["ProductoId"];
                }
            }catch (Exception ex)
            {
                throw ex;
            }
        }
示例#19
0
        public string ValidarCliente(string Nombre)
        {
            DbVentana cone   = new DbVentana();
            DataTable dt     = new DataTable();
            string    nombre = "";

            dt = cone.ObtenerDatos(String.Format("Select Nombre from Clientes where Nombre = '{0}'", Nombre));

            if (dt.Rows.Count > 0)
            {
                nombre = dt.Rows[0]["Nombre"].ToString();
            }
            else
            {
                nombre = "no";
            }

            return(nombre);
        }
示例#20
0
        public void ObtenerValor(string Material)
        {
            DbVentana cone = new DbVentana();
            DataTable dt   = new DataTable();

            try
            {
                dt = cone.ObtenerDatos(String.Format("Select * from Materiales where Detalle ='{0}'", Material));
                if (dt.Rows.Count > 0)
                {
                    this.Cantidad   = Convert.ToSingle(dt.Rows[0]["Cantidad"]);
                    this.MaterialId = (int)dt.Rows[0]["MaterialId"];
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#21
0
        public override DataTable Listado(string Campos, string Condicion, string Orden)
        {
            DbVentana cone  = new DbVentana();
            DataTable dt    = new DataTable();
            string    campo = " '{0}'";

            string OrdenFinal = "";

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


            dt = cone.ObtenerDatos(String.Format("Select " + Campos + " from Usuarios " + Condicion + campo, Orden));

            if (dt.Rows.Count > 0)
            {
                this.Restriccion = (int)dt.Rows[0]["Restriccion"];
                this.UserName    = dt.Rows[0]["UserName"].ToString();
            }
            return(dt);
        }
示例#22
0
        public override bool Buscar(int IdBuscado)
        {
            DbVentana cone     = new DbVentana();
            DataTable dt       = new DataTable();
            bool      Retornar = true;

            try
            {
                dt = cone.ObtenerDatos(String.Format("Select * from Materiales where idMaterial = {0}", IdBuscado));
                if (dt.Rows.Count > 0)
                {
                    this.Detalle  = dt.Rows[0]["Detalle"].ToString();
                    this.Unidad   = dt.Rows[0]["Unidad"].ToString();
                    this.Cantidad = Convert.ToSingle(dt.Rows[0]["Cantidad"]);
                    this.Precio   = Convert.ToSingle(dt.Rows[0]["Precio"]);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Retornar);
        }