Ejemplo n.º 1
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.º 2
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.º 3
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.º 4
0
  public static void Select()
 {
     using( var db = new agrosysEntitiesFull ())
     {
         db.clientes.Where(
     }
 }
Ejemplo n.º 5
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.º 6
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.º 7
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.º 8
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.º 9
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.º 10
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.º 11
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.º 12
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.º 13
0
 public static void Select()
 {
     using( var db = new agrosysEntitiesFull ())
     {
         db.clientes.Where(
     }
 }
Ejemplo n.º 14
0
        public static void SetTienda()
        {
            using( var theContext = new agrosysEntitiesFull())
            {

            }
        }
Ejemplo n.º 15
0
 public static void DeleteEmpleados()
 {
     // Get Employes from DB
     using (var entityModel = new agrosysEntitiesFull())
     {
         //employe = ctx.Teachers.Where(t => t.TeacherName == "Teacher 1").FirstOrDefault<Teacher>();
     }
 }
Ejemplo n.º 16
0
        public static void DeleteEmpleados()
        {
            // Get Employes from DB
            using (var entityModel= new agrosysEntitiesFull ())
            {
                //employe = ctx.Teachers.Where(t => t.TeacherName == "Teacher 1").FirstOrDefault<Teacher>();

            }
        }
Ejemplo n.º 17
0
 public object GetTienda(int id_tienda)
 {
     tienda objTienda = new tienda();
     // Get tienda from DB
     using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
     {
         objTienda = TiendaEntidad.tiendas.Where(s => s.id_tienda == id_tienda).FirstOrDefault<tienda>();
     }
     return objTienda;
 }
Ejemplo n.º 18
0
 public void fillProducto(string idProducto)
 {
     using (var dbContex = new agrosysEntitiesFull())
     {
         var results  = dbContex.getPrecioProductosPorID(idProducto);
         foreach (var item in results)
         {
             txtDetallePrecio.Text = item.ToString();
         }
     }
 }
Ejemplo n.º 19
0
 public void fillProducto(string idProducto)
 {
     using (var dbContex = new agrosysEntitiesFull())
     {
         var results = dbContex.getPrecioProductosPorID(idProducto);
         foreach (var item in results)
         {
             txtDetallePrecio.Text = item.ToString();
         }
     }
 }
Ejemplo n.º 20
0
        public object GetTienda(int id_tienda)
        {
            tienda objTienda = new tienda();

            // Get tienda from DB
            using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
            {
                objTienda = TiendaEntidad.tiendas.Where(s => s.id_tienda == id_tienda).FirstOrDefault <tienda>();
            }
            return(objTienda);
        }
Ejemplo n.º 21
0
        public void fillCliente(int idCliente)
        {
            using (var dbContex = new agrosysEntitiesFull())
            {
                var result = dbContex.getClientesPorID(idCliente);

                foreach (var item in result)
                {
                    txtCliente.Text = item.primer_nombre + " " + item.segundo_nombre + " " + item.primer_apellido + " " + item.segundo_apellido;
                }
            }
        }
Ejemplo n.º 22
0
        public void fillCliente(int idCliente)
        {
            using (var dbContex = new agrosysEntitiesFull())
            {
                var result = dbContex.getClientesPorID(idCliente);

                foreach (var item in result)
                {
                    txtCliente.Text = item.primer_nombre + " " + item.segundo_nombre + " " + item.primer_apellido + " " + item.segundo_apellido;
                }
            }
        }
Ejemplo n.º 23
0
 public void FillTienda()
 {
     tienda objTienda = new tienda();
     int tiendaID = Convert.ToInt32(comboBox1.SelectedValue);
     // Get tienda from DB
     using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
     {
         objTienda = TiendaEntidad.tiendas.Where(s => s.id_tienda == tiendaID).FirstOrDefault<tienda>();
     }
     txtN.Text = objTienda.nombre.ToString();
     txtD.Text = objTienda.direccion.ToString();
     txtT.Text = objTienda.telefono.ToString();
 }
Ejemplo n.º 24
0
 public void FillProducto()
 {
     producto objproducto = new producto();
     int productoID = Convert.ToInt32(comboBox2.SelectedValue);
     // Get tienda from DB
     using (agrosysEntitiesFull productoEntidad = new agrosysEntitiesFull())
     {
         objproducto = productoEntidad.productoes.Where(s => s.id_producto == productoID).FirstOrDefault<producto>();
     }
     txtN.Text = objproducto.nombre_producto.ToString();
     txtD.Text = objproducto.detalle_producto.ToString();
     txtP.Text = objproducto.precio.ToString();
 }
Ejemplo n.º 25
0
 public int getNextValue()
 {
     using (var dbContex = new agrosysEntitiesFull())
     {
         var result   = dbContex.FacturaNextIdValue("facturas");
         var contador = "";
         foreach (var item in result)
         {
             contador = item;
         }
         return(Convert.ToInt16(contador));
     }
 }
Ejemplo n.º 26
0
        public void FillProducto()
        {
            producto objproducto = new producto();
            int      productoID  = Convert.ToInt32(comboBox2.SelectedValue);

            // Get tienda from DB
            using (agrosysEntitiesFull productoEntidad = new agrosysEntitiesFull())
            {
                objproducto = productoEntidad.productoes.Where(s => s.id_producto == productoID).FirstOrDefault <producto>();
            }
            txtN.Text = objproducto.nombre_producto.ToString();
            txtD.Text = objproducto.detalle_producto.ToString();
            txtP.Text = objproducto.precio.ToString();
        }
Ejemplo n.º 27
0
        public void FillTienda()
        {
            tienda objTienda = new tienda();
            int    tiendaID  = Convert.ToInt32(comboBox1.SelectedValue);

            // Get tienda from DB
            using (agrosysEntitiesFull TiendaEntidad = new agrosysEntitiesFull())
            {
                objTienda = TiendaEntidad.tiendas.Where(s => s.id_tienda == tiendaID).FirstOrDefault <tienda>();
            }
            txtN.Text = objTienda.nombre.ToString();
            txtD.Text = objTienda.direccion.ToString();
            txtT.Text = objTienda.telefono.ToString();
        }
Ejemplo n.º 28
0
 public void FillProveedor()
 {
     proveedor objproveedor = new proveedor();
     int proveedorID = Convert.ToInt32(comboBox1.SelectedValue);
     // Get tienda from DB
     using (agrosysEntitiesFull proveedorEntidad = new agrosysEntitiesFull())
     {
         objproveedor = proveedorEntidad.proveedors.Where(s => s.id_proveedor == proveedorID).FirstOrDefault<proveedor>();
     }
     txtN.Text = objproveedor.nombre_proveedor.ToString();
     txtD.Text = objproveedor.direccion.ToString();
     txtT.Text = objproveedor.telefono.ToString();
     txtNIT.Text = objproveedor.nit.ToString();
 }
Ejemplo n.º 29
0
        public void FillProveedor()
        {
            proveedor objproveedor = new proveedor();
            int       proveedorID  = Convert.ToInt32(comboBox1.SelectedValue);

            // Get tienda from DB
            using (agrosysEntitiesFull proveedorEntidad = new agrosysEntitiesFull())
            {
                objproveedor = proveedorEntidad.proveedors.Where(s => s.id_proveedor == proveedorID).FirstOrDefault <proveedor>();
            }
            txtN.Text   = objproveedor.nombre_proveedor.ToString();
            txtD.Text   = objproveedor.direccion.ToString();
            txtT.Text   = objproveedor.telefono.ToString();
            txtNIT.Text = objproveedor.nit.ToString();
        }
Ejemplo n.º 30
0
 public void Fillempleado()
 {
     empleado objempleado = new empleado();
     int empleadoID = Convert.ToInt32(comboBox1.SelectedValue);
     // Get tienda from DB
     using (agrosysEntitiesFull empleadoEntidad = new agrosysEntitiesFull())
     {
         objempleado = empleadoEntidad.empleadoes.Where(s => s.id_empleado == empleadoID).FirstOrDefault<empleado>();
     }
     txtN.Text = objempleado.primer_nombre.ToString();
     txtN2.Text = objempleado.segundo_nombre.ToString();
     txtA.Text = objempleado.primer_apellido.ToString();
     txtA2.Text = objempleado.segundo_apellido.ToString();
     txtD.Text = objempleado.direccion.ToString();
     txtT.Text = objempleado.telefono.ToString();
     txtNIT.Text = objempleado.nit.ToString();
     txtDPI.Text = objempleado.dpi.ToString();
 }
Ejemplo n.º 31
0
 public void FillCliente()
 {
     cliente objCliente = new cliente();
     int clienteID = Convert.ToInt32(comboBox1.SelectedValue);
     // Get tienda from DB
     using (agrosysEntitiesFull ClienteEntidad = new agrosysEntitiesFull())
     {
         objCliente = ClienteEntidad.clientes.Where(s => s.id_cliente == clienteID).FirstOrDefault<cliente>();
     }
     txtN.Text = objCliente.primer_nombre.ToString();
     txtN2.Text = objCliente.segundo_nombre.ToString();
     txtA.Text = objCliente.primer_apellido.ToString();
     txtA2.Text = objCliente.segundo_apellido.ToString();
     txtD.Text = objCliente.direccion.ToString();
     txtT.Text = objCliente.telefono.ToString();
     txtNIT.Text = objCliente.nit.ToString();
     txtDPI.Text = objCliente.dpi.ToString();
 }
Ejemplo n.º 32
0
        public void SaveUsuario()
        {
            agrosysEntitiesFull entidad = new agrosysEntitiesFull();
            usuario user = new usuario();
            rol roluser = new rol();
            user.nombre_usuario = txtUsuario.Text.ToString();
            user.password = txtPassword.Text.ToString();
            user.rol_id_rol = Convert.ToInt32( ddlRol.SelectedValue);
            user.empleado_id_empleado = Convert.ToInt32( ddlEmpleado.SelectedValue);

            using (var ctx = new agrosysEntitiesFull())
            {

                ctx.Set<usuario>().Remove(user);
            }

            entidad.usuarios.Add(user);
        }
Ejemplo n.º 33
0
        public void SaveUsuario()
        {
            agrosysEntitiesFull entidad = new agrosysEntitiesFull();
            usuario             user    = new usuario();
            rol roluser = new rol();

            user.nombre_usuario       = txtUsuario.Text.ToString();
            user.password             = txtPassword.Text.ToString();
            user.rol_id_rol           = Convert.ToInt32(ddlRol.SelectedValue);
            user.empleado_id_empleado = Convert.ToInt32(ddlEmpleado.SelectedValue);

            using (var ctx = new agrosysEntitiesFull())
            {
                ctx.Set <usuario>().Remove(user);
            }

            entidad.usuarios.Add(user);
        }
Ejemplo n.º 34
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.º 35
0
        public void FillCliente()
        {
            cliente objCliente = new cliente();
            int     clienteID  = Convert.ToInt32(comboBox1.SelectedValue);

            // Get tienda from DB
            using (agrosysEntitiesFull ClienteEntidad = new agrosysEntitiesFull())
            {
                objCliente = ClienteEntidad.clientes.Where(s => s.id_cliente == clienteID).FirstOrDefault <cliente>();
            }
            txtN.Text   = objCliente.primer_nombre.ToString();
            txtN2.Text  = objCliente.segundo_nombre.ToString();
            txtA.Text   = objCliente.primer_apellido.ToString();
            txtA2.Text  = objCliente.segundo_apellido.ToString();
            txtD.Text   = objCliente.direccion.ToString();
            txtT.Text   = objCliente.telefono.ToString();
            txtNIT.Text = objCliente.nit.ToString();
            txtDPI.Text = objCliente.dpi.ToString();
        }
Ejemplo n.º 36
0
        public void Fillempleado()
        {
            empleado objempleado = new empleado();
            int      empleadoID  = Convert.ToInt32(comboBox1.SelectedValue);

            // Get tienda from DB
            using (agrosysEntitiesFull empleadoEntidad = new agrosysEntitiesFull())
            {
                objempleado = empleadoEntidad.empleadoes.Where(s => s.id_empleado == empleadoID).FirstOrDefault <empleado>();
            }
            txtN.Text   = objempleado.primer_nombre.ToString();
            txtN2.Text  = objempleado.segundo_nombre.ToString();
            txtA.Text   = objempleado.primer_apellido.ToString();
            txtA2.Text  = objempleado.segundo_apellido.ToString();
            txtD.Text   = objempleado.direccion.ToString();
            txtT.Text   = objempleado.telefono.ToString();
            txtNIT.Text = objempleado.nit.ToString();
            txtDPI.Text = objempleado.dpi.ToString();
        }
Ejemplo n.º 37
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.º 38
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.º 39
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.º 40
0
 public bool isNullTable()
 {
     using (var dbContex = new agrosysEntitiesFull())
     {
         var result   = dbContex.FacturaContador();
         var contador = "";
         foreach (var item in result)
         {
             contador = item;
         }
         if (Convert.ToInt16(contador) == 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Ejemplo n.º 41
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.º 42
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.º 43
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.º 44
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.º 45
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.º 46
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.º 47
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.º 48
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.º 49
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.º 50
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.º 51
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.º 52
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.º 53
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.º 54
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.º 55
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.º 56
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.º 57
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.º 58
0
 public bool isNullTable()
 {
     using (var dbContex = new agrosysEntitiesFull())
     {
         var result = dbContex.FacturaContador();
         var contador = "";
         foreach (var item in result)
         {
              contador = item ;
         }
         if ( Convert.ToInt16(contador) == 0)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
 }
Ejemplo n.º 59
0
 public int getNextValue()
 {
     using (var dbContex = new agrosysEntitiesFull())
     {
         var result = dbContex.FacturaNextIdValue("facturas");
         var contador = "";
         foreach (var item in result)
         {
             contador = item;
         }
         return Convert.ToInt16(contador);
     }
 }
Ejemplo n.º 60
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.");
            }
        }