Exemplo n.º 1
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.TableCommand Comando;
            if (this.Existe == false)
            {
                Comando = new qGen.Insert(Connection, this.TablaDatos);
                Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
            }
            else
            {
                Comando             = new qGen.Update(Connection, this.TablaDatos);
                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
            }

            Comando.Fields.AddWithValue("nombre", this.Nombre);
            Comando.Fields.AddWithValue("estacion", this.Estacion);
            Comando.Fields.AddWithValue("dispositivo", this.Dispositivo);
            Comando.Fields.AddWithValue("bandeja", this.Bandeja);
            Comando.Fields.AddWithValue("ubicacion", this.Ubicacion);

            Comando.Fields.AddWithValue("tipo", (int)this.Clase);
            Comando.Fields.AddWithValue("carga", (int)this.CargaPapel);
            Comando.Fields.AddWithValue("talonario", this.UsaTalonario ? 1 : 0);

            Comando.Fields.AddWithValue("fiscal_modelo", (int)this.FiscalModelo);
            Comando.Fields.AddWithValue("fiscal_bps", this.FiscalBps);

            Comando.Fields.AddWithValue("obs", this.Obs);

            this.AgregarTags(Comando);

            Connection.Execute(Comando);

            return(base.Guardar());
        }
Exemplo n.º 2
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.TableCommand Comando;

            if (this.Existe == false)
            {
                Comando = new qGen.Insert(this.Connection, this.TablaDatos);
                Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
            }
            else
            {
                Comando             = new qGen.Update(this.Connection, this.TablaDatos);
                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
            }

            Comando.Fields.AddWithValue("id_ticket", this.Tarea.Id);
            if (this.Persona == null)
            {
                Comando.Fields.AddWithValue("id_tecnico", this.Persona.Id);
            }
            else
            {
                Comando.Fields.AddWithValue("id_tecnico", null);
            }
            Comando.Fields.AddWithValue("descripcion", this.Descripcion);
            Comando.Fields.AddWithValue("estado", this.Estado);
            Comando.Fields.AddWithValue("minutos_tecnico", this.Minutos);
            Comando.Fields.AddWithValue("privado", this.Privado ? 1 : 0);

            this.AgregarTags(Comando);

            this.Connection.Execute(Comando);

            return(base.Guardar());
        }
Exemplo n.º 3
0
                public override Lfx.Types.OperationResult Guardar()
                {
                        qGen.TableCommand Comando;

                        if (this.Existe == false) {
                                Comando = new qGen.Insert(this.Connection, this.TablaDatos);
                        } else {
                                Comando = new qGen.Update(this.Connection, this.TablaDatos);
                                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
                        }

                        Comando.Fields.AddWithValue("fecha", this.Fecha);
                        Comando.Fields.AddWithValue("auto", this.Auto ? 1 : 0);
                        Comando.Fields.AddWithValue("concepto", this.Nombre);
                        Comando.Fields.AddWithValue("id_cliente", this.IdCliente);
                        Comando.Fields.AddWithValue("importe", this.Importe);
                        Comando.Fields.AddWithValue("comprob", this.Comprobantes);
                        Comando.Fields.AddWithValue("obs", this.Obs);

                        if (this.IdConcepto == 0)
                                Comando.Fields.AddWithValue("id_concepto", null);
                        else
                                Comando.Fields.AddWithValue("id_concepto", this.IdConcepto);

                        this.AgregarTags(Comando);

                        this.Connection.Execute(Comando);

                        return base.Guardar();
                }
Exemplo n.º 4
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.TableCommand Comando;

            if (this.Existe == false)
            {
                Comando = new qGen.Insert(this.Connection, this.TablaDatos);
                Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
            }
            else
            {
                Comando             = new qGen.Update(this.Connection, this.TablaDatos);
                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
            }

            Comando.Fields.AddWithValue("nombre", this.Nombre);
            Comando.Fields.AddWithValue("cp", this.CodigoPostal);
            if (this.Provincia == null)
            {
                Comando.Fields.AddWithValue("id_provincia", null);
            }
            else
            {
                Comando.Fields.AddWithValue("id_provincia", this.Provincia.Id);
            }
            Comando.Fields.AddWithValue("iva", (int)(this.Iva));

            this.AgregarTags(Comando);

            this.Connection.Execute(Comando);

            return(base.Guardar());
        }
Exemplo n.º 5
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.IStatement Comando;
            if (this.Existe == false)
            {
                Comando = new qGen.Insert("conceptos");
            }
            else
            {
                Comando             = new qGen.Update("conceptos");
                Comando.WhereClause = new qGen.Where("id_concepto", this.Id);
            }

            Comando.ColumnValues.AddWithValue("nombre", this.Nombre);
            Comando.ColumnValues.AddWithValue("es", this.Direccion);
            if (this.Grupo == 0)
            {
                Comando.ColumnValues.AddWithValue("grupo", null);
            }
            else
            {
                Comando.ColumnValues.AddWithValue("grupo", this.Grupo);
            }

            Connection.ExecuteNonQuery(Comando);

            return(base.Guardar());
        }
Exemplo n.º 6
0
        public bool AddTask(string commandString, string component, string terminalName)
        {
            if (terminalName == null || terminalName.Length == 0)
            {
                terminalName = Lfx.Environment.SystemInformation.MachineName;
            }

            qGen.Insert Comando = new qGen.Insert("sys_programador");
            Comando.ColumnValues.AddWithValue("crea_estacion", Lfx.Environment.SystemInformation.MachineName);
            Comando.ColumnValues.AddWithValue("crea_usuario", "");                    // TODO: que ponga el nombre de usuario
            Comando.ColumnValues.AddWithValue("estacion", terminalName);
            Comando.ColumnValues.AddWithValue("comando", commandString);
            Comando.ColumnValues.AddWithValue("componente", component);
            Comando.ColumnValues.AddWithValue("fecha", new qGen.SqlExpression("NOW()"));
            Comando.ColumnValues.AddWithValue("fechaejecutar", null);

            try {
                using (System.Data.IDbTransaction Trans = this.DataBase.BeginTransaction()) {
                    this.DataBase.ExecuteNonQuery(Comando);
                    Trans.Commit();
                }
            }
            catch {
                return(true);
            }

            return(false);
        }
Exemplo n.º 7
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.IStatement Comando;

            if (this.Existe == false)
            {
                Comando = new qGen.Insert(this.TablaDatos);
                Comando.ColumnValues.AddWithValue("fecha", new qGen.SqlExpression("NOW()"));
            }
            else
            {
                Comando             = new qGen.Update(this.TablaDatos);
                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
            }

            Comando.ColumnValues.AddWithValue("nombre", this.Nombre);
            Comando.ColumnValues.AddWithValue("obs", this.Obs);

            Comando.ColumnValues.AddWithValue("espacio", this.EspacioNombres);
            Comando.ColumnValues.AddWithValue("version", this.Version);
            Comando.ColumnValues.AddWithValue("estructura", this.Estructura);
            Comando.ColumnValues.AddWithValue("cif", this.Cif);

            Comando.ColumnValues.AddWithValue("url", this.Url);
            Comando.ColumnValues.AddWithValue("url_act", this.UrlActualizaciones);

            this.AgregarTags(Comando);

            this.Connection.ExecuteNonQuery(Comando);

            return(base.Guardar());
        }
Exemplo n.º 8
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.IStatement Comando;

            if (this.Existe == false)
            {
                Comando = new qGen.Insert(this.TablaDatos);
                Comando.ColumnValues.AddWithValue("fecha", new qGen.SqlExpression("NOW()"));
            }
            else
            {
                Comando             = new qGen.Update(this.TablaDatos);
                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
            }

            Comando.ColumnValues.AddWithValue("nombre", this.Nombre);
            Comando.ColumnValues.AddWithValue("porcentaje", this.Porcentaje);
            Comando.ColumnValues.AddWithValue("predet", this.Predeterminado ? 1 : 0);
            Comando.ColumnValues.AddWithValue("obs", this.Obs);
            Comando.ColumnValues.AddWithValue("estado", this.Estado);

            this.AgregarTags(Comando);

            this.Connection.ExecuteNonQuery(Comando);

            return(base.Guardar());
        }
Exemplo n.º 9
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.IStatement Comando;

            if (this.Existe == false)
            {
                Comando = new qGen.Insert(this.TablaDatos);
                Comando.ColumnValues.AddWithValue("fecha", new qGen.SqlExpression("NOW()"));
            }
            else
            {
                Comando             = new qGen.Update(this.TablaDatos);
                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
            }

            Comando.ColumnValues.AddWithValue("nombre", this.Nombre);
            Comando.ColumnValues.AddWithValue("cp", this.CodigoPostal);
            if (this.Provincia == null)
            {
                Comando.ColumnValues.AddWithValue("id_provincia", null);
            }
            else
            {
                Comando.ColumnValues.AddWithValue("id_provincia", this.Provincia.Id);
            }
            Comando.ColumnValues.AddWithValue("iva", (int)(this.Iva));

            this.AgregarTags(Comando);

            this.Connection.ExecuteNonQuery(Comando);

            return(base.Guardar());
        }
Exemplo n.º 10
0
        /// <summary>
        /// Agrega un comentario al historial de este elemento. El comentario se guarda inmediatamente en el historial.
        /// Sólo se pueden agregar comentarios al elemento una vez que este fue guardado.
        /// </summary>
        /// <param name="texto">El texto del comentario.</param>
        public void AgregarComentario(string texto)
        {
            if (this.Existe == false)
            {
                throw new Lfx.Types.DomainException("No se pueden agregar comentarios a un elemento que aun no ha sido guardado.");
            }

            qGen.Insert NuevoCom = new qGen.Insert("sys_log");
            NuevoCom.ColumnValues.AddWithValue("estacion", Lfx.Environment.SystemInformation.MachineName);
            NuevoCom.ColumnValues.AddWithValue("tabla", this.TablaDatos);
            NuevoCom.ColumnValues.AddWithValue("comando", "Comment");
            NuevoCom.ColumnValues.AddWithValue("item_id", this.Id);
            if (Lbl.Sys.Config.Actual.UsuarioConectado == null || Lbl.Sys.Config.Actual.UsuarioConectado.Id == 0)
            {
                NuevoCom.ColumnValues.AddWithValue("usuario", null);
            }
            else
            {
                NuevoCom.ColumnValues.AddWithValue("usuario", Lbl.Sys.Config.Actual.UsuarioConectado.Id);
            }
            NuevoCom.ColumnValues.AddWithValue("fecha", new qGen.SqlExpression("NOW()"));
            NuevoCom.ColumnValues.AddWithValue("extra1", texto);

            this.Connection.ExecuteNonQuery(NuevoCom);
        }
Exemplo n.º 11
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.TableCommand Comando;

            if (this.Existe == false)
            {
                Comando = new qGen.Insert(this.Connection, this.TablaDatos);
            }
            else
            {
                Comando             = new qGen.Update(this.Connection, this.TablaDatos);
                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
            }

            Comando.Fields.AddWithValue("nombre", this.Nombre);
            if (this.Alicuota == null)
            {
                Comando.Fields.AddWithValue("id_alicuota", null);
            }
            else
            {
                Comando.Fields.AddWithValue("id_alicuota", this.Alicuota.Id);
            }

            this.AgregarTags(Comando);

            this.Connection.Execute(Comando);

            return(base.Guardar());
        }
Exemplo n.º 12
0
        /// <summary>
        /// Guarda los cambios que se hayan efectuado en las etiquetas.
        /// </summary>
        public void GuardarEtiquetas()
        {
            if (this.Existe == false)
            {
                throw new Lfx.Types.DomainException("No se pueden agregar etiquetas a un elemento que aun no ha sido guardado.");
            }

            // Elimino las etiquetas que ya no están.
            ColeccionGenerica <Etiqueta> ListaEtiquetas = this.Etiquetas.Quitados(m_EtiquetasOriginal);

            if (ListaEtiquetas != null && ListaEtiquetas.Count > 0)
            {
                qGen.Delete EliminarEtiquetas = new qGen.Delete("sys_labels_values");
                EliminarEtiquetas.WhereClause = new qGen.Where("item_id", this.Id);
                EliminarEtiquetas.WhereClause.Add(new qGen.ComparisonCondition("id_label", qGen.ComparisonOperators.In, ListaEtiquetas.GetAllIds()));
                this.Connection.ExecuteNonQuery(EliminarEtiquetas);
            }

            // Agrego las etiquetas nuevas.
            ListaEtiquetas = this.Etiquetas.Agregados(m_EtiquetasOriginal);
            if (ListaEtiquetas != null && ListaEtiquetas.Count > 0)
            {
                foreach (ElementoDeDatos El in ListaEtiquetas)
                {
                    qGen.Insert CrearEtiquetas = new qGen.Insert("sys_labels_values");
                    CrearEtiquetas.ColumnValues.AddWithValue("id_label", El.Id);
                    CrearEtiquetas.ColumnValues.AddWithValue("item_id", this.Id);
                    this.Connection.ExecuteNonQuery(CrearEtiquetas);
                }
            }
        }
Exemplo n.º 13
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.TableCommand Comando;
            if (this.Existe == false)
            {
                Comando = new qGen.Insert(Connection, "personas_grupos");
                Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
            }
            else
            {
                Comando             = new qGen.Update(Connection, "personas_grupos");
                Comando.WhereClause = new qGen.Where("id_grupo", this.Id);
            }

            Comando.Fields.AddWithValue("nombre", this.Nombre);
            Comando.Fields.AddWithValue("descuento", this.Descuento);
            Comando.Fields.AddWithValue("predet", this.Predeterminado ? 1 : 0);
            if (this.Parent != null)
            {
                Comando.Fields.AddWithValue("parent", this.Parent.Id);
            }
            else
            {
                Comando.Fields.AddWithValue("parent", null);
            }

            Connection.Execute(Comando);

            return(base.Guardar());
        }
Exemplo n.º 14
0
        public override Lfx.Types.OperationResult Guardar()
        {
            try {
                qGen.IStatement Comando;
                if (this.Existe)
                {
                    Comando             = new qGen.Update(this.TablaDatos);
                    Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
                }
                else
                {
                    Comando = new qGen.Insert(this.TablaDatos);
                    Comando.ColumnValues.AddWithValue("fecha", new qGen.SqlExpression("NOW()"));
                }

                Comando.ColumnValues.AddWithValue("nombre", this.Registro["nombre"].ToString());
                Comando.ColumnValues.AddWithValue("cuenta_stock", this.CuentaExistencias ? 1 : 0);
                Comando.ColumnValues.AddWithValue("deposito", this.Deposito);
                Comando.ColumnValues.AddWithValue("facturable", this.Facturable ? 1 : 0);
                Comando.ColumnValues.AddWithValue("estado", this.Estado);
                Comando.ColumnValues.AddWithValue("obs", this.Obs);

                this.AgregarTags(Comando);

                this.Connection.ExecuteNonQuery(Comando);

                return(new Lfx.Types.SuccessOperationResult());
            }
            catch (Exception ex) {
                return(new Lfx.Types.FailureOperationResult(ex.ToString()));
            }
        }
Exemplo n.º 15
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.TableCommand Comando;

            if (this.Existe == false)
            {
                Comando = new qGen.Insert(this.Connection, this.TablaDatos);
                Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
            }
            else
            {
                Comando             = new qGen.Update(this.Connection, this.TablaDatos);
                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
            }

            Comando.Fields.AddWithValue("nombre", this.Nombre);
            Comando.Fields.AddWithValue("porcentaje", this.Porcentaje);
            Comando.Fields.AddWithValue("predet", this.Predeterminado ? 1 : 0);
            Comando.Fields.AddWithValue("obs", this.Obs);
            Comando.Fields.AddWithValue("estado", this.Estado);

            this.AgregarTags(Comando);

            this.Connection.Execute(Comando);

            return(base.Guardar());
        }
Exemplo n.º 16
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.IStatement Comando;
            if (this.Existe == false)
            {
                Comando = new qGen.Insert(this.TablaDatos);
                Comando.ColumnValues.AddWithValue("fecha", new qGen.SqlExpression("NOW()"));
                Comando.ColumnValues.AddWithValue("estado", 1);
                Comando.ColumnValues.AddWithValue("decimales", 2);
            }
            else
            {
                Comando             = new qGen.Update("monedas");
                Comando.WhereClause = new qGen.Where("id_moneda", m_ItemId);
                Comando.ColumnValues.AddWithValue("fecha", new qGen.SqlExpression("NOW()"));
            }


            Comando.ColumnValues.AddWithValue("nombre", this.Nombre);
            Comando.ColumnValues.AddWithValue("iso", this.NomenclaturaIso);
            Comando.ColumnValues.AddWithValue("signo", this.Simbolo);
            if (this.Cotizacion > 0)
            {
                Comando.ColumnValues.AddWithValue("cotizacion", this.Cotizacion);
            }


            Connection.ExecuteNonQuery(Comando);

            return(base.Guardar());
        }
Exemplo n.º 17
0
		public override Lfx.Types.OperationResult Guardar()
                {
			qGen.TableCommand Comando;

                        if (this.Existe == false) {
                                Comando = new qGen.Insert(this.Connection, this.TablaDatos);
                                Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                        } else {
                                Comando = new qGen.Update(this.Connection, this.TablaDatos);
                                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
                        }

                        Comando.Fields.AddWithValue("nombre", this.Nombre);
			Comando.Fields.AddWithValue("url", this.Url);
			if(this.Proveedor == null)
				Comando.Fields.AddWithValue("id_proveedor", null);
			else
				Comando.Fields.AddWithValue("id_proveedor", this.Proveedor.Id);
			Comando.Fields.AddWithValue("obs", this.Obs);
			Comando.Fields.AddWithValue("estado", this.Estado);

			this.AgregarTags(Comando);

                        this.Connection.Execute(Comando);

			return base.Guardar();
		}
Exemplo n.º 18
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.IStatement Comando;

            if (this.Existe == false)
            {
                Comando = new qGen.Insert(this.TablaDatos);
            }
            else
            {
                Comando             = new qGen.Update(this.TablaDatos);
                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
            }

            Comando.ColumnValues.AddWithValue("nombre", this.Nombre);
            Comando.ColumnValues.AddWithValue("abrev", this.Abreviatura);
            Comando.ColumnValues.AddWithValue("comprob", this.Comprobante);
            Comando.ColumnValues.AddWithValue("comprob2", this.Comprobante2);

            this.AgregarTags(Comando);

            this.Connection.ExecuteNonQuery(Comando);

            return(base.Guardar());
        }
Exemplo n.º 19
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.IStatement Comando;
            if (this.Existe == false)
            {
                Comando = new qGen.Insert("personas_grupos");
                Comando.ColumnValues.AddWithValue("fecha", new qGen.SqlExpression("NOW()"));
            }
            else
            {
                Comando             = new qGen.Update("personas_grupos");
                Comando.WhereClause = new qGen.Where("id_grupo", this.Id);
            }

            Comando.ColumnValues.AddWithValue("nombre", this.Nombre);
            Comando.ColumnValues.AddWithValue("descuento", this.Descuento);
            Comando.ColumnValues.AddWithValue("predet", this.Predeterminado ? 1 : 0);
            if (this.Parent != null)
            {
                Comando.ColumnValues.AddWithValue("parent", this.Parent.Id);
            }
            else
            {
                Comando.ColumnValues.AddWithValue("parent", null);
            }

            Connection.ExecuteNonQuery(Comando);

            return(base.Guardar());
        }
Exemplo n.º 20
0
        /// <summary>
        /// Persist (insert or update) an entity.
        /// </summary>
        /// <param name="entity">The entity to be persisted.</param>
        public void Persist(object entity)
        {
            var EntityType = entity.GetType();
            var ClassName  = EntityType.FullName;

            qGen.IStatement InsertOrUpdate;

            var ClassMetadata = this.MetadataFactory.GetMetadataForClass(EntityType);

            if (ClassMetadata.ObjectInfo.IdentifierHasValue(entity))
            {
                InsertOrUpdate             = new qGen.Update(ClassMetadata.TableName);
                InsertOrUpdate.WhereClause = new qGen.Where();
                foreach (var Col in ClassMetadata.Columns.GetIdColumns())
                {
                    InsertOrUpdate.WhereClause.AddWithValue(Col.Name, ClassMetadata.ObjectInfo.GetColumnValue(entity, Col));
                }
            }
            else
            {
                InsertOrUpdate = new qGen.Insert(ClassMetadata.TableName);
            }

            foreach (var Col in ClassMetadata.Columns)
            {
                if (Col.GeneratedValueStategy == GeneratedValueStategies.None)
                {
                    object ColValue;

                    if (Col.AssociationMetada != null && Col.AssociationMetada.AssociationType != AssociationTypes.None)
                    {
                        // Association column. Get value from property on the other side
                        object OtherEndEntity = ClassMetadata.ObjectInfo.GetColumnValue(entity, Col);
                        ColValue = Col.AssociationMetada.OtherEndClass.ObjectInfo.GetColumnValue(OtherEndEntity, Col.AssociationMetada.OtherEndColumn);
                    }
                    else
                    {
                        // Regular member-to-column value
                        ColValue = ClassMetadata.ObjectInfo.GetColumnValue(entity, Col);
                    }

                    InsertOrUpdate.ColumnValues.AddWithValue(Col.Name, ColValue);
                }
            }

            this.Connection.ExecuteNonQuery(InsertOrUpdate);

            if (InsertOrUpdate is qGen.Insert)
            {
                foreach (var Col in ClassMetadata.Columns)
                {
                    if (Col.GeneratedValueStategy == GeneratedValueStategies.DbGenerated)
                    {
                        ClassMetadata.ObjectInfo.SetColumnValue(entity, Col, this.Connection.GetLastInsertId());
                        break;
                    }
                }
            }
        }
Exemplo n.º 21
0
        public void Movimiento(bool auto, Lbl.Cajas.Concepto concepto, string textoConcepto,
                               Lbl.Personas.Persona cliente, decimal importe, string obs,
                               Lbl.Comprobantes.ComprobanteConArticulos factura, Lbl.Comprobantes.Recibo recibo, string comprobantes)
        {
            if (Lbl.Sys.Config.Actual.UsuarioConectado.TienePermiso(this.Caja, Lbl.Sys.Permisos.Operaciones.Mover) == false)
            {
                throw new Lfx.Types.Exceptions.AccessDeniedException("No tiene permiso para hacer movimientos en la caja solicitada");
            }

            decimal SaldoActual = this.ObtenerSaldo(true);

            qGen.IStatement InsertarMovimiento = new qGen.Insert("cajas_movim");
            InsertarMovimiento.ColumnValues.AddWithValue("id_caja", this.Caja.Id);
            InsertarMovimiento.ColumnValues.AddWithValue("id_sucursal", null);
            InsertarMovimiento.ColumnValues.AddWithValue("auto", auto ? 1 : 0);
            if (concepto == null)
            {
                InsertarMovimiento.ColumnValues.AddWithValue("id_concepto", null);
            }
            else
            {
                InsertarMovimiento.ColumnValues.AddWithValue("id_concepto", concepto.Id);
            }
            InsertarMovimiento.ColumnValues.AddWithValue("concepto", textoConcepto);
            InsertarMovimiento.ColumnValues.AddWithValue("id_persona", Lbl.Sys.Config.Actual.UsuarioConectado.Id);
            if (cliente == null)
            {
                InsertarMovimiento.ColumnValues.AddWithValue("id_cliente", null);
            }
            else
            {
                InsertarMovimiento.ColumnValues.AddWithValue("id_cliente", cliente.Id);
            }
            InsertarMovimiento.ColumnValues.AddWithValue("fecha", new qGen.SqlExpression("NOW()"));
            InsertarMovimiento.ColumnValues.AddWithValue("importe", importe);
            if (factura == null)
            {
                InsertarMovimiento.ColumnValues.AddWithValue("id_comprob", null);
            }
            else
            {
                InsertarMovimiento.ColumnValues.AddWithValue("id_comprob", factura.Id);
            }
            if (recibo == null)
            {
                InsertarMovimiento.ColumnValues.AddWithValue("id_recibo", null);
            }
            else
            {
                InsertarMovimiento.ColumnValues.AddWithValue("id_recibo", recibo.Id);
            }
            InsertarMovimiento.ColumnValues.AddWithValue("comprob", comprobantes);
            InsertarMovimiento.ColumnValues.AddWithValue("saldo", SaldoActual + importe);
            InsertarMovimiento.ColumnValues.AddWithValue("obs", obs);
            //System.Data.IDbTransaction Trans =this.Connection.BeginTransaction();
            this.Connection.ExecuteNonQuery(InsertarMovimiento);
            // Trans.Commit();
        }
Exemplo n.º 22
0
 private void MenuItemPegadoRapidoAgregar_Click(object sender, System.EventArgs e)
 {
     qGen.Insert Comando = new qGen.Insert("sys_quickpaste");
     Comando.Fields.AddWithValue("texto", this.Text);
     Comando.Fields.AddWithValue("estacion", Lfx.Environment.SystemInformation.MachineName);
     Comando.Fields.AddWithValue("usuario", Lbl.Sys.Config.Actual.UsuarioConectado.Id);
     Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
     Lfx.Workspace.Master.MasterConnection.Execute(Comando);
 }
Exemplo n.º 23
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.IStatement Comando;

            if (this.Existe == false)
            {
                Comando = new qGen.Insert(this.TablaDatos);
                Comando.ColumnValues.AddWithValue("fecha", new qGen.SqlExpression("NOW()"));
            }
            else
            {
                Comando             = new qGen.Update(this.TablaDatos);
                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
            }

            //if (this.Numero > 0)
            //    Comando.Fields.AddWithValue("id_formapago", this.Numero);

            Comando.ColumnValues.AddWithValue("nombre", this.Nombre);

            if (this.Registro["tipo"] != null)
            {
                Comando.ColumnValues.AddWithValue("tipo", this.Registro["tipo"].ToString());
            }

            if (this.Caja == null)
            {
                Comando.ColumnValues.AddWithValue("id_caja", null);
            }
            else
            {
                Comando.ColumnValues.AddWithValue("id_caja", this.Caja.Id);
            }

            if (Concepto_Ingreso != null)
            {
                Comando.ColumnValues.AddWithValue("id_concepto", this.Concepto_Ingreso.Id);
            }
            if (Concepto_Egreso != null)
            {
                Comando.ColumnValues.AddWithValue("id_concepto_egreso", this.Concepto_Egreso.Id);
            }
            Comando.ColumnValues.AddWithValue("descuento", this.Descuento);
            Comando.ColumnValues.AddWithValue("retencion", this.Retencion);
            Comando.ColumnValues.AddWithValue("autopres", this.AutoPresentacion);
            Comando.ColumnValues.AddWithValue("autoacred", this.AutoAcreditacion);
            Comando.ColumnValues.AddWithValue("adelantacuotas", false);
            Comando.ColumnValues.AddWithValue("dias_acred", this.DiasAcreditacion);
            Comando.ColumnValues.AddWithValue("pagos", this.PuedeHacerPagos);
            Comando.ColumnValues.AddWithValue("cobros", this.PuedeHacerCobros);
            Comando.ColumnValues.AddWithValue("obs", null);
            Comando.ColumnValues.AddWithValue("estado", true);

            this.AgregarTags(Comando);
            this.Connection.ExecuteNonQuery(Comando);
            return(base.Guardar());
        }
Exemplo n.º 24
0
        protected bool UpdateData()
        {
            bool correct = false;

            try
            {
                string stringValue = "";
                if (TieneRegistro)
                {
                    //Actualizar el valor
                    qGen.Update UpdateCommand = new qGen.Update("sys_config");
                    foreach (string field in codigobarra.Fields())
                    {
                        UpdateCommand.ColumnValues.Clear();
                        if (UpdateCommand.WhereClause != null)
                        {
                            UpdateCommand.WhereClause.Clear();
                        }

                        stringValue = ReturnValue(field);
                        UpdateCommand.ColumnValues.Add(new Lazaro.Orm.Data.ColumnValue("valor", Lazaro.Orm.ColumnTypes.VarChar, stringValue));
                        UpdateCommand.WhereClause          = new qGen.Where();
                        UpdateCommand.WhereClause.Operator = qGen.AndOr.And;
                        UpdateCommand.WhereClause.Add(new qGen.ComparisonCondition("nombre", field));
                        UpdateCommand.WhereClause.Add(new qGen.ComparisonCondition("id_sucursal", sucursalActual));
                        UpdateCommand.WhereClause.Add(new qGen.ComparisonCondition("estacion", terminalName));
                        UpdateCommand.WhereClause.Add(new qGen.ComparisonCondition("Grupo", "L"));
                        Connection.Update(UpdateCommand);
                    }
                }
                else
                {
                    //Crear el valor
                    qGen.Insert InsertCommand = new qGen.Insert("sys_config");
                    foreach (string field in codigobarra.Fields())
                    {
                        InsertCommand.ColumnValues.Clear();

                        stringValue = ReturnValue(field);
                        InsertCommand.ColumnValues.Add(new Lazaro.Orm.Data.ColumnValue("id_sucursal", Lazaro.Orm.ColumnTypes.Integer, sucursalActual));
                        InsertCommand.ColumnValues.Add(new Lazaro.Orm.Data.ColumnValue("estacion", Lazaro.Orm.ColumnTypes.VarChar, terminalName));
                        InsertCommand.ColumnValues.Add(new Lazaro.Orm.Data.ColumnValue("Grupo", Lazaro.Orm.ColumnTypes.VarChar, "L"));
                        InsertCommand.ColumnValues.Add(new Lazaro.Orm.Data.ColumnValue("nombre", Lazaro.Orm.ColumnTypes.VarChar, field));
                        InsertCommand.ColumnValues.Add(new Lazaro.Orm.Data.ColumnValue("valor", Lazaro.Orm.ColumnTypes.VarChar, stringValue));
                        Connection.Insert(InsertCommand);
                    }
                }
                correct = true;
            }
            catch (Exception exc)
            {
                correct = false;
                MessageBox.Show(exc.Message);
            }
            return(correct);
        }
Exemplo n.º 25
0
        public void Movimiento(bool auto, Lbl.Cajas.Concepto concepto, string textoConcepto,
                               Lbl.Personas.Persona cliente, decimal importe, string obs,
                               Lbl.Comprobantes.ComprobanteConArticulos factura, Lbl.Comprobantes.Recibo recibo, string comprobantes)
        {
            if (Lbl.Sys.Config.Actual.UsuarioConectado.TienePermiso(this, Lbl.Sys.Permisos.Operaciones.Mover) == false)
            {
                throw new Lfx.Types.Exceptions.AccessDeniedException("No tiene permiso para hacer movimientos en la caja solicitada");
            }

            decimal SaldoActual = this.ObtenerSaldo(true);

            qGen.TableCommand InsertarMovimiento = new qGen.Insert(this.Connection, "cajas_movim");
            InsertarMovimiento.Fields.AddWithValue("id_caja", this.Id);
            InsertarMovimiento.Fields.AddWithValue("auto", auto ? 1 : 0);
            if (concepto == null)
            {
                InsertarMovimiento.Fields.AddWithValue("id_concepto", null);
            }
            else
            {
                InsertarMovimiento.Fields.AddWithValue("id_concepto", concepto.Id);
            }
            InsertarMovimiento.Fields.AddWithValue("concepto", textoConcepto);
            InsertarMovimiento.Fields.AddWithValue("id_persona", Lbl.Sys.Config.Actual.UsuarioConectado.Id);
            if (cliente == null)
            {
                InsertarMovimiento.Fields.AddWithValue("id_cliente", null);
            }
            else
            {
                InsertarMovimiento.Fields.AddWithValue("id_cliente", cliente.Id);
            }
            InsertarMovimiento.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
            InsertarMovimiento.Fields.AddWithValue("importe", importe);
            if (factura == null)
            {
                InsertarMovimiento.Fields.AddWithValue("id_comprob", null);
            }
            else
            {
                InsertarMovimiento.Fields.AddWithValue("id_comprob", factura.Id);
            }
            if (recibo == null)
            {
                InsertarMovimiento.Fields.AddWithValue("id_recibo", null);
            }
            else
            {
                InsertarMovimiento.Fields.AddWithValue("id_recibo", recibo.Id);
            }
            InsertarMovimiento.Fields.AddWithValue("comprob", comprobantes);
            InsertarMovimiento.Fields.AddWithValue("saldo", SaldoActual + importe);
            InsertarMovimiento.Fields.AddWithValue("obs", obs);
            this.Connection.Execute(InsertarMovimiento);
        }
Exemplo n.º 26
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.IStatement Comando;
            if (this.Existe)
            {
                Comando             = new qGen.Update(this.TablaDatos);
                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
            }
            else
            {
                Comando = new qGen.Insert(this.TablaDatos);
            }

            Comando.ColumnValues.AddWithValue("fecha", new qGen.SqlExpression("NOW()"));

            if (this.FormaDePago == null)
            {
                throw new InvalidOperationException("Lbl.Pagos.Valor.Guardar: Debe especificar la forma de pago");
            }
            else
            {
                Comando.ColumnValues.AddWithValue("id_formapago", this.FormaDePago.Id);
            }

            if (this.Recibo == null)
            {
                throw new InvalidOperationException("Lbl.Pagos.Valor.Guardar: Debe especificar el recibo");
            }
            else
            {
                Comando.ColumnValues.AddWithValue("id_recibo", this.Recibo.Id);
            }

            if (this.Nombre == null || this.Nombre.Length == 0)
            {
                Comando.ColumnValues.AddWithValue("nombre", this.FormaDePago.ToString() + " Nº " + this.Numero);
            }
            else
            {
                Comando.ColumnValues.AddWithValue("nombre", this.Nombre);
            }

            Comando.ColumnValues.AddWithValue("numero", this.Numero);
            Comando.ColumnValues.AddWithValue("id_sucursal", Lfx.Workspace.Master.CurrentConfig.Empresa.SucursalActual);

            Comando.ColumnValues.AddWithValue("importe", this.Importe);
            Comando.ColumnValues.AddWithValue("obs", this.Obs);

            this.AgregarTags(Comando);

            this.Connection.ExecuteNonQuery(Comando);

            return(base.Guardar());
        }
Exemplo n.º 27
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.IStatement Comando;
            if (this.Existe == false)
            {
                Comando = new qGen.Insert(this.TablaDatos);
                Comando.ColumnValues.AddWithValue("fecha", new qGen.SqlExpression("NOW()"));
            }
            else
            {
                Comando             = new qGen.Update(this.TablaDatos);
                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
            }

            Comando.ColumnValues.AddWithValue("prefijo", this.Prefijo);
            Comando.ColumnValues.AddWithValue("numero", this.Numero);
            Comando.ColumnValues.AddWithValue("nombre", this.Nombre);

            if (this.Sucursal == null)
            {
                Comando.ColumnValues.AddWithValue("id_sucursal", null);
            }
            else
            {
                Comando.ColumnValues.AddWithValue("id_sucursal", this.Sucursal.Id);
            }

            if (this.Impresora == null)
            {
                Comando.ColumnValues.AddWithValue("id_impresora", null);
            }
            else
            {
                Comando.ColumnValues.AddWithValue("id_impresora", this.Impresora.Id);
            }
            Comando.ColumnValues.AddWithValue("tipo", (int)(this.Tipo));
            Comando.ColumnValues.AddWithValue("tipo_fac", this.TipoFac);
            Comando.ColumnValues.AddWithValue("detalonario", this.UsaTalonario ? 1 : 0);
            Comando.ColumnValues.AddWithValue("estacion", this.Estacion);
            Comando.ColumnValues.AddWithValue("carga", this.CargaManual ? 1 : 0);
            Comando.ColumnValues.AddWithValue("modelo", (int)(this.FiscalModeloImpresora));
            Comando.ColumnValues.AddWithValue("puerto", this.FiscalPuerto);
            Comando.ColumnValues.AddWithValue("bps", this.FiscalBps);
            Comando.ColumnValues.AddWithValue("variante", (int)this.Variante);
            Comando.ColumnValues.AddWithValue("enumerar", (int)this.Enumerar);
            Comando.ColumnValues.AddWithValue("id_persona", (int)this.Persona);

            this.AgregarTags(Comando);

            Connection.ExecuteNonQuery(Comando);

            return(base.Guardar());
        }
Exemplo n.º 28
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.IStatement Comando = new qGen.Insert(this.TablaDatos);
            Comando.ColumnValues.AddWithValue("id_comprob", this.IdComprobante);
            Comando.ColumnValues.AddWithValue("orden", this.Orden);

            if (this.Articulo == null)
            {
                Comando.ColumnValues.AddWithValue("id_articulo", null);
                Comando.ColumnValues.AddWithValue("nombre", this.Nombre);
                Comando.ColumnValues.AddWithValue("descripcion", "");
            }
            else
            {
                Comando.ColumnValues.AddWithValue("id_articulo", this.Articulo.Id);
                Comando.ColumnValues.AddWithValue("nombre", this.Articulo.Nombre);
                Comando.ColumnValues.AddWithValue("descripcion", this.Articulo.Descripcion);
            }

            if (this.Alicuota == null)
            {
                Comando.ColumnValues.AddWithValue("id_alicuota", null);
            }
            else
            {
                Comando.ColumnValues.AddWithValue("id_alicuota", this.Alicuota.Id);
            }

            Comando.ColumnValues.AddWithValue("cantidad", this.Cantidad);
            Comando.ColumnValues.AddWithValue("precio", this.ImporteUnitario);
            Comando.ColumnValues.AddWithValue("iva", this.ImporteIvaUnitario);
            Comando.ColumnValues.AddWithValue("recargo", this.Recargo);
            if (this.Costo == 0 && this.Articulo != null)
            {
                Comando.ColumnValues.AddWithValue("costo", this.Articulo.Costo);
            }
            else
            {
                Comando.ColumnValues.AddWithValue("costo", this.Costo);
            }
            Comando.ColumnValues.AddWithValue("importe", this.ImporteUnitarioAImprimir);
            Comando.ColumnValues.AddWithValue("importe", this.ImporteAImprimir);
            Comando.ColumnValues.AddWithValue("total", this.ImporteTotalConIvaFinal);
            Comando.ColumnValues.AddWithValue("series", this.DatosSeguimiento);
            Comando.ColumnValues.AddWithValue("obs", this.Obs);

            this.AgregarTags(Comando, this.Registro, this.TablaDatos);

            this.Connection.ExecuteNonQuery(Comando);

            return(base.Guardar());
        }
Exemplo n.º 29
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.TableCommand Comando;
            if (this.Existe == false)
            {
                Comando = new qGen.Insert(Connection, this.TablaDatos);
                Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
            }
            else
            {
                Comando             = new qGen.Update(Connection, this.TablaDatos);
                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
            }

            Comando.Fields.AddWithValue("prefijo", this.Prefijo);
            Comando.Fields.AddWithValue("numero", this.Numero);
            Comando.Fields.AddWithValue("nombre", this.Nombre);

            if (this.Sucursal == null)
            {
                Comando.Fields.AddWithValue("id_sucursal", null);
            }
            else
            {
                Comando.Fields.AddWithValue("id_sucursal", this.Sucursal.Id);
            }

            if (this.Impresora == null)
            {
                Comando.Fields.AddWithValue("id_impresora", null);
            }
            else
            {
                Comando.Fields.AddWithValue("id_impresora", this.Impresora.Id);
            }
            Comando.Fields.AddWithValue("tipo", (int)(this.Tipo));
            Comando.Fields.AddWithValue("tipo_fac", this.TipoFac);
            Comando.Fields.AddWithValue("detalonario", this.UsaTalonario ? 1 : 0);
            Comando.Fields.AddWithValue("estacion", this.Estacion);
            Comando.Fields.AddWithValue("carga", this.CargaManual ? 1 : 0);
            Comando.Fields.AddWithValue("modelo", (int)(this.ModeloImpresoraFiscal));
            Comando.Fields.AddWithValue("puerto", this.Puerto);
            Comando.Fields.AddWithValue("bps", this.Bps);

            this.AgregarTags(Comando);

            Connection.Execute(Comando);

            return(base.Guardar());
        }
Exemplo n.º 30
0
        public bool WriteGlobalSetting(string settingName, string stringValue, string terminalName, int sucursal)
        {
            if (terminalName == null || terminalName.Length == 0)
            {
                terminalName = Lfx.Environment.SystemInformation.MachineName;
            }

            string CurrentValue = ReadGlobalSetting <string>(settingName, null, terminalName, sucursal);

            if (CurrentValue == null)
            {
                //Crear el valor
                qGen.Insert InsertCommand = new qGen.Insert("sys_config");
                InsertCommand.ColumnValues.Add(new Lazaro.Orm.Data.ColumnValue("estacion", Lazaro.Orm.ColumnTypes.VarChar, terminalName));
                InsertCommand.ColumnValues.Add(new Lazaro.Orm.Data.ColumnValue("id_sucursal", Lazaro.Orm.ColumnTypes.Integer, sucursal));
                InsertCommand.ColumnValues.Add(new Lazaro.Orm.Data.ColumnValue("nombre", Lazaro.Orm.ColumnTypes.VarChar, settingName));
                InsertCommand.ColumnValues.Add(new Lazaro.Orm.Data.ColumnValue("valor", Lazaro.Orm.ColumnTypes.VarChar, stringValue));
                Connection.Insert(InsertCommand);
            }
            else
            {
                //Actualizar el valor
                qGen.Update UpdateCommand = new qGen.Update("sys_config");
                UpdateCommand.ColumnValues.Add(new Lazaro.Orm.Data.ColumnValue("valor", Lazaro.Orm.ColumnTypes.VarChar, stringValue));
                UpdateCommand.WhereClause          = new qGen.Where();
                UpdateCommand.WhereClause.Operator = qGen.AndOr.And;
                UpdateCommand.WhereClause.Add(new qGen.ComparisonCondition("nombre", settingName));
                UpdateCommand.WhereClause.Add(new qGen.ComparisonCondition("estacion", terminalName));
                UpdateCommand.WhereClause.Add(new qGen.ComparisonCondition("id_sucursal", sucursal));
                Connection.Update(UpdateCommand);
            }

            string CacheSettingName = terminalName + "/" + sucursal.ToString() + "/" + settingName;

            if (this.SysConfigCache.ContainsKey(CacheSettingName))
            {
                this.SysConfigCache[CacheSettingName] = stringValue;
            }
            else
            {
                this.SysConfigCache.Add(CacheSettingName, stringValue);
            }

            return(true);
        }
Exemplo n.º 31
0
        /// <summary>
        /// Agrega un comentario al historial de este elemento. El comentario se guarda inmediatamente en el historial.
        /// Sólo se pueden agregar comentarios al elemento una vez que este fue guardado.
        /// </summary>
        /// <param name="texto">El texto del comentario.</param>
        public void AgregarComentario(string texto)
        {
            if (this.Existe == false)
            {
                throw new Lfx.Types.DomainException("No se pueden agregar comentarios a un elemento que aun no ha sido guardado.");
            }

            qGen.Insert NuevoCom = new qGen.Insert("sys_log");
            NuevoCom.Fields.AddWithValue("estacion", Lfx.Environment.SystemInformation.MachineName);
            NuevoCom.Fields.AddWithValue("tabla", this.TablaDatos);
            NuevoCom.Fields.AddWithValue("comando", "Comment");
            NuevoCom.Fields.AddWithValue("item_id", this.Id);
            NuevoCom.Fields.AddWithValue("usuario", Lbl.Sys.Config.Actual.UsuarioConectado.Id);
            NuevoCom.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
            NuevoCom.Fields.AddWithValue("extra1", texto);

            this.Connection.Execute(NuevoCom);
        }
Exemplo n.º 32
0
        public override Lfx.Types.OperationResult Guardar()
        {
            qGen.TableCommand Comando;

            if (this.Existe == false)
            {
                Comando = new qGen.Insert(this.Connection, this.TablaDatos);
            }
            else
            {
                Comando             = new qGen.Update(this.Connection, this.TablaDatos);
                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
            }

            Comando.Fields.AddWithValue("nombre", this.Nombre);
            Comando.Fields.AddWithValue("nombresing", this.NombreSingular);
            Comando.Fields.AddWithValue("stock_minimo", this.PuntoDeReposicion);
            Comando.Fields.AddWithValue("web", this.PublicacionWeb);
            Comando.Fields.AddWithValue("requierens", ((int)(this.Seguimiento)));
            Comando.Fields.AddWithValue("obs", this.Obs);
            if (this.Rubro == null)
            {
                Comando.Fields.AddWithValue("id_rubro", null);
            }
            else
            {
                Comando.Fields.AddWithValue("id_rubro", this.Rubro.Id);
            }
            if (this.Alicuota == null)
            {
                Comando.Fields.AddWithValue("id_alicuota", null);
            }
            else
            {
                Comando.Fields.AddWithValue("id_alicuota", this.Alicuota.Id);
            }
            Comando.Fields.AddWithValue("garantia", this.Garantia);

            this.AgregarTags(Comando);

            this.Connection.Execute(Comando);

            return(base.Guardar());
        }
Exemplo n.º 33
0
                public override Lfx.Types.OperationResult Ok()
                {
                        if (EntradaTicket.ValueInt == 0)
                                return new Lfx.Types.FailureOperationResult("Escriba el código de Ticket");

                        using (System.Data.IDbTransaction Trans = this.Connection.BeginTransaction()) {
                                qGen.Insert InsertarNovedad = new qGen.Insert(Connection, "tickets_eventos");
                                InsertarNovedad.Fields.AddWithValue("id_ticket", EntradaTicket.ValueInt);
                                InsertarNovedad.Fields.AddWithValue("id_tecnico", EntradaEncargado.ValueInt);
                                InsertarNovedad.Fields.AddWithValue("minutos_tecnico", Lfx.Types.Parsing.ParseInt(EntradaMinutos.Text));
                                InsertarNovedad.Fields.AddWithValue("privado", EntradaCondicion.TextKey);
                                InsertarNovedad.Fields.AddWithValue("descripcion", EntradaDescripcion.Text);
                                InsertarNovedad.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                                this.Connection.Execute(InsertarNovedad);
                                Trans.Commit();
                        }

                        return base.Ok();
                }
Exemplo n.º 34
0
                public override Lfx.Types.OperationResult Guardar()
                {
                        qGen.TableCommand Comando;
                        if (this.Existe == false) {
                                Comando = new qGen.Insert(Connection, "conceptos");
                        } else {
                                Comando = new qGen.Update(Connection, "conceptos");
                                Comando.WhereClause = new qGen.Where("id_concepto", this.Id);
                        }

                        Comando.Fields.AddWithValue("nombre", this.Nombre);
                        Comando.Fields.AddWithValue("es", this.Direccion);
                        if (this.Grupo == 0)
                                Comando.Fields.AddWithValue("grupo", null);
                        else
                                Comando.Fields.AddWithValue("grupo", this.Grupo);

                        Connection.Execute(Comando);

                        return base.Guardar();
                }
Exemplo n.º 35
0
                public override Lfx.Types.OperationResult Guardar()
                {
                        qGen.TableCommand Comando;
                        if (this.Existe == false) {
                                Comando = new qGen.Insert(Connection, "personas_grupos");
                                Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                        } else {
                                Comando = new qGen.Update(Connection, "personas_grupos");
                                Comando.WhereClause = new qGen.Where("id_grupo", this.Id);
                        }

                        Comando.Fields.AddWithValue("nombre", this.Nombre);
                        Comando.Fields.AddWithValue("descuento", this.Descuento);
                        Comando.Fields.AddWithValue("predet", this.Predeterminado ? 1 : 0);
                        if (this.Parent != null)
                                Comando.Fields.AddWithValue("parent", this.Parent.Id);
                        else
                                Comando.Fields.AddWithValue("parent", null);

                        Connection.Execute(Comando);
                        
                        return base.Guardar();
                }
Exemplo n.º 36
0
		public override Lfx.Types.OperationResult Guardar()
                {
			qGen.TableCommand Comando;

                        if (this.Existe == false) {
                                Comando = new qGen.Insert(this.Connection, this.TablaDatos);
                        } else {
                                Comando = new qGen.Update(this.Connection, this.TablaDatos);
                                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
                        }

                        Comando.Fields.AddWithValue("nombre", this.Nombre);
                        if (this.Alicuota == null)
                                Comando.Fields.AddWithValue("id_alicuota", null);
                        else
                                Comando.Fields.AddWithValue("id_alicuota", this.Alicuota.Id);

			this.AgregarTags(Comando);

                        this.Connection.Execute(Comando);

			return base.Guardar();
		}
Exemplo n.º 37
0
                public override Lfx.Types.OperationResult Guardar()
                {
                        qGen.TableCommand Comando;

                        if (this.Existe == false) {
                                Comando = new qGen.Insert(this.Connection, this.TablaDatos);
                                Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                        } else {
                                Comando = new qGen.Update(this.Connection, this.TablaDatos);
                                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
                        }

                        Comando.Fields.AddWithValue("nombre", this.Nombre);
                        Comando.Fields.AddWithValue("porcentaje", this.Porcentaje);
                        Comando.Fields.AddWithValue("predet", this.Predeterminado ? 1 : 0);
                        Comando.Fields.AddWithValue("obs", this.Obs);
                        Comando.Fields.AddWithValue("estado", this.Estado);

                        this.AgregarTags(Comando);

                        this.Connection.Execute(Comando);

                        return base.Guardar();
                }
Exemplo n.º 38
0
		public override Lfx.Types.OperationResult Guardar()
                {
			qGen.TableCommand Comando;

                        if (this.Existe == false) {
                                Comando = new qGen.Insert(this.Connection, this.TablaDatos);
                        } else {
                                Comando = new qGen.Update(this.Connection, this.TablaDatos);
                                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
                        }

                        Comando.Fields.AddWithValue("nombre", this.Nombre);
                        Comando.Fields.AddWithValue("nombresing", this.NombreSingular);
                        Comando.Fields.AddWithValue("stock_minimo", this.PuntoDeReposicion);
                        Comando.Fields.AddWithValue("web", this.PublicacionWeb);
                        Comando.Fields.AddWithValue("requierens", ((int)(this.Seguimiento)));
                        Comando.Fields.AddWithValue("obs", this.Obs);
                        if (this.Rubro == null)
                                Comando.Fields.AddWithValue("id_rubro", null);
                        else
                                Comando.Fields.AddWithValue("id_rubro", this.Rubro.Id);
                        if (this.Alicuota == null)
                                Comando.Fields.AddWithValue("id_alicuota", null);
                        else
                                Comando.Fields.AddWithValue("id_alicuota", this.Alicuota.Id);
                        Comando.Fields.AddWithValue("garantia", this.Garantia);

			this.AgregarTags(Comando);

                        this.Connection.Execute(Comando);

			return base.Guardar();
		}
Exemplo n.º 39
0
                private void GuardarDetalle()
                {
                        this.Articulos.ElementoPadre = this;

                        qGen.Delete EliminarDetallesViejos = new qGen.Delete("comprob_detalle");
                        EliminarDetallesViejos.WhereClause = new qGen.Where("id_comprob", this.Id);
                        this.Connection.Execute(EliminarDetallesViejos);

                        int i = 1;
                        for (int Pasada = 1; Pasada <= 2; Pasada++) {
                                foreach (Lbl.Comprobantes.DetalleArticulo Art in m_Articulos) {
                                        // En la primera pasada, guardo sólo importes y cantidades positivos (o cero)
                                        // en la segunda pasada, guardo sólo los negativos.
                                        // De esa manera, los negativos siempre quedan últimos
                                        // lo cual es un requerimiento de las fiscales Hasar.
                                        if ((Pasada == 1 && Art.Cantidad >= 0 && Art.Unitario >= 0)
                                                || (Pasada == 2 && (Art.Cantidad < 0 || Art.Unitario < 0))) {
                                                qGen.TableCommand Comando = new qGen.Insert(this.Connection, "comprob_detalle");
                                                Comando.Fields.AddWithValue("id_comprob", this.Id);
                                                Comando.Fields.AddWithValue("orden", i);

                                                if (Art.Articulo == null) {
                                                        Comando.Fields.AddWithValue("id_articulo", null);
                                                        Comando.Fields.AddWithValue("nombre", Art.Nombre);
                                                        Comando.Fields.AddWithValue("descripcion", "");
                                                } else {
                                                        Comando.Fields.AddWithValue("id_articulo", Art.Articulo.Id);
                                                        Comando.Fields.AddWithValue("nombre", Art.Nombre);
                                                        Comando.Fields.AddWithValue("descripcion", Art.Articulo.Descripcion);
                                                }

                                                Comando.Fields.AddWithValue("cantidad", Art.Cantidad);
                                                Comando.Fields.AddWithValue("precio", Art.Unitario);
                                                Comando.Fields.AddWithValue("iva", Art.ImporteIva);
                                                Comando.Fields.AddWithValue("recargo", Art.Recargo);
                                                if (Art.Costo == 0 && Art.Articulo != null)
                                                        Comando.Fields.AddWithValue("costo", Art.Articulo.Costo);
                                                else
                                                        Comando.Fields.AddWithValue("costo", Art.Costo);
                                                Comando.Fields.AddWithValue("importe", Art.ImporteAImprimir);
                                                Comando.Fields.AddWithValue("total", Art.ImporteConIva);
                                                Comando.Fields.AddWithValue("series", Art.DatosSeguimiento);
                                                Comando.Fields.AddWithValue("obs", Art.Obs);

                                                this.AgregarTags(Comando, Art.Registro, "comprob_detalle");

                                                this.Connection.Execute(Comando);
                                                i++;
                                        }
                                }
                        }
                }
Exemplo n.º 40
0
                public override Lfx.Types.OperationResult Ok()
                {
                        if (EntradaPv.ValueInt < 0 || EntradaPv.ValueInt > 999) {
                                LabelAyuda.Text = "Seleccione el Tipo de Comprobante y un Punto de Venta apropiado.";
                                OkButton.Enabled = false;
                        }

                        using (IDbTransaction Trans = this.Connection.BeginTransaction()) {
                                qGen.Insert InsertarComprob = new qGen.Insert("comprob");

                                switch (EntradaTipo.TextKey) {
                                        case "A":
                                        case "B":
                                        case "C":
                                        case "E":
                                        case "M":
                                                InsertarComprob.Fields.AddWithValue("tipo_fac", "F" + EntradaTipo.TextKey);
                                                break;
                                        default:
                                                InsertarComprob.Fields.AddWithValue("tipo_fac", EntradaTipo.TextKey);
                                                break;
                                }
                                InsertarComprob.Fields.AddWithValue("id_formapago", 3);
                                InsertarComprob.Fields.AddWithValue("id_sucursal", Lfx.Workspace.Master.CurrentConfig.Empresa.SucursalActual);
                                InsertarComprob.Fields.AddWithValue("pv", EntradaPv.ValueInt);
                                InsertarComprob.Fields.AddWithValue("numero", EntradaDesde.ValueInt - 1);
                                InsertarComprob.Fields.AddWithValue("fecha", new DateTime(1900, 1, 1, 0, 0, 0));
                                InsertarComprob.Fields.AddWithValue("id_vendedor", Lbl.Sys.Config.Actual.UsuarioConectado.Id);
                                InsertarComprob.Fields.AddWithValue("id_cliente", Lbl.Sys.Config.Actual.UsuarioConectado.Id);
                                InsertarComprob.Fields.AddWithValue("obs", "Marcador de inicio de numeración.");
                                InsertarComprob.Fields.AddWithValue("impresa", 1);
                                InsertarComprob.Fields.AddWithValue("anulada", 1);
                                this.Connection.Execute(InsertarComprob);
                                Trans.Commit();
                        }

                        return base.Ok();
                }
Exemplo n.º 41
0
		public override Lfx.Types.OperationResult Guardar()
		{
			qGen.TableCommand Comando;
                        if (this.Existe) {
				Comando = new qGen.Update(this.Connection, this.TablaDatos);
				Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
			} else {
				Comando = new qGen.Insert(this.Connection, this.TablaDatos);
			}

			Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                        if (this.Concepto == null)
                                Comando.Fields.AddWithValue("id_concepto", null);
                        else
                                Comando.Fields.AddWithValue("id_concepto", this.Concepto.Id);

                        if (this.ConceptoTexto == null || this.ConceptoTexto.Length == 0) {
				if (this.Concepto == null)
					Comando.Fields.AddWithValue("concepto", "");
				else
                                	Comando.Fields.AddWithValue("concepto", this.Concepto.Nombre);
			} else {
                                Comando.Fields.AddWithValue("concepto", this.ConceptoTexto);
			}

                        if (this.Banco == null)
                                Comando.Fields.AddWithValue("id_banco", null);
                        else
                                Comando.Fields.AddWithValue("id_banco", this.Banco.Id);

                        if (this.Chequera == null)
                                Comando.Fields.AddWithValue("id_chequera", null);
                        else
                                Comando.Fields.AddWithValue("id_chequera", this.Chequera.Id);

			Comando.Fields.AddWithValue("numero", this.Numero);
			Comando.Fields.AddWithValue("id_sucursal", Lfx.Workspace.Master.CurrentConfig.Empresa.SucursalActual);

                        if (this.ReciboCobro == null)
                                Comando.Fields.AddWithValue("id_recibo", null);
                        else
                                Comando.Fields.AddWithValue("id_recibo", this.ReciboCobro.Id);

                        if (this.ReciboPago == null)
                                Comando.Fields.AddWithValue("id_recibo_pago", null);
                        else
                                Comando.Fields.AddWithValue("id_recibo_pago", this.ReciboPago.Id);

                        if (this.Cliente == null && this.ReciboCobro != null)
                                this.Cliente = this.ReciboCobro.Cliente;
                        if (this.Cliente == null && this.ReciboPago != null)
                                this.Cliente = this.ReciboPago.Cliente;

                        if (this.Cliente == null)
                                Comando.Fields.AddWithValue("id_cliente", null);
                        else
                                Comando.Fields.AddWithValue("id_cliente", this.Cliente.Id);
                        
                        if (this.Factura == null)
                                Comando.Fields.AddWithValue("id_comprob", null);
                        else
                                Comando.Fields.AddWithValue("id_comprob", this.Factura.Id);

                        if (this.Emitido)
                                Comando.Fields.AddWithValue("nombre", "Nº " + this.Numero + " por " + Lbl.Sys.Config.Moneda.Simbolo + " " + Lfx.Types.Formatting.FormatCurrency(this.Importe, 2));
                        else
                                Comando.Fields.AddWithValue("nombre", "Nº " + this.Numero + " por " + Lbl.Sys.Config.Moneda.Simbolo + " " + Lfx.Types.Formatting.FormatCurrency(this.Importe, 2) + " emitido por " + this.Emisor);
			Comando.Fields.AddWithValue("importe", this.Importe);
			Comando.Fields.AddWithValue("fechaemision", this.FechaEmision);
			Comando.Fields.AddWithValue("emitidopor", this.Emisor);
                        Comando.Fields.AddWithValue("emitido", this.Emitido ? 1 : 0);
                        Comando.Fields.AddWithValue("estado", this.Estado);
			Comando.Fields.AddWithValue("fechacobro", this.FechaCobro);
			Comando.Fields.AddWithValue("obs", this.Obs);

			this.AgregarTags(Comando);

			this.Connection.Execute(Comando);

                        if (this.Chequera != null) {
                                qGen.Update ActualizarChequeras = new qGen.Update("chequeras");
                                ActualizarChequeras.Fields.AddWithValue("cheques_emitidos", new qGen.SqlExpression("cheques_emitidos+1"));
                                ActualizarChequeras.WhereClause = new qGen.Where("id_chequera", this.Chequera.Id);
                                this.Connection.Execute(ActualizarChequeras);
                        }

                        if (this.Existe == false && this.Emitido == false) {
                                //Asiento en la cuenta cheques, sólo para cheques de cobro
                                Cajas.Caja CajaCheques = new Lbl.Cajas.Caja(this.Connection, Lfx.Workspace.Master.CurrentConfig.Empresa.CajaCheques);
                                Lbl.Personas.Persona UsarCliente = this.Cliente;
                                if (UsarCliente == null && this.Factura != null)
                                        UsarCliente = this.Factura.Cliente;
                                if (UsarCliente == null && this.ReciboCobro != null)
                                        UsarCliente = this.ReciboCobro.Cliente;
                                if (UsarCliente == null && this.ReciboPago != null)
                                        UsarCliente = this.ReciboPago.Cliente;
                                CajaCheques.Movimiento(true, 
                                        this.Concepto, this.ConceptoTexto, 
                                        UsarCliente, 
                                        this.ReciboPago != null ? -this.Importe : this.Importe,
                                        this.ToString(), 
                                        this.Factura, 
                                        this.ReciboCobro != null ? this.ReciboCobro : this.ReciboPago, 
                                        null);
                        }

                        return base.Guardar();
		}
Exemplo n.º 42
0
                public override IElementoDeDatos ConvertirRegistroEnElemento(MapaDeTabla mapa, Lfx.Data.Row externalRow, Lfx.Data.Row internalRow)
                {
                        switch (mapa.TablaLazaro) {
                                case "ctacte":
                                        Lbl.IElementoDeDatos ElemMovim = base.ConvertirRegistroEnElemento(mapa, externalRow, internalRow);
                                        Lbl.CuentasCorrientes.Movimiento Movim = ElemMovim as Lbl.CuentasCorrientes.Movimiento;
                                        if (Movim != null) {
                                                if (Movim.IdCliente == 0)
                                                        return null;

                                                Movim.Auto = true;
                                                string TipoComprobVentre = externalRow["original_TIPO"].ToString();
                                                if (TipoComprobVentre == "FCB") {
                                                        TipoComprobVentre = "Factura";
                                                } else if (TipoComprobVentre == "RCB") {
                                                        TipoComprobVentre = "Recibo";
                                                        Movim.Importe = -Movim.Importe;
                                                } else if (TipoComprobVentre == "NCB") {
                                                        TipoComprobVentre = "Nota de Crédito";
                                                        Movim.Importe = -Movim.Importe;
                                                }
                                                Movim.Nombre = TipoComprobVentre + " 0001-" + System.Convert.ToInt32(externalRow["original_NROCOM"]).ToString("00000000");
                                        }
                                        return ElemMovim;

                                case "comprob_detalle":
                                        // Busco una factura a la cual adosar este detalle
                                        string Tipo = externalRow["TIPO"].ToString(), TipoLazaro = null;
                                        bool Compra = false;
                                        int Numero = Lfx.Types.Parsing.ParseInt(externalRow["NROCOM"].ToString());
                                        switch (Tipo) {
                                                case "FCA":
                                                        TipoLazaro = "FA";
                                                        break;
                                                case "FCB":
                                                        TipoLazaro = "FB";
                                                        break;
                                                case "ING":
                                                        TipoLazaro = "FA";
                                                        Compra = true;
                                                        break;
                                                case "DEV":
                                                        TipoLazaro = "NCB";
                                                        break;
                                        }

                                        if (Numero > 0 && TipoLazaro != null) {
                                                // Es una factura válida
                                                Lbl.Comprobantes.Factura Fac;

                                                qGen.Select SelFac = new qGen.Select("comprob");
                                                SelFac.WhereClause = new qGen.Where();
                                                SelFac.WhereClause.AddWithValue("tipo_fac", TipoLazaro);
                                                SelFac.WhereClause.AddWithValue("compra", Compra ? 1 : 0);
                                                SelFac.WhereClause.AddWithValue("numero", Numero);
                                                Lfx.Data.Row FacRow = this.Connection.FirstRowFromSelect(SelFac);

                                                if (FacRow == null) {
                                                        int Cliente = System.Convert.ToInt32(externalRow["CLIENTE"]);
                                                        if (Cliente <= 0)
                                                                Cliente = 999;
                                                        qGen.Insert NewFac = new qGen.Insert("comprob");
                                                        NewFac.Fields.AddWithValue("id_formapago", 1);
                                                        NewFac.Fields.AddWithValue("tipo_fac", TipoLazaro);
                                                        NewFac.Fields.AddWithValue("pv", 1);
                                                        NewFac.Fields.AddWithValue("numero", Numero);
                                                        NewFac.Fields.AddWithValue("situacionorigen", 1);
                                                        NewFac.Fields.AddWithValue("situaciondestino", 999);
                                                        NewFac.Fields.AddWithValue("fecha", System.Convert.ToDateTime(externalRow["FECHA"]));
                                                        NewFac.Fields.AddWithValue("id_vendedor", 1);
                                                        NewFac.Fields.AddWithValue("id_cliente", Cliente);
                                                        NewFac.Fields.AddWithValue("impresa", 1);
                                                        NewFac.Fields.AddWithValue("id_sucursal", 1);
                                                        NewFac.Fields.AddWithValue("estado", 1);
                                                        this.Connection.Execute(NewFac);

                                                        FacRow = this.Connection.FirstRowFromSelect(SelFac);
                                                }

                                                Fac = new Comprobantes.Factura(this.Connection, FacRow);
                                                if (internalRow != null)
                                                        internalRow.Fields.AddWithValue("id_comprob", Fac.Id);
                                                Lbl.IElementoDeDatos Elem = base.ConvertirRegistroEnElemento(mapa, externalRow, internalRow);
                                                Lbl.Comprobantes.DetalleArticulo DetArt = Elem as Lbl.Comprobantes.DetalleArticulo;
                                                if (DetArt != null) {
                                                        if (DetArt.Articulo == null)
                                                                DetArt.Nombre = externalRow["original_CODIGO"].ToString();
                                                        DetArt.IdComprobante = Fac.Id;
                                                }
                                                return Elem;
                                        }
                                        break;
                        }

                        return base.ConvertirRegistroEnElemento(mapa, externalRow, internalRow);
                }
Exemplo n.º 43
0
                public override Lfx.Types.OperationResult Guardar()
                {
                        qGen.TableCommand Comando;

                        if (this.Existe == false) {
                                Comando = new qGen.Insert(this.Connection, this.TablaDatos);
                                Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                        } else {
                                Comando = new qGen.Update(this.Connection, this.TablaDatos);
                                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
                        }

                        Comando.Fields.AddWithValue("id_ticket", this.Tarea.Id);
                        if (this.Persona == null)
                                Comando.Fields.AddWithValue("id_tecnico", this.Persona.Id);
                        else
                                Comando.Fields.AddWithValue("id_tecnico", null);
                        Comando.Fields.AddWithValue("descripcion", this.Descripcion);
                        Comando.Fields.AddWithValue("estado", this.Estado);
                        Comando.Fields.AddWithValue("minutos_tecnico", this.Minutos);
                        Comando.Fields.AddWithValue("privado", this.Privado ? 1 : 0);

                        this.AgregarTags(Comando);

                        this.Connection.Execute(Comando);

                        return base.Guardar();
                }
Exemplo n.º 44
0
                public override Lfx.Types.OperationResult Guardar()
                {
                        qGen.TableCommand Comando;
                        if (this.Existe == false) {
                                Comando = new qGen.Insert(Connection, this.TablaDatos);
                                Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                        } else {
                                Comando = new qGen.Update(Connection, this.TablaDatos);
                                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
                        }

                        Comando.Fields.AddWithValue(this.CampoNombre, this.Nombre);
                        Comando.Fields.AddWithValue("titular", this.Titular);
                        if (Banco == null)
                                Comando.Fields.AddWithValue("id_banco", null);
                        else
                                Comando.Fields.AddWithValue("id_banco", this.Banco.Id);
                        if (this.Moneda == null)
                                Comando.Fields.AddWithValue("id_moneda", null);
                        else
                                Comando.Fields.AddWithValue("id_moneda", this.Moneda.Id);
                        Comando.Fields.AddWithValue("numero", this.Numero);
                        Comando.Fields.AddWithValue("tipo", (int)(this.Tipo));
                        Comando.Fields.AddWithValue("cbu", this.ClaveBancaria);
                        Comando.Fields.AddWithValue("estado", this.Estado);

                        Connection.Execute(Comando);

                        return base.Guardar();
                }
Exemplo n.º 45
0
                public override Lfx.Types.OperationResult Guardar()
                {
                        this.Cliente.Connection = this.Connection;
                        if (this.Facturas != null) {
                                foreach (Lbl.Comprobantes.ComprobanteImporte Comp in this.Facturas) {
                                        Comp.Comprobante.Connection = this.Connection;
                                }
                        }

                        if (this.Concepto == null) {
                                //Concepto predeterminado para recibos
                                if (this.DePago)
                                        //Compra de mercadería
                                        this.Concepto = new Lbl.Cajas.Concepto(this.Connection, 21000);
                                else
                                        //Ingresos por facturación
                                        this.Concepto = Lbl.Cajas.Concepto.IngresosPorFacturacion;
                        } else {
                                this.Concepto.Connection = this.Connection;
                        }
                        if (this.Tipo.NumerarAlGuardar)
                                this.Numerar(false);

                        // Asiento el recibo
                        qGen.TableCommand Comando;

                        if (this.Existe == false) {
                                Comando = new qGen.Insert(this.Connection, this.TablaDatos);
                                Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                        } else {
                                throw new Lfx.Types.DomainException("Lbl: No se puede cambiar un recibo impreso");
                        }

                        if (this.Concepto != null)
                                Comando.Fields.AddWithValue("id_concepto", this.Concepto.Id);
                        else
                                Comando.Fields.AddWithValue("id_concepto", null);

                        Comando.Fields.AddWithValue("concepto", this.ConceptoTexto);
                        Comando.Fields.AddWithValue("tipo_fac", this.Tipo.Nomenclatura);
                        Comando.Fields.AddWithValue("pv", this.PV);
                        Comando.Fields.AddWithValue("numero", this.Numero);
                        Comando.Fields.AddWithValue("nombre", this.PV.ToString("0000") + "-" + this.Numero.ToString("00000000"));
                        Comando.Fields.AddWithValue("id_vendedor", Lfx.Data.Connection.ConvertZeroToDBNull(this.Vendedor.Id));
                        Comando.Fields.AddWithValue("id_cliente", Lfx.Data.Connection.ConvertZeroToDBNull(this.Cliente.Id));
                        Comando.Fields.AddWithValue("id_sucursal", Lfx.Workspace.Master.CurrentConfig.Empresa.SucursalActual);
                        Comando.Fields.AddWithValue("total", this.Total);
                        Comando.Fields.AddWithValue("obs", this.Obs);

                        this.AgregarTags(Comando);

                        this.Connection.Execute(Comando);
                        this.ActualizarId();

                        string ObsPago = string.Empty;
                        if (this.Obs != null && this.Obs.Length > 0)
                                ObsPago += this.Obs + " ///";
                        else if (this.DePago)
                                ObsPago = "Pago";
                        else
                                ObsPago = "Cobro";

                        ObsPago += " s/" + this.ToString(true);

                        if (ConceptoTexto == null || ConceptoTexto.Length == 0)
                                ConceptoTexto = ObsPago;

                        // Asiento los valores
                        foreach (Cobro Pg in this.Cobros) {
                                Pg.Concepto = this.Concepto;
                                Pg.ConceptoTexto = this.ConceptoTexto;
                                switch (Pg.FormaDePago.Tipo) {
                                        case Lbl.Pagos.TiposFormasDePago.Efectivo:
                                                Cajas.Caja CajaDiaria = new Cajas.Caja(this.Connection, Lfx.Workspace.Master.CurrentConfig.Empresa.CajaDiaria);
                                                CajaDiaria.Movimiento(true, this.Concepto, this.ConceptoTexto, Cliente, Pg.Importe, ObsPago, null, this, string.Empty);
                                                break;
                                        case Lbl.Pagos.TiposFormasDePago.ChequePropio:
                                        case Lbl.Pagos.TiposFormasDePago.ChequeTerceros:
                                                Pg.Cheque.Connection = this.Connection;
                                                Pg.Cheque.Obs = ObsPago;
                                                Pg.Cheque.Concepto = Pg.Concepto;
                                                Pg.Cheque.ConceptoTexto = Pg.ConceptoTexto;
                                                if (this.DePago)
                                                        Pg.Cheque.ReciboPago = this;
                                                else
                                                        Pg.Cheque.ReciboCobro = this;
                                                Pg.Cheque.Cliente = this.Cliente;
                                                Pg.Cheque.Emitido = Pg.FormaDePago.Tipo == Lbl.Pagos.TiposFormasDePago.ChequePropio;
                                                Lfx.Types.OperationResult ResultadoCheque = Pg.Cheque.Guardar();
                                                if (ResultadoCheque.Success == false)
                                                        return ResultadoCheque;
                                                break;
                                        case Lbl.Pagos.TiposFormasDePago.Tarjeta:
                                                Pg.Cupon.Connection = this.Connection;
                                                Pg.Cupon.Obs = ObsPago;
                                                Pg.Cupon.ConceptoTexto = Pg.ConceptoTexto;
                                                Pg.Cupon.Recibo = this;
                                                Pg.Cupon.Cliente = this.Cliente;
                                                Lfx.Types.OperationResult ResultadoCupon = Pg.Cupon.Guardar();
                                                if (ResultadoCupon.Success == false)
                                                        return ResultadoCupon;
                                                break;
                                        case Lbl.Pagos.TiposFormasDePago.Caja:
                                                Pg.CajaDestino.Connection = this.Connection;
                                                Pg.CajaDestino.Movimiento(true, Pg.Concepto, Pg.ConceptoTexto, this.Cliente, Pg.Importe, ObsPago, null, this, string.Empty);
                                                break;
                                        case Lbl.Pagos.TiposFormasDePago.OtroValor:
                                                Pg.Valor.Connection = this.Connection;
                                                Pg.Valor.Obs = ObsPago;
                                                Pg.Valor.Recibo = this;
                                                Lfx.Types.OperationResult ResultadoValor = Pg.Valor.Guardar();
                                                if (ResultadoValor.Success == false)
                                                        return ResultadoValor;
                                                break;
                                }
                        }

                        foreach (Pago Pg in this.Pagos) {
                                Pg.Concepto = this.Concepto;
                                Pg.ConceptoTexto = this.ConceptoTexto;
                                switch (Pg.FormaDePago.Tipo) {
                                        case Lbl.Pagos.TiposFormasDePago.Efectivo:
                                                Cajas.Caja CajaDiaria = new Cajas.Caja(this.Connection, Lfx.Workspace.Master.CurrentConfig.Empresa.CajaDiaria);
                                                CajaDiaria.Movimiento(true, Pg.Concepto, Pg.ConceptoTexto, this.Cliente, -Pg.Importe, ObsPago, null, this, string.Empty);
                                                break;
                                        case Lbl.Pagos.TiposFormasDePago.ChequePropio:
                                                Pg.Cheque.Connection = this.Connection;
                                                Pg.Cheque.Concepto = Pg.Concepto;
                                                Pg.Cheque.Cliente = this.Cliente;
                                                Pg.Cheque.ConceptoTexto = Pg.ConceptoTexto;
                                                Pg.Cheque.Obs = ObsPago;
                                                Pg.Cheque.Emitido = true;
                                                Pg.Cheque.ReciboPago = this;
                                                Lfx.Types.OperationResult ResultadoCheque = Pg.Cheque.Guardar();
                                                if (ResultadoCheque.Success == false)
                                                        return ResultadoCheque;
                                                break;
                                        case Lbl.Pagos.TiposFormasDePago.Caja:
                                                Pg.CajaOrigen.Connection = this.Connection;
                                                Pg.CajaOrigen.Movimiento(true, Pg.Concepto, Pg.ConceptoTexto, this.Cliente, -Pg.Importe, ObsPago, null, this, string.Empty);
                                                break;
                                        case Lbl.Pagos.TiposFormasDePago.ChequeTerceros:
                                                Pg.Cheque.Connection = this.Connection;
                                                Lfx.Types.OperationResult ResultadoChequeTerceros = Pg.Cheque.Entregar(this);
                                                if (ResultadoChequeTerceros.Success == false)
                                                        return ResultadoChequeTerceros;
                                                break;
                                        case Lbl.Pagos.TiposFormasDePago.OtroValor:
                                                Pg.Valor.Connection = this.Connection;
                                                Pg.Valor.Estado = 11;
                                                if (Pg.Valor.Obs.Length > 0)
                                                        Pg.Valor.Obs += " /// ";
                                                Pg.Valor.Obs += "Entregado s/" + this.ToString();
                                                Pg.Valor.Recibo = this;
                                                Pg.Valor.Guardar();
                                                Lfx.Types.OperationResult ResultadoValor = Pg.Valor.Guardar();
                                                if (ResultadoValor.Success == false)
                                                        return ResultadoValor;
                                                break;
                                }
                        }

                        CancelarImpagos(this.Cliente, this.Facturas, this, this.DePago ? -this.Total : this.Total);
                        this.Cliente.CuentaCorriente.Movimiento(true, this.Concepto, this.ConceptoTexto, this.DePago ? this.Total : -this.Total, this.Obs, null, this, this.ToString());

                        base.Guardar();

                        return new Lfx.Types.SuccessOperationResult();
                }
Exemplo n.º 46
0
                public bool Enviar(INotificacion notif)
                {
                        qGen.Insert InsertarMensaje = new qGen.Insert("sys_mensajes");
                        InsertarMensaje.Fields.AddWithValue("id_remitente", notif.Remitente.Id);
                        InsertarMensaje.Fields.AddWithValue("id_destinatario", notif.Destinatario.Id);
                        InsertarMensaje.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                        InsertarMensaje.Fields.AddWithValue("destino", notif.Destino);
                        InsertarMensaje.Fields.AddWithValue("nombre", notif.Nombre);
                        InsertarMensaje.Fields.AddWithValue("obs", notif.Obs);
                        InsertarMensaje.Fields.AddWithValue("estacion_envia", notif.EstacionOrigen);
                        InsertarMensaje.Fields.AddWithValue("estacion_recibe", notif.EstacionDestino);

                        try {
                                this.Connection.Execute(InsertarMensaje);
                                return false;
                        } catch {
                                return true;
                        }
                }
Exemplo n.º 47
0
                public void Movimiento(bool auto, Lbl.Cajas.Concepto concepto, string textoConcepto,
                        Lbl.Personas.Persona cliente, decimal importe, string obs,
                        Lbl.Comprobantes.ComprobanteConArticulos factura, Lbl.Comprobantes.Recibo recibo, string comprobantes)
                {
                        if (Lbl.Sys.Config.Actual.UsuarioConectado.TienePermiso(this, Lbl.Sys.Permisos.Operaciones.Mover) == false) {
                                throw new Lfx.Types.Exceptions.AccessDeniedException("No tiene permiso para hacer movimientos en la caja solicitada");
                        }

                        decimal SaldoActual = this.ObtenerSaldo(true);

                        qGen.TableCommand InsertarMovimiento = new qGen.Insert(this.Connection, "cajas_movim");
			InsertarMovimiento.Fields.AddWithValue("id_caja", this.Id);
			InsertarMovimiento.Fields.AddWithValue("auto", auto ? 1 : 0);
                        if (concepto == null)
                                InsertarMovimiento.Fields.AddWithValue("id_concepto", null);
                        else
                                InsertarMovimiento.Fields.AddWithValue("id_concepto", concepto.Id);
                        InsertarMovimiento.Fields.AddWithValue("concepto", textoConcepto);
                        InsertarMovimiento.Fields.AddWithValue("id_persona", Lbl.Sys.Config.Actual.UsuarioConectado.Id);
                        if (cliente == null)
                                InsertarMovimiento.Fields.AddWithValue("id_cliente", null);
                        else
                                InsertarMovimiento.Fields.AddWithValue("id_cliente", cliente.Id);
			InsertarMovimiento.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
			InsertarMovimiento.Fields.AddWithValue("importe", importe);
                        if (factura == null)
                                InsertarMovimiento.Fields.AddWithValue("id_comprob", null);
                        else
                                InsertarMovimiento.Fields.AddWithValue("id_comprob", factura.Id);
                        if (recibo == null)
                                InsertarMovimiento.Fields.AddWithValue("id_recibo", null);
                        else
                                InsertarMovimiento.Fields.AddWithValue("id_recibo", recibo.Id);
			InsertarMovimiento.Fields.AddWithValue("comprob", comprobantes);
			InsertarMovimiento.Fields.AddWithValue("saldo", SaldoActual + importe);
			InsertarMovimiento.Fields.AddWithValue("obs", obs);
			this.Connection.Execute(InsertarMovimiento);
		}
Exemplo n.º 48
0
                public void Poll()
                {
                        if (this.Connection.State != System.Data.ConnectionState.Open)
                                this.Connection.Open();

                        qGen.Where WhereUsuario = new qGen.Where(qGen.AndOr.Or);
                        WhereUsuario.AddWithValue("id_destinatario", Lbl.Sys.Config.Actual.UsuarioConectado.Id);
                        WhereUsuario.AddWithValue("id_destinatario", null);
                        if (Lbl.Sys.Config.Actual.UsuarioConectado.Persona.Grupo != null)
                                WhereUsuario.AddWithValue("id_grupo", Lbl.Sys.Config.Actual.UsuarioConectado.Persona.Grupo.Id);
                        if (Lbl.Sys.Config.Actual.UsuarioConectado.Persona.SubGrupo != null)
                                WhereUsuario.AddWithValue("id_grupo", Lbl.Sys.Config.Actual.UsuarioConectado.Persona.SubGrupo.Id);


                        qGen.Select SelMensajesSinLeer = new qGen.Select("sys_mensajes");

                        SelMensajesSinLeer.WhereClause = new qGen.Where();
                        //SelMensajesSinLeer.WhereClause.AddWithValue("estacion_recibe", Lfx.Environment.SystemInformation.MachineName);
                        SelMensajesSinLeer.WhereClause.AddWithValue("id_mensaje", qGen.ComparisonOperators.GreaterThan, this.LastMessageId);
                        SelMensajesSinLeer.WhereClause.AddWithValue(WhereUsuario);
                        SelMensajesSinLeer.Order = "id_mensaje";

                        System.Data.DataTable TablaMensajes;
                        try {
                                TablaMensajes = this.Connection.Select(SelMensajesSinLeer);
                                foreach (System.Data.DataRow Mensaje in TablaMensajes.Rows) {
                                        INotificacion Res = new NotificacionRegistro(this.Connection, (Lfx.Data.Row)(Mensaje));
                                        this.LastMessageId = System.Convert.ToInt32(Mensaje["id_mensaje"]);
                                        string Destino = System.Convert.ToString(Mensaje["destino"]);
                                        if (Lfx.Components.Manager.ComponentesCargados.ContainsKey(Destino)) {
                                                // Lo notifico via IPC
                                                Lfx.Workspace.Master.RunTime.Notify(Destino, Res);

                                                // Se lo notifico directamente al componente
                                                if (Lfx.Components.Manager.ComponentesCargados[Destino].Funciones.ContainsKey("Notify")) {
                                                        Lfx.Components.Manager.ComponentesCargados[Destino].Funciones["Notify"].Instancia.Arguments = new object[] { Res };
                                                        Lfx.Components.Manager.ComponentesCargados[Destino].Funciones["Notify"].Run();
                                                }
                                        } else {
                                                Lfx.Workspace.Master.RunTime.Notify(Destino, Res);
                                        }
                                }

                                qGen.Insert ActualizarEstado = new qGen.Insert("sys_mensajeria");
                                ActualizarEstado.OnDuplicateKeyUpdate = true;
                                ActualizarEstado.Fields.AddWithValue("id_usuario", Lbl.Sys.Config.Actual.UsuarioConectado.Id);
                                ActualizarEstado.Fields.AddWithValue("estacion", Lfx.Environment.SystemInformation.MachineName);
                                ActualizarEstado.Fields.AddWithValue("nombre", Lbl.Sys.Config.Actual.UsuarioConectado.Nombre);
                                ActualizarEstado.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                                if (this.LastMessageId > 0)
                                        ActualizarEstado.Fields.AddWithValue("id_ultimomensaje", this.LastMessageId);

                                this.Connection.Execute(ActualizarEstado);
                        } catch (Exception ex) {
                                System.Console.WriteLine(ex.Message);
                                if (Lfx.Environment.SystemInformation.DesignMode)
                                        throw;
                                else
                                        return;
                        }
                }
Exemplo n.º 49
0
                public override Lfx.Types.OperationResult Guardar()
                {
                        qGen.TableCommand Comando;

                        if (this.Existe == false) {
                                Comando = new qGen.Insert(this.Connection, this.TablaDatos);
                        } else {
                                Comando = new qGen.Update(this.Connection, this.TablaDatos);
                                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
                        }

                        Comando.Fields.AddWithValue("letra", this.Nomenclatura);
                        Comando.Fields.AddWithValue("letrasola", this.Letra == null ? "" : this.Letra);
                        Comando.Fields.AddWithValue("nombre", this.Nombre);
                        Comando.Fields.AddWithValue("nombrelargo", this.NombreLargo);
                        Comando.Fields.AddWithValue("mueve_stock", this.MueveExistencias);
                        Comando.Fields.AddWithValue("direc_ctacte", this.DireccionCtaCte);
                        Comando.Fields.AddWithValue("compra", this.PermiteCompra ? 1 : 0);
                        Comando.Fields.AddWithValue("venta", this.PermiteVenta ? 1 : 0);
                        Comando.Fields.AddWithValue("numerar_guardar", this.NumerarAlGuardar ? 1 : 0);
                        Comando.Fields.AddWithValue("numerar_imprimir", this.NumerarAlImprimir ? 1 : 0);
                        Comando.Fields.AddWithValue("imprimir_guardar", this.ImprimirAlGuardar ? 1 : 0);
                        Comando.Fields.AddWithValue("imprimir_repetir", this.PermiteImprimirVariasVeces ? 1 : 0);
                        Comando.Fields.AddWithValue("imprimir_modificar", this.PermiteModificarImpresos ? 1 : 0);
                        Comando.Fields.AddWithValue("cargapapel", (int)(this.CargaPapel));

                        if (this.SituacionOrigen == null)
                                Comando.Fields.AddWithValue("situacionorigen", null);
                        else
                                Comando.Fields.AddWithValue("situacionorigen", this.SituacionOrigen.Id);

                        if (this.SituacionDestino == null)
                                Comando.Fields.AddWithValue("situaciondestino", null);
                        else
                                Comando.Fields.AddWithValue("situaciondestino", this.SituacionDestino.Id);

                        this.AgregarTags(Comando);

                        this.Connection.Execute(Comando);

                        if (this.Impresoras != null && this.Impresoras.HayCambios) {
                                // Eliminar todas las impresoras asociadas con el tipo
                                qGen.Delete EliminarImpresorasActuales = new qGen.Delete("comprob_tipo_impresoras");
                                EliminarImpresorasActuales.WhereClause = new qGen.Where("id_tipo", this.Id);
                                this.Connection.Execute(EliminarImpresorasActuales);

                                // Guardar la nueva lista de permisos del usuario
                                foreach (Lbl.Impresion.TipoImpresora Impr in this.Impresoras) {
                                        qGen.Insert InsertarImpresora = new qGen.Insert("comprob_tipo_impresoras");
                                        InsertarImpresora.Fields.AddWithValue("id_tipo", this.Id);
                                        InsertarImpresora.Fields.AddWithValue("id_impresora", Impr.Impresora.Id);
                                        if (Impr.Sucursal == null)
                                                InsertarImpresora.Fields.AddWithValue("id_sucursal", null);
                                        else
                                                InsertarImpresora.Fields.AddWithValue("id_sucursal", Impr.Sucursal.Id);
                                        if (Impr.PuntoDeVenta == null)
                                                InsertarImpresora.Fields.AddWithValue("id_pv", null);
                                        else
                                                InsertarImpresora.Fields.AddWithValue("id_pv", Impr.PuntoDeVenta.Id);
                                        InsertarImpresora.Fields.AddWithValue("estacion", Impr.Estacion);
                                        InsertarImpresora.Fields.AddWithValue("nombre", Impr.Nombre);

                                        this.Connection.Execute(InsertarImpresora);
                                }
                        }

                        return base.Guardar();
                }
Exemplo n.º 50
0
                public override Lfx.Types.OperationResult Guardar()
                {
                        qGen.TableCommand Comando;

                        if (this.Existe == false) {
                                Comando = new qGen.Insert(this.Connection, this.TablaDatos);
                        } else {
                                Comando = new qGen.Update(this.Connection, this.TablaDatos);
                                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
                        }

                        Comando.Fields.AddWithValue("nombre", this.Nombre);
                        Comando.Fields.AddWithValue("porcentaje", this.Porcentaje);
                        Comando.Fields.AddWithValue("importe_minimo", this.ImporteMinimo);

                        this.AgregarTags(Comando);

                        this.Connection.Execute(Comando);

                        return base.Guardar();
                }
Exemplo n.º 51
0
                public override Lfx.Types.OperationResult Guardar()
                {
                        qGen.TableCommand Comando;

                        if (this.Existe == false) {
                                Comando = new qGen.Insert(this.Connection, this.TablaDatos);
                                Comando.Fields.AddWithValue("fecha_ingreso", qGen.SqlFunctions.Now);
                                Comando.Fields.AddWithValue("id_sucursal", Lfx.Workspace.Master.CurrentConfig.Empresa.SucursalActual);
                        } else {
                                Comando = new qGen.Update(this.Connection, this.TablaDatos);
                                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
                        }

                        Comando.Fields.AddWithValue("id_persona", this.Cliente.Id);
                        if (this.Tipo == null)
                                Comando.Fields.AddWithValue("id_tipo_ticket", null);
                        else
                                Comando.Fields.AddWithValue("id_tipo_ticket", this.Tipo.Id);
                        if (this.Encargado == null)
                                Comando.Fields.AddWithValue("id_tecnico_recibe", null);
                        else
                                Comando.Fields.AddWithValue("id_tecnico_recibe", this.Encargado.Id);
                        Comando.Fields.AddWithValue("prioridad", this.Prioridad);
                        Comando.Fields.AddWithValue("nombre", this.Nombre);
                        Comando.Fields.AddWithValue("descripcion", this.GetFieldValue<string>("descripcion"));
                        Comando.Fields.AddWithValue("estado", this.Estado);
                        Comando.Fields.AddWithValue("articulos_descuento", this.DescuentoArticulos);
                        Comando.Fields.AddWithValue("entrega_estimada", this.FechaEstimada);
                        Comando.Fields.AddWithValue("entrega_limite", this.FechaLimite);
                        Comando.Fields.AddWithValue("presupuesto", this.Importe);
                        if (this.Presupuesto == null)
                                Comando.Fields.AddWithValue("id_presupuesto", null);
                        else
                                Comando.Fields.AddWithValue("id_presupuesto", this.Presupuesto.Id);
                        if (this.Factura == null)
                                Comando.Fields.AddWithValue("id_comprob", null);
                        else
                                Comando.Fields.AddWithValue("id_comprob", this.Factura.Id);
                        Comando.Fields.AddWithValue("obs", this.Obs);

                        this.AgregarTags(Comando);

                        this.Connection.Execute(Comando);
                        this.ActualizarId();

                        if (this.RegistroOriginal != null && this.RegistroOriginal["estado"] != this.Registro["estado"])
                                this.AgregarComentario("Actualización de Estado: " + Lbl.Tareas.Estado.TodosPorNumero[this.Estado].ToString());

                        if (this.Articulos != null && this.Articulos.HayCambios) {
                                qGen.Delete EliminarArticulos = new qGen.Delete("tickets_articulos");
                                EliminarArticulos.WhereClause = new qGen.Where("id_ticket", this.Id);
                                this.Connection.Execute(EliminarArticulos);

                                int i = 1;
                                foreach (Lbl.Comprobantes.DetalleArticulo Det in this.Articulos) {
                                        qGen.Insert InsertarArticulo = new qGen.Insert(Connection, "tickets_articulos");
                                        InsertarArticulo.Fields.AddWithValue("id_ticket", this.Id);
                                        if (Det.Articulo == null) {
                                                InsertarArticulo.Fields.AddWithValue("id_articulo", null);
                                                InsertarArticulo.Fields.AddWithValue("nombre", Det.Descripcion);
                                        } else {
                                                InsertarArticulo.Fields.AddWithValue("id_articulo", Det.Articulo.Id);
                                                InsertarArticulo.Fields.AddWithValue("nombre", Det.Articulo.Nombre);
                                        }
                                        
                                        InsertarArticulo.Fields.AddWithValue("orden", i++);
                                        InsertarArticulo.Fields.AddWithValue("cantidad", Det.Cantidad);
                                        InsertarArticulo.Fields.AddWithValue("precio", Det.Unitario);
                                        Connection.Execute(InsertarArticulo);
                                }
                        }

                        return base.Guardar();
                }
Exemplo n.º 52
0
                /// <summary>
                /// Asienta un movimiento en la cuenta corriente, y cancela comprobantes asociados.
                /// </summary>
                /// <param name="auto">Indica si es un movimiento automático (generado por el sistema) o manual (generado por el usuario).</param>
                /// <param name="concepto">El concepto bajo el cual se realiza el movimiento.</param>
                /// <param name="textoConcepto">El texto que describe al concepto.</param>
                /// <param name="importeDebito">El importe a debitar de la cuenta. Un importe negativo indica un crédito.</param>
                /// <param name="obs">Observaciones.</param>
                /// <param name="comprob">El comprobante asociado a este movimiento.</param>
                /// <param name="recibo">El recibo asociado a este movimiento.</param>
                /// <param name="textoComprob">Un texto sobre los comprobantes asociados al sistema.</param>
                /// <param name="extras">Colección de campos adicionales para el registro.</param>
                public void Movimiento(bool auto, 
                        Lbl.Cajas.Concepto concepto,
                        string textoConcepto,
                        decimal importeDebito,
                        string obs,
                        Lbl.Comprobantes.ComprobanteConArticulos comprob,
                        Lbl.Comprobantes.Recibo recibo,
                        string textoComprob,
                        Dictionary<string, object> extras)
                {
                        decimal SaldoActual = this.ObtenerSaldo(true);
                        decimal NuevoSaldo = SaldoActual + importeDebito;

                        qGen.Insert ComandoInsertarMovimiento = new qGen.Insert(this.Connection, this.TablaDatos);
				
                        ComandoInsertarMovimiento.Fields.AddWithValue("auto", auto ? (int)1 : (int)0);
                        if (concepto == null)
                                ComandoInsertarMovimiento.Fields.AddWithValue("id_concepto", null);
                        else
                                ComandoInsertarMovimiento.Fields.AddWithValue("id_concepto", concepto.Id);
                        ComandoInsertarMovimiento.Fields.AddWithValue("concepto", textoConcepto);
                        ComandoInsertarMovimiento.Fields.AddWithValue("id_cliente", this.Persona.Id);
			ComandoInsertarMovimiento.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                        ComandoInsertarMovimiento.Fields.AddWithValue("importe", importeDebito);
                        if (comprob == null)
                                ComandoInsertarMovimiento.Fields.AddWithValue("id_comprob", null);
                        else
                                ComandoInsertarMovimiento.Fields.AddWithValue("id_comprob", comprob.Id);
                        if (recibo == null)
                                ComandoInsertarMovimiento.Fields.AddWithValue("id_recibo", null);
                        else
                                ComandoInsertarMovimiento.Fields.AddWithValue("id_recibo", recibo.Id);
                        ComandoInsertarMovimiento.Fields.AddWithValue("comprob", textoComprob);
                        ComandoInsertarMovimiento.Fields.AddWithValue("saldo", NuevoSaldo);
                        ComandoInsertarMovimiento.Fields.AddWithValue("obs", obs);

                        if (extras != null && extras.Count > 0) {
                                foreach (KeyValuePair<string, object> extra in extras) {
                                        ComandoInsertarMovimiento.Fields.AddWithValue(extra.Key, extra.Value);
                                }
                        }
                        this.Connection.Execute(ComandoInsertarMovimiento);

                        qGen.Update ComandoActualizarCliente = new qGen.Update("personas");
                        ComandoActualizarCliente.Fields.AddWithValue("saldo_ctacte", NuevoSaldo);
                        ComandoActualizarCliente.WhereClause = new qGen.Where("id_persona", this.Persona.Id);
                        this.Connection.Execute(ComandoActualizarCliente);
                }
Exemplo n.º 53
0
                public override Lfx.Types.OperationResult Guardar()
                {
                        qGen.TableCommand Comando;

                        if (this.Existe == false) {
                                Comando = new qGen.Insert(this.Connection, this.TablaDatos);
                                Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                        } else {
                                Comando = new qGen.Update(this.Connection, this.TablaDatos);
                                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
                        }

                        Comando.Fields.AddWithValue("nombre", this.Nombre);
                        Comando.Fields.AddWithValue("obs", this.Obs);

                        Comando.Fields.AddWithValue("espacio", this.EspacioNombres);
                        Comando.Fields.AddWithValue("version", this.Version);
                        Comando.Fields.AddWithValue("estructura", this.Estructura);
                        Comando.Fields.AddWithValue("cif", this.Cif);

                        Comando.Fields.AddWithValue("url", this.Url);
                        Comando.Fields.AddWithValue("url_act", this.UrlActualizaciones);

                        this.AgregarTags(Comando);

                        this.Connection.Execute(Comando);

                        return base.Guardar();
                }
Exemplo n.º 54
0
                public bool AddTask(string commandString, string component, string terminalName)
                {
                        if (terminalName == null || terminalName.Length == 0)
                                terminalName = Lfx.Environment.SystemInformation.MachineName;

                        qGen.Insert Comando = new qGen.Insert(this.DataBase, "sys_programador");
                        Comando.Fields.AddWithValue("crea_estacion", Lfx.Environment.SystemInformation.MachineName);
                        Comando.Fields.AddWithValue("crea_usuario", "");        // TODO: que ponga el nombre de usuario
                        Comando.Fields.AddWithValue("estacion", terminalName);
                        Comando.Fields.AddWithValue("comando", commandString);
                        Comando.Fields.AddWithValue("componente", component);
                        Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                        Comando.Fields.AddWithValue("fechaejecutar", null);

                        try {
                                using (System.Data.IDbTransaction Trans = this.DataBase.BeginTransaction()) {
                                        this.DataBase.Execute(Comando);
                                        Trans.Commit();
                                }
                        }
                        catch {
                                return true;
                        }

                        return false;
                }
Exemplo n.º 55
0
                public override Lfx.Types.OperationResult Guardar()
                {
                        try {
				qGen.TableCommand Comando;
                                if (this.Existe) {
					Comando = new qGen.Update(this.Connection, this.TablaDatos);
					Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
				} else {
					Comando = new qGen.Insert(this.Connection, this.TablaDatos);
                                        Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                                }

                                Comando.Fields.AddWithValue("nombre", this.Registro["nombre"].ToString());
                                Comando.Fields.AddWithValue("cuenta_stock", this.CuentaExistencias ? 1 : 0);
                                Comando.Fields.AddWithValue("deposito", this.Deposito);
                                Comando.Fields.AddWithValue("facturable", this.Facturable ? 1 : 0);
                                Comando.Fields.AddWithValue("estado", this.Estado);
                                Comando.Fields.AddWithValue("obs", this.Obs);
				
				this.AgregarTags(Comando);

	                        this.Connection.Execute(Comando);

				return new Lfx.Types.SuccessOperationResult();
                        }
                        catch (Exception ex) {
                                return new Lfx.Types.FailureOperationResult(ex.ToString());
                        }
                }
Exemplo n.º 56
0
                public override Lfx.Types.OperationResult Guardar()
                {
                        qGen.TableCommand Comando;
                        if (this.Existe == false) {
                                Comando = new qGen.Insert(Connection, this.TablaDatos);
                                Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                        } else {
                                Comando = new qGen.Update(Connection, this.TablaDatos);
                                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
                        }

                        Comando.Fields.AddWithValue("prefijo", this.Prefijo);
                        Comando.Fields.AddWithValue("numero", this.Numero);
                        Comando.Fields.AddWithValue("nombre", this.Nombre);
                        
                        if (this.Sucursal == null)
                                Comando.Fields.AddWithValue("id_sucursal", null);
                        else
                                Comando.Fields.AddWithValue("id_sucursal", this.Sucursal.Id);
                        
                        if (this.Impresora == null)
                                Comando.Fields.AddWithValue("id_impresora", null);
                        else
                                Comando.Fields.AddWithValue("id_impresora", this.Impresora.Id);
                        Comando.Fields.AddWithValue("tipo", (int)(this.Tipo));
                        Comando.Fields.AddWithValue("tipo_fac", this.TipoFac);
                        Comando.Fields.AddWithValue("detalonario", this.UsaTalonario ? 1 : 0);
                        Comando.Fields.AddWithValue("estacion", this.Estacion);
                        Comando.Fields.AddWithValue("carga", this.CargaManual ? 1 : 0);
                        Comando.Fields.AddWithValue("modelo", (int)(this.ModeloImpresoraFiscal));
                        Comando.Fields.AddWithValue("puerto", this.Puerto);
                        Comando.Fields.AddWithValue("bps", this.Bps);

                        this.AgregarTags(Comando);

                        Connection.Execute(Comando);

                        return base.Guardar();
                }
Exemplo n.º 57
0
                public override Lfx.Types.OperationResult Guardar()
                {
                        qGen.TableCommand Comando;
                        if (this.Existe == false) {
                                Comando = new qGen.Insert(Connection, this.TablaDatos);
                                Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                        } else {
                                Comando = new qGen.Update(Connection, this.TablaDatos);
                                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
                        }

                        Comando.Fields.AddWithValue("nombre", this.Nombre);
                        Comando.Fields.AddWithValue("estacion", this.Estacion);
                        Comando.Fields.AddWithValue("id_impresora", this.Tipo.Id);
                        Comando.Fields.AddWithValue("id_tipo", this.Impresora.Id);
                        if (this.Sucursal == null)
                                Comando.Fields.AddWithValue("id_sucursal", null);
                        else
                                Comando.Fields.AddWithValue("id_sucursal", this.Sucursal.Id);
                        if (this.PuntoDeVenta == null)
                                Comando.Fields.AddWithValue("id_pv", null);
                        else
                                Comando.Fields.AddWithValue("id_pv", this.PuntoDeVenta.Id);

                        this.AgregarTags(Comando);

                        Connection.Execute(Comando);

                        return base.Guardar();
                }
Exemplo n.º 58
0
                public Lfx.Types.OperationResult CancelarImporte(decimal importe, Lbl.Comprobantes.Comprobante comprob)
		{
			if(this.ImporteCancelado + importe > this.Total)
                                throw new Lfx.Types.DomainException("ComprobanteConArticulos.CancelarImporte: El importe a cancelar no puede ser mayor que el saldo impago");
			this.ImporteCancelado += importe;
			qGen.Update Actualizar = new qGen.Update("comprob", new qGen.Where("id_comprob", this.Id));
			Actualizar.Fields.AddWithValue("cancelado", this.ImporteCancelado);
			this.Connection.Execute(Actualizar);

                        if (comprob is Lbl.Comprobantes.Recibo) {
                                qGen.Insert AsentarComprobantesDeEsteRecibo = new qGen.Insert("recibos_comprob");
                                AsentarComprobantesDeEsteRecibo.Fields.AddWithValue("id_comprob", this.Id);
                                AsentarComprobantesDeEsteRecibo.Fields.AddWithValue("id_recibo", comprob.Id);
                                AsentarComprobantesDeEsteRecibo.Fields.AddWithValue("importe", importe);
                                this.Connection.Execute(AsentarComprobantesDeEsteRecibo);
                        } else if (comprob is Lbl.Comprobantes.ComprobanteConArticulos) {
                                Lbl.Comprobantes.ComprobanteConArticulos factura = comprob as Lbl.Comprobantes.ComprobanteConArticulos;
                                qGen.Insert AsentarComprobantesDeEsteRecibo = new qGen.Insert("comprob_comprob");
                                AsentarComprobantesDeEsteRecibo.Fields.AddWithValue("id_comprob", factura.Id);
                                AsentarComprobantesDeEsteRecibo.Fields.AddWithValue("id_comprob_rel", this.Id);
                                AsentarComprobantesDeEsteRecibo.Fields.AddWithValue("importe", importe);
                                this.Connection.Execute(AsentarComprobantesDeEsteRecibo);
                        }
			return new Lfx.Types.SuccessOperationResult();
		}
Exemplo n.º 59
0
                public override Lfx.Types.OperationResult Guardar()
                {
                        this.Articulos.ElementoPadre = this;

			qGen.TableCommand Comando;

			if (this.Existe == false) {
                                Comando = new qGen.Insert(this.Connection, this.TablaDatos);
                        } else {
                                Comando = new qGen.Update(this.Connection, this.TablaDatos);
                                Comando.WhereClause = new qGen.Where(this.CampoId, this.Id);
                        }

                        if (this.Existe == false && this.Numero == 0 && this.Tipo.NumerarAlGuardar) {
                                this.Numerar(false);
                        }

                        if (this.Fecha.Year == 1) {
                                Comando.Fields.AddWithValue("fecha", qGen.SqlFunctions.Now);
                        } else {
                                Comando.Fields.AddWithValue("fecha", this.Fecha);
                        }

                        if (this.ComprobanteOriginal == null)
                                Comando.Fields.AddWithValue("id_comprob_orig", null);
                        else
                                Comando.Fields.AddWithValue("id_comprob_orig", this.ComprobanteOriginal.Id);

                        if(this.FormaDePago == null)
                                Comando.Fields.AddWithValue("id_formapago", null);
                        else
                                Comando.Fields.AddWithValue("id_formapago", FormaDePago.Id);

                        if (this.Vendedor == null)
                                Comando.Fields.AddWithValue("id_vendedor", null);
                        else
                                Comando.Fields.AddWithValue("id_vendedor", this.Vendedor.Id);
                        
                        if (this.Sucursal == null)
                                Comando.Fields.AddWithValue("id_sucursal", Lfx.Workspace.Master.CurrentConfig.Empresa.SucursalActual);
                        else
                                Comando.Fields.AddWithValue("id_sucursal", this.Sucursal.Id);

                        if (this.IdRemito == 0)
                                Comando.Fields.AddWithValue("id_remito", null);
                        else
                                Comando.Fields.AddWithValue("id_remito", this.IdRemito);

                        Comando.Fields.AddWithValue("pv", this.PV);
                        Comando.Fields.AddWithValue("numero", this.Numero);
                        Comando.Fields.AddWithValue("nombre", this.PV.ToString("0000") + "-" + this.Numero.ToString("00000000"));
                        Comando.Fields.AddWithValue("id_cliente", Lfx.Data.Connection.ConvertZeroToDBNull(this.Cliente.Id));
                        if (this.SituacionOrigen == null)
                                Comando.Fields.AddWithValue("situacionorigen", null);
                        else
                                Comando.Fields.AddWithValue("situacionorigen", this.SituacionOrigen.Id);
                        if (this.SituacionDestino == null)
                                Comando.Fields.AddWithValue("situaciondestino", null);
                        else
                                Comando.Fields.AddWithValue("situaciondestino", this.SituacionDestino.Id);
                        Comando.Fields.AddWithValue("tipo_fac", this.Tipo.Nomenclatura);
                        Comando.Fields.AddWithValue("subtotal", this.SubTotalSinIva);
                        Comando.Fields.AddWithValue("descuento", this.Descuento);
                        Comando.Fields.AddWithValue("interes", this.Recargo);
                        Comando.Fields.AddWithValue("cuotas", this.Cuotas);
                        Comando.Fields.AddWithValue("total", this.Total);
                        Comando.Fields.AddWithValue("iva", this.ImporteIva);
                        Comando.Fields.AddWithValue("totalreal", this.TotalSinRedondeo);
                        Comando.Fields.AddWithValue("gastosenvio", this.GastosDeEnvio);
                        Comando.Fields.AddWithValue("otrosgastos", this.OtrosGastos);
                        Comando.Fields.AddWithValue("obs", this.Obs);
                        // Lo comprobantes de compra se marcan siempre como impresos
                        Comando.Fields.AddWithValue("impresa", this.Compra ? 1 : (this.Impreso ? 1 : 0));
                        Comando.Fields.AddWithValue("compra", this.Compra ? 1 : 0);
                        Comando.Fields.AddWithValue("estado", this.Estado);
                        Comando.Fields.AddWithValue("series", this.Articulos.DatosSeguimiento);
                        if (this.Tipo.EsFacturaOTicket == false && this.Tipo.EsNotaDebito == false) {
                                // Este comprobante no es cancelable
                                this.ImporteCancelado = this.Total;
                                Comando.Fields.AddWithValue("cancelado", this.Total);
                        }

			this.AgregarTags(Comando);

                        this.Connection.Execute(Comando);
                        this.ActualizarId();

                        this.GuardarDetalle();

                        if (this.Compra) {
                                if (this.Tipo.MueveExistencias != 0) {
                                        // Comprobantes de compra mueven stock al guardar
                                        Lfx.Types.OperationResult Res = VerificarSeries();
                                        if (Res.Success == false)
                                                return Res;
                                }

                                if (this.Tipo.EsFacturaNCoND)
                                        this.AsentarPago(false);

                                if (this.Tipo.MueveExistencias != 0) {
                                        // Comprobantes de compra mueven stock al guardar
                                        this.MoverExistencias(false);

                                        Lbl.ListaIds ArticulosAfectados = new Lbl.ListaIds();
                                        foreach (DetalleArticulo Det in m_Articulos) {
                                                if (Det.IdArticulo != 0 && ArticulosAfectados.Contains(Det.IdArticulo) == false)
                                                        ArticulosAfectados.Add(Det.IdArticulo);
                                        }

                                        if (m_ArticulosOriginales != null) {
                                                foreach (DetalleArticulo Det in m_ArticulosOriginales) {
                                                        if (Det.IdArticulo > 0 && ArticulosAfectados.Contains(Det.IdArticulo) == false)
                                                                ArticulosAfectados.Add(Det.IdArticulo);
                                                }
                                        }

                                        if (ArticulosAfectados.Count > 0) {
                                                string ArtCsv = ArticulosAfectados.ToString();
                                                // Actualizo cantidades pedidas y a pedir
                                                Connection.ExecuteSql(@"UPDATE articulos SET apedir=(
							SELECT SUM(cantidad)
							FROM comprob, comprob_detalle
							WHERE comprob.id_comprob=comprob_detalle.id_comprob
							AND comprob.compra=1
							AND tipo_fac='NP' AND estado=50 AND comprob_detalle.id_articulo=articulos.id_articulo)
						WHERE control_stock=1 AND id_articulo IN (" + ArtCsv + " )");
                                                Connection.ExecuteSql(@"UPDATE articulos SET pedido=(
							SELECT SUM(cantidad)
							FROM comprob, comprob_detalle
							WHERE comprob.id_comprob=comprob_detalle.id_comprob
							AND comprob.compra=1
							AND tipo_fac='PD' AND estado=50 AND comprob_detalle.id_articulo=articulos.id_articulo)
						WHERE control_stock=1 AND id_articulo IN (" + ArtCsv + " )");
                                        }
                                }
                        }

                        return base.Guardar();
                }
Exemplo n.º 60
0
                public override Lfx.Types.OperationResult Guardar()
                {
                        qGen.TableCommand Comando = new qGen.Insert(this.Connection, this.TablaDatos);
                        Comando.Fields.AddWithValue("id_comprob", this.IdComprobante);
                        Comando.Fields.AddWithValue("orden", this.Orden);

                        if (this.Articulo == null) {
                                Comando.Fields.AddWithValue("id_articulo", null);
                                Comando.Fields.AddWithValue("nombre", this.Nombre);
                                Comando.Fields.AddWithValue("descripcion", "");
                        } else {
                                Comando.Fields.AddWithValue("id_articulo", this.Articulo.Id);
                                Comando.Fields.AddWithValue("nombre", this.Articulo.Nombre);
                                Comando.Fields.AddWithValue("descripcion", this.Articulo.Descripcion);
                        }

                        Comando.Fields.AddWithValue("cantidad", this.Cantidad);
                        Comando.Fields.AddWithValue("precio", this.Unitario);
                        Comando.Fields.AddWithValue("recargo", this.Recargo);
                        if (this.Costo == 0 && this.Articulo != null)
                                Comando.Fields.AddWithValue("costo", this.Articulo.Costo);
                        else
                                Comando.Fields.AddWithValue("costo", this.Costo);
                        Comando.Fields.AddWithValue("importe", this.ImporteAImprimir);
                        Comando.Fields.AddWithValue("series", this.DatosSeguimiento);
                        Comando.Fields.AddWithValue("obs", this.Obs);

                        this.AgregarTags(Comando, this.Registro, this.TablaDatos);

                        this.Connection.Execute(Comando);

                        return base.Guardar();
                }