Ejemplo n.º 1
0
        public void DeleteTienda()
        {
            tienda objTienda          = new tienda();
            tienda objTiendaVerificar = new tienda();
            int    tiendaID           = Convert.ToInt32(comboBox1.SelectedValue);
            string nombreTienda       = txtN.Text.ToString();

            using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
            {
                objTiendaVerificar = VerificarTiendaEntidad.tiendas.Where(s => s.nombre == nombreTienda).FirstOrDefault <tienda>();
            }

            if (objTiendaVerificar != null)
            {
                using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
                {
                    objTienda = TiendaEntidad.tiendas.Where(s => s.id_tienda == tiendaID).FirstOrDefault <tienda>();
                    TiendaEntidad.Set <tienda>().Remove(objTienda);
                    TiendaEntidad.SaveChanges();
                }

                HideButtom();
                ShowNotification("Su registro a sido Eliminado!");
            }
            else
            {
                ShowNotification("El registro no Existe!");
            }
        }
Ejemplo n.º 2
0
        public void DeleteClientes()
        {
            int     idCliente          = Convert.ToInt32(comboBox1.SelectedValue);
            cliente objTiendaVerificar = new cliente();

            using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
            {
                objTiendaVerificar = VerificarTiendaEntidad.clientes.Where(s => s.id_cliente == idCliente).FirstOrDefault <cliente>();
            }

            if (objTiendaVerificar != null)
            {
                using (agrosysEntitiesFull ClienteEntidad = new agrosysEntitiesFull())
                {
                    objTiendaVerificar = ClienteEntidad.clientes.Where(s => s.id_cliente == idCliente).FirstOrDefault <cliente>();
                    ClienteEntidad.Set <cliente>().Remove(objTiendaVerificar);
                    ClienteEntidad.SaveChanges();
                }

                HideButtom();
                ShowNotification("Su registro a sido Eliminado!");
            }
            else
            {
                ShowNotification("El registro no Existe!");
            }
        }
Ejemplo n.º 3
0
        public void DeleteProductos()
        {
            int idProductos = Convert.ToInt32(comboBox2.SelectedValue);
            producto objTiendaVerificar = new producto();

            using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
            {
                objTiendaVerificar = VerificarTiendaEntidad.productoes.Where(s => s.id_producto == idProductos).FirstOrDefault<producto>();
            }

            if (objTiendaVerificar != null)
            {
                using (agrosysEntitiesFull ProveedorEntidad = new agrosysEntitiesFull())
                {
                    objTiendaVerificar = ProveedorEntidad.productoes.Where(s => s.id_producto == idProductos).FirstOrDefault<producto>();
                    ProveedorEntidad.Set<producto>().Remove(objTiendaVerificar);
                    ProveedorEntidad.SaveChanges();
                }
                ShowNotification("Su registro a sido Eliminado!");
                HideButtom();
            }
            else
            {
                ShowNotification("El registro no Existe!");
            }
        }
Ejemplo n.º 4
0
        public void DeleteProductos()
        {
            int      idProductos        = Convert.ToInt32(comboBox2.SelectedValue);
            producto objTiendaVerificar = new producto();

            using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
            {
                objTiendaVerificar = VerificarTiendaEntidad.productoes.Where(s => s.id_producto == idProductos).FirstOrDefault <producto>();
            }

            if (objTiendaVerificar != null)
            {
                using (agrosysEntitiesFull ProveedorEntidad = new agrosysEntitiesFull())
                {
                    objTiendaVerificar = ProveedorEntidad.productoes.Where(s => s.id_producto == idProductos).FirstOrDefault <producto>();
                    ProveedorEntidad.Set <producto>().Remove(objTiendaVerificar);
                    ProveedorEntidad.SaveChanges();
                }
                ShowNotification("Su registro a sido Eliminado!");
                HideButtom();
            }
            else
            {
                ShowNotification("El registro no Existe!");
            }
        }
Ejemplo n.º 5
0
        public void SetTienda(string nombre, string direccion, string telefono)
        {
            try
            {
                tienda objTiendaVerificar = new tienda();
                using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
                {
                    objTiendaVerificar = VerificarTiendaEntidad.tiendas.Where(s => s.nombre == nombre).FirstOrDefault <tienda>();
                }

                if (objTiendaVerificar == null)
                {
                    using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
                    {
                        tienda objTienda = new tienda();
                        objTienda.nombre    = nombre;
                        objTienda.telefono  = telefono;
                        objTienda.direccion = direccion;

                        TiendaEntidad.tiendas.Add(objTienda);
                        TiendaEntidad.SaveChanges();
                        string mensaje = "La tienda con el nombre " + nombre + " a sido guardada";
                        ShowNotification(mensaje);
                    }
                }
                else
                {
                    ShowNotification("No se a podido guardar el registro");
                }
            }
            catch (Exception)
            {
                throw new Exception("Hay un problema al guardar la tienda, por favor intente de nuevo.");
            }
        }
Ejemplo n.º 6
0
        public void DeleteClientes()
        {
            int  idCliente = Convert.ToInt32( comboBox1.SelectedValue);
               cliente objTiendaVerificar = new cliente();

            using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
            {
                objTiendaVerificar = VerificarTiendaEntidad.clientes.Where(s => s.id_cliente == idCliente).FirstOrDefault<cliente>();
            }

            if (objTiendaVerificar != null)
            {
                using (agrosysEntitiesFull ClienteEntidad = new agrosysEntitiesFull())
                {
                    objTiendaVerificar = ClienteEntidad.clientes.Where(s => s.id_cliente == idCliente).FirstOrDefault<cliente>();
                    ClienteEntidad.Set<cliente>().Remove(objTiendaVerificar);
                    ClienteEntidad.SaveChanges();
                }

                HideButtom();
                ShowNotification("Su registro a sido Eliminado!");
            }
            else
            {
                ShowNotification("El registro no Existe!");
            }
        }
Ejemplo n.º 7
0
        public void DeleteEmpleados()
        {
            int  idempleado = Convert.ToInt32( comboBox1.SelectedValue);
               empleado objTiendaVerificar = new empleado();

            using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
            {
                objTiendaVerificar = VerificarTiendaEntidad.empleadoes.Where(s => s.id_empleado == idempleado).FirstOrDefault<empleado>();
            }

            if (objTiendaVerificar != null)
            {
                using (agrosysEntitiesFull empleadoEntidad = new agrosysEntitiesFull())
                {
                    objTiendaVerificar = empleadoEntidad.empleadoes.Where(s => s.id_empleado == idempleado).FirstOrDefault<empleado>();
                    empleadoEntidad.Set<empleado>().Remove(objTiendaVerificar);
                    empleadoEntidad.SaveChanges();
                }

                HideButtom();
                ShowNotification("Su registro a sido Eliminado!");
            }
            else
            {
                ShowNotification("El registro no Existe!");
            }
        }
Ejemplo n.º 8
0
        public void UpdateTienda(string nombreTienda, int tiendaID)
        {
            tienda objTienda          = new tienda();
            tienda objTiendaVerificar = new tienda();


            using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
            {
                objTiendaVerificar = VerificarTiendaEntidad.tiendas.Where(s => s.nombre == nombreTienda).FirstOrDefault <tienda>();
            }

            if (objTiendaVerificar == null)
            {
                using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
                {
                    objTienda = TiendaEntidad.tiendas.Where(s => s.id_tienda == tiendaID).FirstOrDefault <tienda>();
                }

                objTienda.nombre    = txtN.Text.ToString();
                objTienda.direccion = txtD.Text.ToString();
                objTienda.telefono  = txtT.Text.ToString();

                using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
                {
                    TiendaEntidad.Entry(objTienda).State = System.Data.EntityState.Modified;
                    TiendaEntidad.SaveChanges();
                }
                HideButtom();
                ShowNotification("Su registro a sido actualizado!");
            }
            else
            {
                ShowNotification("Ya existe una tienda con ese nomnbre!");
            }
        }
Ejemplo n.º 9
0
        public void DeleteTienda()
        {
            tienda objTienda = new tienda();
            tienda objTiendaVerificar = new tienda();
            int tiendaID = Convert.ToInt32(comboBox1.SelectedValue);
            string nombreTienda = txtN.Text.ToString();

            using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
            {
                objTiendaVerificar = VerificarTiendaEntidad.tiendas.Where(s => s.nombre == nombreTienda).FirstOrDefault<tienda>();
            }

            if (objTiendaVerificar != null)
            {
                using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
                {
                    objTienda = TiendaEntidad.tiendas.Where(s => s.id_tienda == tiendaID).FirstOrDefault<tienda>();
                    TiendaEntidad.Set<tienda>().Remove(objTienda);
                    TiendaEntidad.SaveChanges();
                }

                HideButtom();
                ShowNotification("Su registro a sido Eliminado!");
            }
            else
            {
                ShowNotification("El registro no Existe!");
            }
        }
Ejemplo n.º 10
0
        public void DeleteEmpleados()
        {
            int      idempleado         = Convert.ToInt32(comboBox1.SelectedValue);
            empleado objTiendaVerificar = new empleado();

            using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
            {
                objTiendaVerificar = VerificarTiendaEntidad.empleadoes.Where(s => s.id_empleado == idempleado).FirstOrDefault <empleado>();
            }

            if (objTiendaVerificar != null)
            {
                using (agrosysEntitiesFull empleadoEntidad = new agrosysEntitiesFull())
                {
                    objTiendaVerificar = empleadoEntidad.empleadoes.Where(s => s.id_empleado == idempleado).FirstOrDefault <empleado>();
                    empleadoEntidad.Set <empleado>().Remove(objTiendaVerificar);
                    empleadoEntidad.SaveChanges();
                }

                HideButtom();
                ShowNotification("Su registro a sido Eliminado!");
            }
            else
            {
                ShowNotification("El registro no Existe!");
            }
        }
Ejemplo n.º 11
0
        public void SetUsuarios(string nombre, string password, int rolID, int empleadoID)
        {
            try
            {
                usuario objTiendaVerificar = new usuario();
                using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
                {
                    objTiendaVerificar = VerificarTiendaEntidad.usuarios.Where(s => s.nombre_usuario == nombre).FirstOrDefault<usuario>();
                }

                if (objTiendaVerificar == null)
                {

                    using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
                    {
                        usuario objusuarios = new usuario();
                        string md5Password;

                        using (MD5 md5Hash = MD5.Create())
                        {
                           md5Password= GetMd5Hash(md5Hash, password);
                        }
                        objusuarios.nombre_usuario = nombre;
                        objusuarios.password = md5Password;
                        objusuarios.rol_id_rol = rolID;
                        objusuarios.empleado_id_empleado = empleadoID;

                        TiendaEntidad.usuarios.Add(objusuarios);
                        TiendaEntidad.SaveChanges();
                        string mensaje = "El usuaris con el Nombre " + nombre + " a sido guardado";
                        ShowNotification(mensaje);
                    }
                }
                else
                {
                    ShowNotification("No se a podido guardar el registro");
                }

            }
            catch (Exception)
            {
                throw new Exception("Hay un problema al guardar la tienda, por favor intente de nuevo.");
            }
        }
Ejemplo n.º 12
0
        public void SetClientes(string primerNombre, string segundoNombre, string primerApellido, string segundoApellido, string telefono, string direccion,string nit , string dpi)
        {
            try
            {
                cliente objTiendaVerificar = new cliente();
                using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
                {
                    objTiendaVerificar = VerificarTiendaEntidad.clientes.Where(s => s.nit == nit).FirstOrDefault<cliente>();
                }

                if (objTiendaVerificar == null)
                {
                    using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
                    {
                        cliente objCliente = new cliente();

                        objCliente.primer_nombre = primerNombre;
                        objCliente.segundo_nombre = segundoNombre;
                        objCliente.primer_apellido = primerApellido;
                        objCliente.segundo_apellido = segundoApellido;
                        objCliente.nit = nit;
                        objCliente.telefono = telefono;
                        objCliente.direccion = direccion;
                        objCliente.dpi = dpi;

                        TiendaEntidad.clientes.Add(objCliente);
                        TiendaEntidad.SaveChanges();
                        string mensaje = "El cliente con el NIT " + nit + " a sido guardado";
                        ShowNotification(mensaje);
                    }
                }
                else
                {
                    ShowNotification("No se a podido guardar el registro");
                }

            }
            catch (Exception)
            {
                throw new Exception("Hay un problema al guardar la tienda, por favor intente de nuevo.");
            }
        }
Ejemplo n.º 13
0
        public void SetEmpleados(string primerNombre, string segundoNombre, string primerApellido, string segundoApellido, string telefono, string direccion, string nit, string dpi, int tiendaId)
        {
            try
            {
                empleado objEmpleadoVerificar = new empleado();
                using (agrosysEntitiesFull VerificarEmpleadoEntidad = new agrosysEntitiesFull())
                {
                    objEmpleadoVerificar = VerificarEmpleadoEntidad.empleadoes.Where(s => s.nit == nit || s.dpi == dpi).FirstOrDefault<empleado>();
                }

                if (objEmpleadoVerificar == null)
                {
                    using (agrosysEntitiesFull EmpleadoEntidad = new agrosysEntitiesFull())
                    {
                        empleado objEmpleado = new empleado();

                        objEmpleado.primer_nombre = primerNombre;
                        objEmpleado.segundo_nombre = segundoNombre;
                        objEmpleado.primer_apellido = primerApellido;
                        objEmpleado.segundo_apellido = segundoApellido;
                        objEmpleado.nit = nit;
                        objEmpleado.telefono = telefono;
                        objEmpleado.direccion = direccion;
                        objEmpleado.dpi = dpi;
                        objEmpleado.tienda_id_tienda = tiendaId;
                        EmpleadoEntidad.empleadoes.Add(objEmpleado);
                        EmpleadoEntidad.SaveChanges();
                        string mensaje = "El Empleado con el NIT " + nit + " a sido guardado";
                        ShowNotification(mensaje);
                    }
                }
                else
                {
                    ShowNotification("No se a podido guardar el registro");
                }

            }
            catch (Exception)
            {
                throw new Exception("Hay un problema al guardar la tienda, por favor intente de nuevo.");
            }
        }
Ejemplo n.º 14
0
        public void SetUsuarios(string nombre, string password, int rolID, int empleadoID)
        {
            try
            {
                usuario objTiendaVerificar = new usuario();
                using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
                {
                    objTiendaVerificar = VerificarTiendaEntidad.usuarios.Where(s => s.nombre_usuario == nombre).FirstOrDefault <usuario>();
                }

                if (objTiendaVerificar == null)
                {
                    using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
                    {
                        usuario objusuarios = new usuario();
                        string  md5Password;

                        using (MD5 md5Hash = MD5.Create())
                        {
                            md5Password = GetMd5Hash(md5Hash, password);
                        }
                        objusuarios.nombre_usuario       = nombre;
                        objusuarios.password             = md5Password;
                        objusuarios.rol_id_rol           = rolID;
                        objusuarios.empleado_id_empleado = empleadoID;

                        TiendaEntidad.usuarios.Add(objusuarios);
                        TiendaEntidad.SaveChanges();
                        string mensaje = "El usuaris con el Nombre " + nombre + " a sido guardado";
                        ShowNotification(mensaje);
                    }
                }
                else
                {
                    ShowNotification("No se a podido guardar el registro");
                }
            }
            catch (Exception)
            {
                throw new Exception("Hay un problema al guardar la tienda, por favor intente de nuevo.");
            }
        }
Ejemplo n.º 15
0
        public void SetClientes(string primerNombre, string segundoNombre, string primerApellido, string segundoApellido, string telefono, string direccion, string nit, string dpi)
        {
            try
            {
                cliente objTiendaVerificar = new cliente();
                using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
                {
                    objTiendaVerificar = VerificarTiendaEntidad.clientes.Where(s => s.nit == nit).FirstOrDefault <cliente>();
                }

                if (objTiendaVerificar == null)
                {
                    using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
                    {
                        cliente objCliente = new cliente();

                        objCliente.primer_nombre    = primerNombre;
                        objCliente.segundo_nombre   = segundoNombre;
                        objCliente.primer_apellido  = primerApellido;
                        objCliente.segundo_apellido = segundoApellido;
                        objCliente.nit       = nit;
                        objCliente.telefono  = telefono;
                        objCliente.direccion = direccion;
                        objCliente.dpi       = dpi;

                        TiendaEntidad.clientes.Add(objCliente);
                        TiendaEntidad.SaveChanges();
                        string mensaje = "El cliente con el NIT " + nit + " a sido guardado";
                        ShowNotification(mensaje);
                    }
                }
                else
                {
                    ShowNotification("No se a podido guardar el registro");
                }
            }
            catch (Exception)
            {
                throw new Exception("Hay un problema al guardar la tienda, por favor intente de nuevo.");
            }
        }
Ejemplo n.º 16
0
        public void UpdateCliente(string NITCliente, int clienteID, string dpi)
        {
            cliente objCliente         = new cliente();
            cliente objTiendaVerificar = new cliente();


            using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
            {
                objTiendaVerificar = VerificarTiendaEntidad.clientes
                                     .Where(s => s.id_cliente != clienteID && (s.nit == NITCliente || s.dpi == dpi))
                                     .FirstOrDefault <cliente>();
            }
            if (objTiendaVerificar == null)
            {
                using (agrosysEntitiesFull ClienteEntidad = new agrosysEntitiesFull())
                {
                    objCliente = ClienteEntidad.clientes.Where(s => s.id_cliente == clienteID).FirstOrDefault <cliente>();
                }

                objCliente.primer_nombre    = txtN.Text.ToString();
                objCliente.segundo_nombre   = txtN2.Text.ToString();
                objCliente.primer_apellido  = txtA.Text.ToString();
                objCliente.segundo_apellido = txtA2.Text.ToString();
                objCliente.telefono         = txtT.Text.ToString();
                objCliente.nit       = txtNIT.Text.ToString();
                objCliente.direccion = txtNIT.Text.ToString();
                objCliente.dpi       = txtDPI.Text.ToString();

                using (agrosysEntitiesFull ClienteEntidad = new agrosysEntitiesFull())
                {
                    ClienteEntidad.Entry(objCliente).State = System.Data.EntityState.Modified;
                    ClienteEntidad.SaveChanges();
                }
                HideButtom();
                ShowNotification("Su registro a sido actualizado!");
            }
            else
            {
                ShowNotification("Ya existe cliente  con ese NIT!");
            }
        }
Ejemplo n.º 17
0
        public void SetEmpleados(string primerNombre, string segundoNombre, string primerApellido, string segundoApellido, string telefono, string direccion, string nit, string dpi, int tiendaId)
        {
            try
            {
                empleado objEmpleadoVerificar = new empleado();
                using (agrosysEntitiesFull VerificarEmpleadoEntidad = new agrosysEntitiesFull())
                {
                    objEmpleadoVerificar = VerificarEmpleadoEntidad.empleadoes.Where(s => s.nit == nit || s.dpi == dpi).FirstOrDefault <empleado>();
                }

                if (objEmpleadoVerificar == null)
                {
                    using (agrosysEntitiesFull EmpleadoEntidad = new agrosysEntitiesFull())
                    {
                        empleado objEmpleado = new empleado();

                        objEmpleado.primer_nombre    = primerNombre;
                        objEmpleado.segundo_nombre   = segundoNombre;
                        objEmpleado.primer_apellido  = primerApellido;
                        objEmpleado.segundo_apellido = segundoApellido;
                        objEmpleado.nit              = nit;
                        objEmpleado.telefono         = telefono;
                        objEmpleado.direccion        = direccion;
                        objEmpleado.dpi              = dpi;
                        objEmpleado.tienda_id_tienda = tiendaId;
                        EmpleadoEntidad.empleadoes.Add(objEmpleado);
                        EmpleadoEntidad.SaveChanges();
                        string mensaje = "El Empleado con el NIT " + nit + " a sido guardado";
                        ShowNotification(mensaje);
                    }
                }
                else
                {
                    ShowNotification("No se a podido guardar el registro");
                }
            }
            catch (Exception)
            {
                throw new Exception("Hay un problema al guardar la tienda, por favor intente de nuevo.");
            }
        }
Ejemplo n.º 18
0
        public void UpdateProducto(string nombre, string detalle, string precio, int productoID, int proveedorID)
        {
            producto objproducto        = new producto();
            producto objTiendaVerificar = new producto();


            using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
            {
                objTiendaVerificar = VerificarTiendaEntidad.productoes
                                     .Where(s => s.id_producto != productoID && (s.nombre_producto == nombre))
                                     .FirstOrDefault <producto>();
            }
            if (objTiendaVerificar == null)
            {
                using (agrosysEntitiesFull productoEntidad = new agrosysEntitiesFull())
                {
                    objproducto = productoEntidad.productoes.Where(s => s.id_producto == productoID).FirstOrDefault <producto>();
                }
                int tiendaId = Convert.ToInt32(comboBox1.SelectedValue);
                objproducto.nombre_producto        = nombre;
                objproducto.precio                 = precio;
                objproducto.detalle_producto       = detalle;
                objproducto.proveedor_id_proveedor = proveedorID;


                using (agrosysEntitiesFull productoEntidad = new agrosysEntitiesFull())
                {
                    productoEntidad.Entry(objproducto).State           = System.Data.EntityState.Modified;
                    productoEntidad.Entry(objproducto.proveedor).State = System.Data.EntityState.Modified;
                    productoEntidad.SaveChanges();
                }
                HideButtom();
                ShowNotification("Su registro a sido actualizado!");
            }
            else
            {
                ShowNotification("Ya existe producto  con ese Nombre!");
            }
        }
Ejemplo n.º 19
0
        public void SetProveedores(string nombre, string direccion, string telefono, string nit)
        {
            try
            {
                proveedor objProveedorVerificar = new proveedor();
                using (agrosysEntitiesFull VerificarProveedorEntidad = new agrosysEntitiesFull())
                {
                    objProveedorVerificar = VerificarProveedorEntidad.proveedors.Where(s => s.nombre_proveedor == nombre || s.nit == nit).FirstOrDefault<proveedor>();
                }

                if (objProveedorVerificar == null)
                {
                    using (agrosysEntitiesFull ProveedorEntidad = new agrosysEntitiesFull())
                    {
                        proveedor objProveedor = new proveedor();

                        objProveedor.nombre_proveedor = nombre;
                        objProveedor.nit = nit;
                        objProveedor.telefono = telefono;
                        objProveedor.direccion = direccion;
                        ProveedorEntidad.proveedors.Add(objProveedor);
                        ProveedorEntidad.SaveChanges();
                        string mensaje = "El proveedor con el NIT " + nit + " a sido guardado";
                        ShowNotification(mensaje);
                        CleanInputs();

                    }
                }
                else
                {
                    ShowNotification("No se a podido guardar el registro");
                }

            }
            catch (Exception)
            {
                throw new Exception("Hay un problema al guardar la Proveedor, por favor intente de nuevo.");
            }
        }
Ejemplo n.º 20
0
        public void SetFactura(string subTotal, string total, string iva, int clienteID)
        {
            try
            {
                using (agrosysEntitiesFull facturaEntidad = new agrosysEntitiesFull())
                {
                    //se guarda la factura
                    factura objfactura = new factura();

                    objfactura.sub_total          = subTotal;
                    objfactura.iva                = iva;
                    objfactura.total              = total;
                    objfactura.cliente_id_cliente = clienteID;
                    facturaEntidad.facturas.Add(objfactura);
                    facturaEntidad.SaveChanges();
                }
            }
            catch (Exception)
            {
                throw new Exception("Hay un problema al guardar la tienda, por favor intente de nuevo.");
            }
        }
Ejemplo n.º 21
0
        public void SetProductos(string nombre, string detalle,string precio, int proveedorID)
        {
            try
            {
                producto objTiendaVerificar = new producto();
                using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
                {
                    objTiendaVerificar = VerificarTiendaEntidad.productoes.Where(s => s.nombre_producto == nombre).FirstOrDefault<producto>();
                }

                if (objTiendaVerificar == null)
                {
                    using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
                    {
                        producto objProducto = new producto();

                        objProducto.nombre_producto = nombre;
                        objProducto.precio = precio;
                        objProducto.detalle_producto = detalle;
                        objProducto.proveedor_id_proveedor = proveedorID;

                        TiendaEntidad.productoes.Add(objProducto);
                        TiendaEntidad.SaveChanges();
                        string mensaje = "El Producto con el Nombre " + nombre + " a sido guardado";
                        ShowNotification(mensaje);
                    }
                }
                else
                {
                    ShowNotification("No se a podido guardar el registro");
                }

            }
            catch (Exception)
            {
                throw new Exception("Hay un problema al guardar la tienda, por favor intente de nuevo.");
            }
        }
Ejemplo n.º 22
0
 public void setDetalleFactura()
 {
     try
     {
         for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
         {
             using (agrosysEntitiesFull facturaEntidad = new agrosysEntitiesFull())
             {
                 detalle_factura objDetalleFactura = new detalle_factura();
                 objDetalleFactura.cantidad             = Convert.ToInt32(ds.Tables[0].Rows[i]["cantidad"]);
                 objDetalleFactura.sub_total            = ds.Tables[0].Rows[i]["subTotal"].ToString();
                 objDetalleFactura.factura_id_factura   = Convert.ToInt32(ds.Tables[0].Rows[i]["facturaID"]);
                 objDetalleFactura.producto_id_producto = Convert.ToInt32(ds.Tables[0].Rows[i]["productoID"]);
                 facturaEntidad.detalle_factura.Add(objDetalleFactura);
                 facturaEntidad.SaveChanges();
             }
         }
     }
     catch (Exception)
     {
         throw new Exception("Hay un problema al guardar la factura, por favor intente de nuevo.");
     }
 }
Ejemplo n.º 23
0
        public bool SetTienda(string nombre, string direccion, string telefono)
        {
            try
            {
                using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
                {
                    tienda objTienda = new tienda();
                    objTienda.nombre    = nombre;
                    objTienda.telefono  = telefono;
                    objTienda.direccion = direccion;

                    TiendaEntidad.tiendas.Add(objTienda);
                    TiendaEntidad.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);

                throw new Exception("Hay un problema al guardar la tienda, por favor intente de nuevo.");
            }
        }
Ejemplo n.º 24
0
        public bool SetTienda(string nombre , string direccion, string telefono )
        {
            try
            {
                using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
                {
                    tienda objTienda = new tienda();
                    objTienda.nombre = nombre;
                    objTienda.telefono = telefono;
                    objTienda.direccion = direccion;

                    TiendaEntidad.tiendas.Add(objTienda);
                    TiendaEntidad.SaveChanges();

                }
                return true;
            }
            catch (Exception)
            {
                return false;
                throw new Exception("Hay un problema al guardar la tienda, por favor intente de nuevo.");
            }
        }
Ejemplo n.º 25
0
        public void UpdateProveedor(string NITproveedor, int proveedorID)
        {
            proveedor objProveedor          = new proveedor();
            proveedor objProveedorVerificar = new proveedor();


            using (agrosysEntitiesFull VerificarProveedorEntidad = new agrosysEntitiesFull())
            {
                objProveedorVerificar = VerificarProveedorEntidad.proveedors
                                        .Where(s => s.id_proveedor != proveedorID || s.nit == NITproveedor)
                                        .FirstOrDefault <proveedor>();
            }
            if (objProveedorVerificar == null)
            {
                using (agrosysEntitiesFull proveedorEntidad = new agrosysEntitiesFull())
                {
                    objProveedor = proveedorEntidad.proveedors.Where(s => s.id_proveedor == proveedorID).FirstOrDefault <proveedor>();
                }

                objProveedor.nombre_proveedor = txtN.Text.ToString();
                objProveedor.telefono         = txtT.Text.ToString();
                objProveedor.nit       = txtNIT.Text.ToString();
                objProveedor.direccion = txtD.Text.ToString();

                using (agrosysEntitiesFull proveedorEntidad = new agrosysEntitiesFull())
                {
                    proveedorEntidad.Entry(objProveedor).State = System.Data.EntityState.Modified;
                    proveedorEntidad.SaveChanges();
                }

                ShowNotification("Su registro a sido actualizado!");
            }
            else
            {
                ShowNotification("Ya existe proveedor  con ese NIT!");
            }
        }
Ejemplo n.º 26
0
        public void SetProveedores(string nombre, string direccion, string telefono, string nit)
        {
            try
            {
                proveedor objProveedorVerificar = new proveedor();
                using (agrosysEntitiesFull VerificarProveedorEntidad = new agrosysEntitiesFull())
                {
                    objProveedorVerificar = VerificarProveedorEntidad.proveedors.Where(s => s.nombre_proveedor == nombre || s.nit == nit).FirstOrDefault <proveedor>();
                }

                if (objProveedorVerificar == null)
                {
                    using (agrosysEntitiesFull ProveedorEntidad = new agrosysEntitiesFull())
                    {
                        proveedor objProveedor = new proveedor();

                        objProveedor.nombre_proveedor = nombre;
                        objProveedor.nit       = nit;
                        objProveedor.telefono  = telefono;
                        objProveedor.direccion = direccion;
                        ProveedorEntidad.proveedors.Add(objProveedor);
                        ProveedorEntidad.SaveChanges();
                        string mensaje = "El proveedor con el NIT " + nit + " a sido guardado";
                        ShowNotification(mensaje);
                        CleanInputs();
                    }
                }
                else
                {
                    ShowNotification("No se a podido guardar el registro");
                }
            }
            catch (Exception)
            {
                throw new Exception("Hay un problema al guardar la Proveedor, por favor intente de nuevo.");
            }
        }
Ejemplo n.º 27
0
        public void SetProductos(string nombre, string detalle, string precio, int proveedorID)
        {
            try
            {
                producto objTiendaVerificar = new producto();
                using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
                {
                    objTiendaVerificar = VerificarTiendaEntidad.productoes.Where(s => s.nombre_producto == nombre).FirstOrDefault <producto>();
                }

                if (objTiendaVerificar == null)
                {
                    using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
                    {
                        producto objProducto = new producto();

                        objProducto.nombre_producto        = nombre;
                        objProducto.precio                 = precio;
                        objProducto.detalle_producto       = detalle;
                        objProducto.proveedor_id_proveedor = proveedorID;

                        TiendaEntidad.productoes.Add(objProducto);
                        TiendaEntidad.SaveChanges();
                        string mensaje = "El Producto con el Nombre " + nombre + " a sido guardado";
                        ShowNotification(mensaje);
                    }
                }
                else
                {
                    ShowNotification("No se a podido guardar el registro");
                }
            }
            catch (Exception)
            {
                throw new Exception("Hay un problema al guardar la tienda, por favor intente de nuevo.");
            }
        }
Ejemplo n.º 28
0
        public void UpdateProveedor(string NITproveedor, int proveedorID)
        {
            proveedor objProveedor = new proveedor();
            proveedor objProveedorVerificar = new proveedor();

            using (agrosysEntitiesFull VerificarProveedorEntidad = new agrosysEntitiesFull())
            {
                objProveedorVerificar = VerificarProveedorEntidad.proveedors
                    .Where(s => s.id_proveedor != proveedorID || s.nit == NITproveedor )
                    .FirstOrDefault<proveedor>();
            }
            if (objProveedorVerificar == null)
            {
                using (agrosysEntitiesFull proveedorEntidad = new agrosysEntitiesFull())
                {
                    objProveedor = proveedorEntidad.proveedors.Where(s => s.id_proveedor == proveedorID).FirstOrDefault<proveedor>();
                }

                objProveedor.nombre_proveedor = txtN.Text.ToString();
                objProveedor.telefono = txtT.Text.ToString();
                objProveedor.nit = txtNIT.Text.ToString();
                objProveedor.direccion = txtD.Text.ToString();

                using (agrosysEntitiesFull proveedorEntidad = new agrosysEntitiesFull())
                {
                    proveedorEntidad.Entry(objProveedor).State = System.Data.EntityState.Modified;
                    proveedorEntidad.SaveChanges();
                }

               ShowNotification("Su registro a sido actualizado!");
            }
            else
            {
                ShowNotification("Ya existe proveedor  con ese NIT!");
            }
        }
Ejemplo n.º 29
0
        public void SetTienda(string nombre, string direccion, string telefono)
        {
            try
            {
                tienda objTiendaVerificar = new tienda();
                using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
                {
                    objTiendaVerificar = VerificarTiendaEntidad.tiendas.Where(s => s.nombre == nombre).FirstOrDefault<tienda>();
                }

                 if (objTiendaVerificar == null)
                 {
                     using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
                     {
                         tienda objTienda = new tienda();
                         objTienda.nombre = nombre;
                         objTienda.telefono = telefono;
                         objTienda.direccion = direccion;

                         TiendaEntidad.tiendas.Add(objTienda);
                         TiendaEntidad.SaveChanges();
                         string mensaje = "La tienda con el nombre " + nombre + " a sido guardada";
                         ShowNotification(mensaje);
                     }
                 }
                 else
                 {
                     ShowNotification("No se a podido guardar el registro");
                 }

            }
            catch (Exception)
            {
                throw new Exception("Hay un problema al guardar la tienda, por favor intente de nuevo.");
            }
        }
Ejemplo n.º 30
0
        public void setDetalleFactura()
        {
            try
            {

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                   {
                       using (agrosysEntitiesFull facturaEntidad = new agrosysEntitiesFull())
                        {
                            detalle_factura objDetalleFactura = new detalle_factura();
                            objDetalleFactura.cantidad = Convert.ToInt32(ds.Tables[0].Rows[i]["cantidad"]);
                            objDetalleFactura.sub_total = ds.Tables[0].Rows[i]["subTotal"].ToString();
                            objDetalleFactura.factura_id_factura = Convert.ToInt32(ds.Tables[0].Rows[i]["facturaID"]);
                            objDetalleFactura.producto_id_producto = Convert.ToInt32(ds.Tables[0].Rows[i]["productoID"]);
                            facturaEntidad.detalle_factura.Add(objDetalleFactura);
                            facturaEntidad.SaveChanges();
                        }
                    }

            }
            catch (Exception)
            {

                throw new Exception("Hay un problema al guardar la factura, por favor intente de nuevo.");
            }
        }
Ejemplo n.º 31
0
        public void UpdateProducto(string nombre, string detalle, string precio,  int productoID, int proveedorID)
        {
            producto objproducto = new producto();
            producto objTiendaVerificar = new producto();

            using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
            {
                objTiendaVerificar = VerificarTiendaEntidad.productoes
                    .Where(s => s.id_producto != productoID && (s.nombre_producto == nombre ))
                    .FirstOrDefault<producto>();
            }
            if (objTiendaVerificar == null)
            {
                using (agrosysEntitiesFull productoEntidad = new agrosysEntitiesFull())
                {
                    objproducto = productoEntidad.productoes.Where(s => s.id_producto == productoID).FirstOrDefault<producto>();
                }
                int tiendaId = Convert.ToInt32(comboBox1.SelectedValue);
                objproducto.nombre_producto = nombre;
                objproducto.precio = precio;
                objproducto.detalle_producto = detalle;
                objproducto.proveedor_id_proveedor = proveedorID;

                using (agrosysEntitiesFull productoEntidad = new agrosysEntitiesFull())
                {
                    productoEntidad.Entry(objproducto).State = System.Data.EntityState.Modified;
                    productoEntidad.Entry(objproducto.proveedor).State = System.Data.EntityState.Modified;
                    productoEntidad.SaveChanges();
                }
                HideButtom();
                ShowNotification("Su registro a sido actualizado!");
            }
            else
            {
                ShowNotification("Ya existe producto  con ese Nombre!");
            }
        }
Ejemplo n.º 32
0
        public void UpdateCliente(string NITCliente, int clienteID, string dpi)
        {
            cliente objCliente= new cliente();
            cliente objTiendaVerificar = new cliente();

            using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
            {
                objTiendaVerificar = VerificarTiendaEntidad.clientes
                    .Where(s => s.id_cliente != clienteID &&( s.nit == NITCliente || s.dpi == dpi))
                    .FirstOrDefault<cliente>();
            }
            if (objTiendaVerificar == null)
            {
                using (agrosysEntitiesFull ClienteEntidad = new agrosysEntitiesFull())
                {
                    objCliente = ClienteEntidad.clientes.Where(s => s.id_cliente == clienteID).FirstOrDefault<cliente>();
                }

                objCliente.primer_nombre = txtN.Text.ToString();
                objCliente.segundo_nombre = txtN2.Text.ToString();
                objCliente.primer_apellido = txtA.Text.ToString();
                objCliente.segundo_apellido = txtA2.Text.ToString();
                objCliente.telefono = txtT.Text.ToString();
                objCliente.nit = txtNIT.Text.ToString();
                objCliente.direccion = txtNIT.Text.ToString();
                objCliente.dpi = txtDPI.Text.ToString();

                using (agrosysEntitiesFull ClienteEntidad = new agrosysEntitiesFull())
                {
                    ClienteEntidad.Entry(objCliente).State = System.Data.EntityState.Modified;
                    ClienteEntidad.SaveChanges();
                }
                HideButtom();
                ShowNotification("Su registro a sido actualizado!");
            }
            else
            {
                ShowNotification("Ya existe cliente  con ese NIT!");
            }
        }
Ejemplo n.º 33
0
        public void UpdateTienda(string nombreTienda,int tiendaID)
        {
            tienda objTienda = new tienda();
            tienda objTiendaVerificar = new tienda();

            using (agrosysEntitiesFull VerificarTiendaEntidad = new agrosysEntitiesFull())
            {
                objTiendaVerificar = VerificarTiendaEntidad.tiendas.Where(s => s.nombre == nombreTienda).FirstOrDefault<tienda>();
            }

            if (objTiendaVerificar == null)
            {
                using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
                {
                    objTienda = TiendaEntidad.tiendas.Where(s => s.id_tienda == tiendaID).FirstOrDefault<tienda>();
                }

                objTienda.nombre = txtN.Text.ToString();
                objTienda.direccion = txtD.Text.ToString();
                objTienda.telefono = txtT.Text.ToString();

                using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
                {
                    TiendaEntidad.Entry(objTienda).State = System.Data.EntityState.Modified;
                    TiendaEntidad.SaveChanges();
                }
                HideButtom();
                ShowNotification("Su registro a sido actualizado!");
            }
            else
            {
                ShowNotification("Ya existe una tienda con ese nomnbre!");
            }
        }
Ejemplo n.º 34
0
        public void SetFactura(string subTotal, string total, string iva, int clienteID)
        {
            try
            {
                      using (agrosysEntitiesFull facturaEntidad = new agrosysEntitiesFull())
                    {
                            //se guarda la factura
                              factura objfactura = new factura();

                              objfactura.sub_total = subTotal;
                              objfactura.iva = iva;
                              objfactura.total = total;
                              objfactura.cliente_id_cliente = clienteID;
                              facturaEntidad.facturas.Add(objfactura);
                              facturaEntidad.SaveChanges();
                           }

            }
            catch (Exception)
            {
                throw new Exception("Hay un problema al guardar la tienda, por favor intente de nuevo.");
            }
        }