示例#1
0
        /// <summary>
        /// Popula a grid com as alíquotas presentes na impressora fiscal e as da aplicação
        /// </summary>
        /// <returns>Se true, foi populado corretamente</returns>
        public override bool InitStep()
        {
            bool result = base.InitStep();

            IList<object[]> sourceVinculo = new List<object[]>();
            IList<object[]> sourceVinculado = new List<object[]>();
            IList<IAliquotaTributo> aliqTrib = new AliquotaTributo().Find<IAliquotaTributo>();

            if (result)
            {
                try
                {
                    using (IConfiguracao conf = new Configuracao())
                    {
                        foreach (ACBrFramework.ECF.Aliquota aliquotaECF in conf.LerAliquotas())
                        {
                            if (aliquotaECF.Tipo == "T")
                            {
                                sourceVinculo.Add(new object[]
                                {
                                    string.Empty,
                                    aliquotaECF.Indice,
                                    string.Format("{0}{1:0000}", aliquotaECF.Tipo, aliquotaECF.ValorAliquota.ToString("00.00")),
                                });
                            }
                            else
                            {
                                sourceVinculo.Add(new object[]
                                {
                                    string.Empty,
                                    aliquotaECF.Indice,
                                    string.Format("{0}{1:0000}", aliquotaECF.Tipo, aliquotaECF.ValorAliquota.ToString("00.00"))
                                });
                            }
                        }
                    }

                    foreach (IAliquotaTributo aliquota in aliqTrib)
                    {
                        sourceVinculado.Add(new object[]
                        {
                            aliquota.GUID.ToString(),
                            aliquota.Valor
                        });
                    }

                    confECF.PopulateGrid(sourceVinculo, sourceVinculado);
                }
                catch (Exception ex)
                {
                    MessageBox.ShowError(ex, false);
                }
            }

            return result;
        }
示例#2
0
        /// <summary>
        /// Popula a grid com as alíquotas cadastradas na impressora fiscal
        /// </summary>
        private void Populate()
        {
            Wait.Show();

            IList<object[]> sourceVinculo = new List<object[]>();
            IList<object[]> sourceVinculado = new List<object[]>();

            IList<IAliquotaTributo> aliqTributos = new AliquotaTributo().Find<IAliquotaTributo>();

            IList<IAliquota> aliquotas = new Aliquota().Find<IAliquota>(new Where
            {
                { "ecf_aliquota.guidimpressora = @guid",
                    new Parameter
                    {
                        ParameterName = "@guid",
                        Value = Settings.ECF.ECFAtual.GUID.ToString()
                    }
                }
            });

            try
            {
                //Acessando a impressora fiscal para buscar quais as alíquotas cadastradas
                using (IConfiguracao conf = new Configuracao(Settings.ECF.ECFAtual.ModeloACBR, Settings.ECF.ECFAtual.Porta))
                {
                    var aliquotasECF = (from a in conf.LerAliquotas()
                                        select a);

                    foreach (ACBrFramework.ECF.Aliquota item in aliquotasECF)
                    {
                        IAliquota aliquota = aliquotas.FirstOrDefault(f => f.Indice.ToString().Trim().Equals(item.Indice));

                        if (item.Tipo.Equals("T"))
                        {
                            sourceVinculo.Add(new object[]
                            {
                                aliquota == null ? "" : aliquota.TributoAliquota.GUID.ToString(),
                                item.Indice,
                                string.Format("T{0:0000}", item.ValorAliquota.ToString("00.00")),
                            });
                        }
                        else
                        {
                            sourceVinculo.Add(new object[]
                            {
                                aliquota == null ? "" : aliquota.TributoAliquota.GUID.ToString(),
                                item.Indice,
                                string.Format("S{0:0000}", item.ValorAliquota.ToString("00.00")),
                            });
                        }
                    }

                    foreach (IAliquotaTributo aliqTrib in aliqTributos)
                    {
                        sourceVinculado.Add(new object[]
                        {
                            aliqTrib.GUID.ToString(),
                            aliqTrib.Valor.ToString()
                        });
                    }
                }

                //Popula a grid com as alíquotas do ECF e as que serão vinculadas
                confECF.PopulateGrid(sourceVinculo, sourceVinculado);
            }
            catch (Exception ex)
            {
                MessageBox.ShowError(ex, false);
            }
            Wait.Close();
        }