コード例 #1
0
        public ENTITY.Categoria[] getCategoriasDAL()
        {
            ConnectBBDD conexion = new ConnectBBDD();
            DataTable   res      = conexion.LeerPorComando($"select *  from categorias");

            if (res.Rows.Count > 0)
            {
                ENTITY.Categoria[] arrCategoria = new ENTITY.Categoria[res.Rows.Count];

                for (int i = 0; i < res.Rows.Count; i++)
                {
                    arrCategoria[i] = new ENTITY.Categoria(
                        res.Rows[i]["nombre"].ToString(),
                        Int32.Parse(res.Rows[i]["id"].ToString())

                        );
                }

                return(arrCategoria);
            }
            else
            {
                ENTITY.Categoria[] datoNull = null;
                return(datoNull);
            }
        }
コード例 #2
0
        public ENTITY.Roles[] getRolesDAL()
        {
            ConnectBBDD conexion = new ConnectBBDD();

            DataTable res = conexion.LeerPorComando($"select * from roles");

            if (res.Rows.Count > 0)
            {
                Roles[] arrUser = new Roles[res.Rows.Count];



                for (int i = 0; i < res.Rows.Count; i++)
                {
                    arrUser[i] = new Roles(int.Parse(res.Rows[i]["id"].ToString()), res.Rows[i]["nombre"].ToString());
                }

                return(arrUser);
            }
            else
            {
                Roles[] datoNull = null;
                return(datoNull);
            }
        }
コード例 #3
0
        public UserInfo[] GetusersDAL()
        {
            ConnectBBDD conexion = new ConnectBBDD();

            DataTable res = conexion.LeerPorComando($"select u.id,u.usuario,u.password,u.email,u.direccion,u.nombre,r.nombre as role  from usuarios as u, Roles  as r where r.id = u.id_role;");

            if (res.Rows.Count > 0)
            {
                UserInfo[] arrUser = new UserInfo[res.Rows.Count];



                for (int i = 0; i < res.Rows.Count; i++)
                {
                    arrUser[i] = new UserInfo(res.Rows[i]["usuario"].ToString(), res.Rows[i]["password"].ToString(), res.Rows[i]["role"].ToString(), res.Rows[i]["nombre"].ToString(), res.Rows[i]["email"].ToString(), res.Rows[i]["direccion"].ToString(), 0, int.Parse(res.Rows[i]["id"].ToString()));
                }

                return(arrUser);
            }
            else
            {
                UserInfo[] datoNull = null;
                return(datoNull);
            }
        }
コード例 #4
0
        public ENTITY.Sucursal[] SucursalesDAL()
        {
            ConnectBBDD conexion = new ConnectBBDD();



            DataTable res = conexion.LeerPorComando($"select * from Sucursales ");

            if (res.Rows.Count > 0)
            {
                ENTITY.Sucursal[] arrSucur = new ENTITY.Sucursal[res.Rows.Count];

                for (int i = 0; i < res.Rows.Count; i++)
                {
                    arrSucur[i] = new ENTITY.Sucursal(int.Parse(res.Rows[i]["id"].ToString()),
                                                      res.Rows[i]["razon_social"].ToString(),
                                                      res.Rows[i]["cuil"].ToString(),
                                                      res.Rows[i]["direccion"].ToString()
                                                      );
                }


                return(arrSucur);
            }
            else
            {
                ENTITY.Sucursal[] datoNull = null;
                return(datoNull);
            }
        }
コード例 #5
0
        public String[] CrearUsuarioDAL(UserInfo model)
        {
            ConnectBBDD conexion = new ConnectBBDD();

            if (model.id_sucursal != 0)
            {
                if (model.Usuario != null && model.Password != null & model.Role != null)
                {
                    if (conexion.EscribirPorComando($"INSERT INTO [dbo].[Empleados]([nombre],[password],[id_role],[id_sucursal],[usuario])VALUES('{model.Nombre}','{model.Password}',{int.Parse(model.Role)},{model.id_sucursal},'{model.Usuario}'); ") != 0)
                    {
                        return(new string[] { "OK", $"Usuario {model.Password}, creado" });
                    }
                    return(new string[] { "ERROR", "El usuario no se ah podido Crear" });
                }

                return(new string[] { "ERROR", "revise la entrada de datos al CrearUsuarioBLL" });
            }
            else
            {
                if (model.Usuario != null && model.Password != null & model.Role != null)
                {
                    if (conexion.EscribirPorComando($"INSERT INTO [dbo].[usuarios]([usuario],[password],[id_role],[nombre],[direccion],[email])VALUES('{model.Usuario}','{model.Password}',{model.Role},'{model.Email}','{model.Direccion}','{model.Nombre}'); ") != 0)
                    {
                        return(new string[] { "OK", $"Usuario {model.Password}, creado" });
                    }
                    return(new string[] { "ERROR", "El usuario no se ah podido Crear" });
                }

                return(new string[] { "ERROR", "revise la entrada de datos al CrearUsuarioBLL" });
            }
        }
コード例 #6
0
        public ENTITY.Auditoria[] ObtenerAuditoriaDAL()
        {
            ConnectBBDD conexion = new ConnectBBDD();

            DataTable res = conexion.LeerPorComando($"select a.Usuario usuario ,c.nombre 'nombrecompleto' ,b.nombre 'rol' , a.Modulo modelo,a.detalle,a.fecha_hora fechahora from Auditoria a , Roles b, Empleados c where a.id_empl = c.id_empl and b.id = a.role");

            if (res.Rows.Count > 0)
            {
                ENTITY.Auditoria[] arrAuditoria = new ENTITY.Auditoria[res.Rows.Count];



                for (int i = 0; i < res.Rows.Count; i++)
                {
                    arrAuditoria[i] = new ENTITY.Auditoria(res.Rows[i]["modelo"].ToString(), res.Rows[i]["usuario"].ToString(), res.Rows[i]["detalle"].ToString(), res.Rows[i]["fechahora"].ToString(), res.Rows[i]["nombrecompleto"].ToString(), res.Rows[i]["rol"].ToString());
                }

                return(arrAuditoria);
            }
            else
            {
                ENTITY.Auditoria[] datoNull = null;
                return(datoNull);
            }
        }
コード例 #7
0
        public ENTITY.Tarjeta[] GetTarjetasDAL(int id)
        {
            ConnectBBDD conexion = new ConnectBBDD();



            DataTable res = conexion.LeerPorComando($"select * from Tarjetas where id_usuario={id};");

            if (res.Rows.Count > 0)
            {
                ENTITY.Tarjeta[] arrEmpl = new ENTITY.Tarjeta[res.Rows.Count];



                for (int i = 0; i < res.Rows.Count; i++)
                {
                    arrEmpl[i] = new ENTITY.Tarjeta(res.Rows[i]["nTarjeta"].ToString(), int.Parse(res.Rows[i]["fechaVencimiento"].ToString()), res.Rows[i]["nombre"].ToString(), int.Parse(res.Rows[i]["pin"].ToString()), int.Parse(res.Rows[i]["id_usuario"].ToString()));
                }

                return(arrEmpl);
            }
            else
            {
                ENTITY.Tarjeta[] datoNull = null;
                return(datoNull);
            }
        }
コード例 #8
0
        public bool GrabarVenta(ENTITY.Venta venta)
        {
            ConnectBBDD conexion = new ConnectBBDD();
            string      a        = $"INSERT INTO [dbo].[Ventas]([id_empl],[id_usua],[Medio_Pago],[nombreClie],[cuilClie],[DireccionClie],[fecha],[total],[id_sucursal])VALUES({venta.Empleado.Id},{venta.Cliente.Id},'{venta.MedioDePago}','{venta.NombreCompletoClie}','{venta.CuilClie}','{venta.DireccionClie}',SYSDATETIME(),{venta.Total},{venta.Empleado.id_sucursal})";

            if (conexion.EscribirPorComando(a) > 0)
            {
                return(true);
            }

            return(false);
        }
コード例 #9
0
        public String eliminarEMPLDAL(int id)
        {
            ConnectBBDD conexion = new ConnectBBDD();

            int res = conexion.EscribirPorComando($"delete from empleados where id_empl = {id}");

            if (res > 0)
            {
                return("Empleado Eliminado correctamente.");
            }

            return("No se ah pido eliminar al usuario.");
        }
コード例 #10
0
        public UserInfo[] getEmplDAL(int id = 0)
        {
            ConnectBBDD conexion = new ConnectBBDD();

            if (!(id > 0))
            {
                DataTable res = conexion.LeerPorComando($"select Empleados.id_empl,Empleados.nombre,Empleados.usuario,Roles.nombre as 'rol',Sucursales.id as 'idsucursal' from Empleados , Roles, Sucursales where Empleados.id_role = Roles.id and Empleados.id_sucursal = Sucursales.id;");

                if (res.Rows.Count > 0)
                {
                    UserInfo[] arrEmpl = new UserInfo[res.Rows.Count];



                    for (int i = 0; i < res.Rows.Count; i++)
                    {
                        arrEmpl[i] = new UserInfo(res.Rows[i]["usuario"].ToString(), string.Empty, res.Rows[i]["rol"].ToString(), res.Rows[i]["nombre"].ToString() + " " + res.Rows[i]["usuario"].ToString(), string.Empty, string.Empty, int.Parse(res.Rows[i]["idsucursal"].ToString()), int.Parse(res.Rows[i]["id_empl"].ToString()));
                    }

                    return(arrEmpl);
                }
                else
                {
                    UserInfo[] datoNull = null;
                    return(datoNull);
                }
            }
            else
            {
                DataTable res = conexion.LeerPorComando($"select Empleados.id_empl, Empleados.password, Empleados.nombre,Empleados.usuario,Roles.nombre as 'rol',Sucursales.id as 'idsucursal' from Empleados , Roles, Sucursales where Empleados.id_role = Roles.id and Empleados.id_sucursal = Sucursales.id and Empleados.id_empl ={id};");

                if (res.Rows.Count > 0)
                {
                    UserInfo[] arrEmpl = new UserInfo[res.Rows.Count];



                    for (int i = 0; i < res.Rows.Count; i++)
                    {
                        arrEmpl[i] = new UserInfo(res.Rows[i]["usuario"].ToString(), res.Rows[i]["password"].ToString(), res.Rows[i]["rol"].ToString(), res.Rows[i]["nombre"].ToString(), string.Empty, string.Empty, int.Parse(res.Rows[i]["idsucursal"].ToString()), int.Parse(res.Rows[i]["id_empl"].ToString()));
                    }

                    return(arrEmpl);
                }
                else
                {
                    UserInfo[] datoNull = null;
                    return(datoNull);
                }
            }
        }
コード例 #11
0
        public string getPropertiePDUDAL(string Clave)
        {
            ConnectBBDD conexion = new ConnectBBDD();


            DataTable PDU = conexion.LeerPorComando($"select PDUVALOR from PDU where PDUCLAVE='{Clave}'");


            if ((PDU.Rows.Count > 0 && PDU.Rows[0]["PDUVALOR"].ToString() != string.Empty))
            {
                return(PDU.Rows[0]["PDUVALOR"].ToString());
            }
            return(null);
        }
コード例 #12
0
        public bool GrabarDetalle(ENTITY.DetalleVenta detalle)
        {
            ConnectBBDD conexion = new ConnectBBDD();
            DataTable   res      = conexion.LeerPorComando($"SELECT IDENT_CURRENT ('ventas') AS Current_Identity;");

            int idVenta = int.Parse(res.Rows[0]["Current_Identity"].ToString());


            if (conexion.EscribirPorComando($"INSERT INTO dbo.DetalleVenta(id_venta,id_producto,cantidad,valor) VALUES({idVenta},{detalle.producto.id},{detalle.Cantidad},{detalle.Valor})") > 0)
            {
                return(true);
            }

            return(false);
        }
コード例 #13
0
        public bool ConsultarUsuarioDAL(UserInfo model)
        {
            ConnectBBDD conexion = new ConnectBBDD();


            DataTable empleados = conexion.LeerPorComando($"select u.id_empl,u.usuario,u.password,u.nombre,r.nombre as role  from Empleados as u, Roles  as r where r.id = u.id_role and usuario='{model.Usuario}'");
            DataTable usuarios  = conexion.LeerPorComando($"select u.id,u.usuario,u.password,u.email,u.direccion,u.nombre,r.nombre as role  from usuarios as u, Roles  as r where r.id = u.id_role and usuario='{model.Usuario}'");


            if ((empleados.Rows.Count > 0 && empleados.Rows[0]["usuario"].ToString().Equals(model.Usuario)) || (usuarios.Rows.Count > 0 && usuarios.Rows[0]["usuario"].ToString().Equals(model.Usuario)))
            {
                return(true);
            }
            return(false);
        }
コード例 #14
0
        public bool loggearEnModuloAuditoria(ENTITY.Auditoria auditoria)
        {
            ConnectBBDD conexion = new ConnectBBDD();


            int insert = conexion.EscribirPorComando($"INSERT INTO Auditoria(Modulo,Usuario,detalle,fecha_hora,role,id_empl) VALUES('{auditoria.Modulo}','{auditoria.Usuario}','{auditoria.Detalle}',SYSDATETIME(),{auditoria.Role},{auditoria.Idempl})");

            if (insert > 0)
            {
                return(true);
            }


            return(false);
        }
コード例 #15
0
        public UserInfo EmplUpdateDAL(UserInfo user, int id)
        {
            ConnectBBDD conexion = new ConnectBBDD();

            string complemento = user.Password != string.Empty ? $", password = '******'" : "";



            int res = conexion.EscribirPorComando($"update Empleados set nombre = '{user.Nombre}'{complemento}, id_role ={ int.Parse(user.Role)},id_sucursal ={ user.id_sucursal}where id_empl = {id}");

            if (res > 0)
            {
                return(user);
            }
            return(null);
        }
コード例 #16
0
        public ENTITY.Sucursal CreateSucursalBLL(ENTITY.Sucursal sucursal)
        {
            ConnectBBDD conexion = new ConnectBBDD();


            //DataTable res = conexion.LeerPorComando($"select * from Sucursales ");

            //if (res.Rows.Count > 0) {
            //    ENTITY.Sucursal[] arrProduct = new ENTITY.Sucursal[res.Rows.Count];

            //    for (int i = 0; i < res.Rows.Count; i++) {
            //        arrProduct[i] = new ENTITY.Sucursal(
            //            res.Rows[i]["nombre"].ToString(),
            //            res.Rows[i]["detalle"].ToString(),
            //           float.Parse(res.Rows[i]["precio"].ToString()),
            //            Int32.Parse(res.Rows[i]["stock"].ToString()),
            //           Int32.Parse(res.Rows[i]["fecha"].ToString()),
            //           bool.Parse(res.Rows[i]["visible"].ToString()),
            //           Int32.Parse(res.Rows[i]["id"].ToString()),
            //           new Categoria(res.Rows[i]["categoria"].ToString(), Int32.Parse(res.Rows[i]["id__categoria"].ToString()))
            //            );
            //    }


            //    return arrProduct;

            //} else {
            //    ENTITY.Sucursal[] datoNull = null;
            //    return datoNull;

            //}


            if (sucursal.razonSocial != string.Empty && sucursal.Direccion != string.Empty && sucursal.Cuil != string.Empty)
            {
                if (conexion.EscribirPorComando($"INSERT INTO [dbo].[Sucursales] ([razon_social],[cuil],[direccion])VALUES('{sucursal.razonSocial}','{sucursal.Cuil}','{sucursal.Direccion}');") != 0)
                {
                    return(sucursal);
                }
                return(null);
            }

            return(null);
        }
コード例 #17
0
        public UserInfo LoginDAL(UserInfo model)
        {
            ConnectBBDD conexion = new ConnectBBDD();
            DataTable   res      = conexion.LeerPorComando($"select u.id,u.usuario,u.password,u.email,u.direccion,u.nombre,r.nombre as role  from usuarios as u, Roles  as r where r.id = u.id_role and usuario='{model.Usuario}'");
            DataTable   resempl  = conexion.LeerPorComando($"select u.id_empl,u.usuario,u.password,u.nombre,r.nombre as role ,u.id_sucursal  from Empleados as u, Roles  as r  where r.id = u.id_role and usuario='{model.Usuario}'");

            if (res.Rows.Count > 0)
            {
                return(new UserInfo(res.Rows[0]["usuario"].ToString(), res.Rows[0]["password"].ToString(), res.Rows[0]["role"].ToString(), res.Rows[0]["nombre"].ToString(), res.Rows[0]["email"].ToString(), res.Rows[0]["direccion"].ToString(), 0, int.Parse(res.Rows[0]["id"].ToString())));
            }
            else if (resempl.Rows.Count > 0)
            {
                return(new UserInfo(resempl.Rows[0]["usuario"].ToString(), resempl.Rows[0]["password"].ToString(), resempl.Rows[0]["role"].ToString(), resempl.Rows[0]["nombre"].ToString(), string.Empty, string.Empty, int.Parse(resempl.Rows[0]["id_sucursal"].ToString()), int.Parse(resempl.Rows[0]["id_empl"].ToString())));
            }
            else
            {
                UserInfo datoNull = null;
                return(datoNull);
            }
        }
コード例 #18
0
        public ENTITY.Producto[] getProductoDAL(int id = 0)
        {
            ConnectBBDD conexion = new ConnectBBDD();

            if (id > 0)
            {
                DataTable res = conexion.LeerPorComando($"select b.nombre,b.precio,b.detalle,b.imgurl ,b.visible,b.fecha,b.id,r.stock,c.nombre as categoria ,c.id as id__categoria from productos b, ProductoSucursalRela r, Sucursales s , Categorias c where b.id = r.id_producto and s.id = r.id_sucursal and b.id_Categoria = c.id and r.id_sucursal = {id}");

                if (res.Rows.Count > 0)
                {
                    ENTITY.Producto[] arrProduct = new ENTITY.Producto[res.Rows.Count];

                    for (int i = 0; i < res.Rows.Count; i++)
                    {
                        arrProduct[i] = new ENTITY.Producto(
                            res.Rows[i]["nombre"].ToString(),
                            res.Rows[i]["detalle"].ToString(),
                            float.Parse(res.Rows[i]["precio"].ToString()),
                            Int32.Parse(res.Rows[i]["stock"].ToString()),
                            Int32.Parse(res.Rows[i]["fecha"].ToString()),
                            bool.Parse(res.Rows[i]["visible"].ToString()),
                            Int32.Parse(res.Rows[i]["id"].ToString()),
                            new Categoria(res.Rows[i]["categoria"].ToString(), Int32.Parse(res.Rows[i]["id__categoria"].ToString())),
                            res.Rows[i]["imgurl"].ToString()
                            );
                    }


                    return(arrProduct);
                }
                else
                {
                    ENTITY.Producto[] datoNull = null;
                    return(datoNull);
                }
            }
            else
            {
                DataTable res = conexion.LeerPorComando($"select a.detalle,a.fecha, a.imgurl,a.id,a.nombre,a.precio,a.stock,a.visible,b.nombre as categoria,b.id as id__categoria from productos as a, categorias as b  where a.id_Categoria = b.id");

                if (res.Rows.Count > 0)
                {
                    ENTITY.Producto[] arrProduct = new ENTITY.Producto[res.Rows.Count];

                    for (int i = 0; i < res.Rows.Count; i++)
                    {
                        arrProduct[i] = new ENTITY.Producto(
                            res.Rows[i]["nombre"].ToString(),
                            res.Rows[i]["detalle"].ToString(),
                            float.Parse(res.Rows[i]["precio"].ToString()),
                            Int32.Parse(res.Rows[i]["stock"].ToString()),
                            Int32.Parse(res.Rows[i]["fecha"].ToString()),
                            bool.Parse(res.Rows[i]["visible"].ToString()),
                            Int32.Parse(res.Rows[i]["id"].ToString()),
                            new Categoria(res.Rows[i]["categoria"].ToString(), Int32.Parse(res.Rows[i]["id__categoria"].ToString())),
                            res.Rows[i]["imgurl"].ToString()

                            );
                    }


                    return(arrProduct);
                }
                else
                {
                    ENTITY.Producto[] datoNull = null;
                    return(datoNull);
                }
            }
        }