private void Busqueda()
 {
     db    = new VeneciaEntities();
     Lista = FactoryProveedores.getItems(db, this.txtBuscar.Text);
     this.bs.DataSource = Lista;
     this.bs.ResetBindings(true);
 }
        void btnAplicarRetencion_Click(object sender, EventArgs e)
        {
            if (this.bs.Current == null)
            {
                return;
            }
            Compra             registro = (Compra)this.bs.Current;
            FrmRetencionesItem f        = new FrmRetencionesItem();

            f.CrearRetencion(registro);
            if (f.DialogResult == DialogResult.OK)
            {
                f.registro.CedulaRif = Basicas.CedulaRif(f.registro.CedulaRif);
                Proveedore proveedor = FactoryProveedores.Item(db, f.registro.CedulaRif);
                if (proveedor == null)
                {
                    proveedor        = new Proveedore();
                    proveedor.Activo = true;
                }
                proveedor.CedulaRif   = f.registro.CedulaRif;
                proveedor.RazonSocial = f.registro.NombreRazonSocial;
                if (proveedor.IdProveedor == null)
                {
                    proveedor.IdProveedor = FactoryContadores.GetMax("IdProveedor");
                    db.Proveedores.AddObject(proveedor);
                }
                f.registro.Id = FactoryContadores.GetMax("IdRetencion");
                db.Retenciones.AddObject(f.registro);
                db.SaveChanges();
                Busqueda();
            }
        }
Example #3
0
 private bool Guardar()
 {
     try
     {
         registro.IdUsuario = FactoryUsuarios.UsuarioActivo.IdUsuario;
         proveedor          = FactoryProveedores.Item(db, registro.CedulaRif);
         if (proveedor == null)
         {
             using (var newDb = new DatosEntities())
             {
                 proveedor             = new Proveedore();
                 proveedor.CedulaRif   = registro.CedulaRif;
                 proveedor.RazonSocial = registro.RazonSocial;
                 proveedor.Direccion   = registro.Direccion;
                 proveedor.IdProveedor = FactoryContadores.GetMax("IdProveedor");
                 newDb.Proveedores.AddObject(proveedor);
                 newDb.SaveChanges();
             }
         }
         else
         {
             proveedor.CedulaRif   = registro.CedulaRif;
             proveedor.RazonSocial = registro.RazonSocial;
             proveedor.Direccion   = registro.Direccion;
         }
         registro.Totalizar();
         if (registro.Errores().Count > 0)
         {
             MessageBox.Show(registro.ErroresStr(), "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return(false);
         }
         if (esNuevo)
         {
             registro.IdCompra = FactoryContadores.GetMax("IdCompra");
             db.Compras.AddObject(registro);
         }
         foreach (HK.ComprasIngrediente p in registro.ComprasIngredientes)
         {
             if (p.IdCompraIngrediente == null)
             {
                 p.IdCompraIngrediente = FactoryContadores.GetMax("IdCompraIngrediente");
             }
         }
         db.SaveChanges();
         if (registro.Estatus == "CERRADA")
         {
             FactoryLibroCompras.EscribirItem(registro);
             FactoryLibroInventarios.RegistrarCompra(registro);
             FactoryCompras.Inventario(registro);
         }
         return(true);
     }
     catch (Exception x)
     {
         Basicas.ManejarError(x);
         return(false);
     }
 }
Example #4
0
        private void Busqueda()
        {
            dc    = new RestaurantEntities();
            Texto = this.txtBuscar.Text;
            switch (myLayout.ToUpper())
            {
            case "CLIENTES":
                this.bindingSource.DataSource = FactoryClientes.getItems(dc, Texto);
                break;

            case "MESONEROS":
                this.bindingSource.DataSource = FactoryUsuarios.getItems(dc, Texto, "MESONERO");
                break;

            case "ADMINISTRADORES":
                this.bindingSource.DataSource = FactoryUsuarios.getItems(dc, Texto, "ADMINISTRADOR");
                break;

            case "CAJEROS":
                this.bindingSource.DataSource = FactoryUsuarios.getItems(dc, Texto, "CAJERO");
                break;

            case "MESAS":
                this.bindingSource.DataSource = FactoryMesas.getItems(dc, Texto);
                break;

            case "PLATOS":
                this.bindingSource.DataSource = FactoryPlatos.getItems(dc, Texto);
                break;

            case "COMPRAS":
                this.bindingSource.DataSource = FactoryCompras.getComprasEspera(dc, Texto);
                break;

            case "FACTURAS":
                this.bindingSource.DataSource = FactoryFacturas.getFacturasPendientes(dc, Texto);
                break;

            case "INGREDIENTES":
                this.bindingSource.DataSource = FactoryIngredientes.getItems(dc, Texto);
                break;

            case "PROVEEDORES":
                this.bindingSource.DataSource = FactoryProveedores.getItems(dc, Texto);
                break;

            case "MESAS DISPONIBLES":
                this.bindingSource.DataSource = FactoryMesas.getMesasDisponibles(dc);
                break;
            }
            this.gridControl1.DataSource = this.bindingSource;
            gridControl1.ForceInitialize();
            gridView1.OptionsLayout.Columns.Reset();
            this.gridControl1.DefaultView.RestoreLayoutFromXml(Application.StartupPath + "\\Layouts\\" + myLayout + ".XML", DevExpress.Utils.OptionsLayoutGrid.FullLayout);
        }
Example #5
0
        void CedulaRifButtonEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            FrmBuscarEntidades F = new FrmBuscarEntidades();

            F.BuscarProveedores("");
            if (F.registro != null)
            {
                proveedor = (Proveedore)F.registro;
                proveedor = FactoryProveedores.Item(proveedor.CedulaRif);
                LeerProveedor();
            }
            else
            {
                proveedor = new Proveedore();
            }
        }
 private void Guadar()
 {
     this.compraBindingSource.EndEdit();
     registro.IdUsuario = FactoryUsuarios.UsuarioActivo.IdUsuario;
     if (esNuevo)
     {
         registro.IdCompra = FactoryContadores.GetMax("IdCompra");
     }
     foreach (HK.ComprasIngrediente p in registro.ComprasIngredientes)
     {
         if (p.IdCompraIngrediente == null)
         {
             p.IdCompraIngrediente = FactoryContadores.GetMax("IdCompraIngrediente");
         }
     }
     proveedor = FactoryProveedores.Item(db, registro.CedulaRif);
     if (proveedor == null)
     {
         proveedor             = new Proveedore();
         proveedor.IdProveedor = FactoryContadores.GetMax("IdProveedor");
         proveedor.CedulaRif   = registro.CedulaRif;
         proveedor.RazonSocial = registro.RazonSocial;
         proveedor.Direccion   = registro.Direccion;
         db.Proveedores.AddObject(proveedor);
     }
     else
     {
         proveedor.CedulaRif   = registro.CedulaRif;
         proveedor.RazonSocial = registro.RazonSocial;
         proveedor.Direccion   = registro.Direccion;
     }
     if (esNuevo)
     {
         db.Compras.AddObject(registro);
     }
     try
     {
         db.SaveChanges();
     }
     catch (Exception x)
     {
         MessageBox.Show(x.InnerException.Message);
     }
 }
Example #7
0
        void CedulaRifButtonEdit_Validating(object sender, CancelEventArgs e)
        {
            DevExpress.XtraEditors.TextEdit Editor = (DevExpress.XtraEditors.TextEdit)sender;
            if (!Editor.IsModified)
            {
                return;
            }
            string Texto = Editor.Text;

            this.compraBindingSource.EndEdit();
            List <Proveedore> T = FactoryProveedores.getItems(Texto);

            switch (T.Count)
            {
            case 0:
                proveedor           = new Proveedore();
                proveedor.CedulaRif = Basicas.CedulaRif(Texto);
                break;

            case 1:
                proveedor = T[0];
                break;

            default:
                FrmBuscarEntidades F = new FrmBuscarEntidades();
                F.BuscarProveedores(Texto);
                if (F.registro != null)
                {
                    proveedor = (Proveedore)F.registro;
                    proveedor = FactoryProveedores.Item(proveedor.CedulaRif);
                }
                else
                {
                    proveedor = null;
                }
                break;
            }
            LeerProveedor();
        }
Example #8
0
        void CedulaRifTextEdit_Validating(object sender, CancelEventArgs e)
        {
            DevExpress.XtraEditors.TextEdit Editor = (DevExpress.XtraEditors.TextEdit)sender;
            if (!Editor.IsModified)
            {
                return;
            }
            string            Texto = Editor.Text;
            List <Proveedore> T     = FactoryProveedores.getItems(Texto);

            switch (T.Count)
            {
            case 0:
                Editor.Text = Basicas.CedulaRif(Texto);
                break;

            case 1:
                registro.CedulaRif         = T[0].CedulaRif;
                registro.NombreRazonSocial = T[0].RazonSocial;
                break;

            default:
                FrmBuscarEntidades F = new FrmBuscarEntidades();
                F.BuscarProveedores(Texto);
                if (F.registro != null)
                {
                    registro.CedulaRif         = ((Proveedore)F.registro).CedulaRif;
                    registro.NombreRazonSocial = ((Proveedore)F.registro).RazonSocial;
                }
                else
                {
                    registro.CedulaRif         = null;
                    registro.NombreRazonSocial = null;
                }
                break;
            }
        }
Example #9
0
        void toolRecuperar_Click(object sender, EventArgs e)
        {
            FrmBuscarEntidades f = new  FrmBuscarEntidades();

            f.BuscarCompras("");
            if (f.DialogResult == System.Windows.Forms.DialogResult.Abort)
            {
                using (var db = new DatosEntities())
                {
                    var x = (from item in db.Compras
                             where item.IdCompra == ((Compra)(f.registro)).IdCompra
                             select item).FirstOrDefault();
                    if (x != null)
                    {
                        db.Compras.DeleteObject(x);
                        db.SaveChanges();
                        return;
                    }
                }
            }
            if (f.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                if (f.registro != null)
                {
                    Limpiar();
                    registro = FactoryCompras.Item(db, ((Compra)f.registro).IdCompra);
                    compraBindingSource.DataSource = registro;
                    compraBindingSource.ResetBindings(true);
                    comprasIngredienteBindingSource.DataSource = registro.ComprasIngredientes;
                    comprasIngredienteBindingSource.ResetBindings(true);
                    proveedor = FactoryProveedores.Item(registro.CedulaRif);
                    esNuevo   = false;
                    //   registro.Estatus = "ABIERTA";
                }
            }
        }