예제 #1
0
파일: TEFTest.cs 프로젝트: njmube/openposbr
        public void PagamentoCartaoTest()
        {
            using(ICupomFiscal cf = new ECF.CupomFiscal())
            {
                cf.FechaCupom(string.Empty);
                cf.AbreCupom(string.Empty, string.Empty, string.Empty);
                cf.VendeItem("00001", "Caneta azul", "F", 10M, 1.50M, 0, "UN", "%", "D", 1);
                cf.SubTotalizaCupom(0, string.Empty);

                IList<IImpressoraFormaPagto> formas = new ImpressoraFormaPagto().Find<IImpressoraFormaPagto>(new Where {
                    {"cad_FormaPagto.TipoForma = @p1", new Parameter {
                        ParameterName = "@p1",
                        GenericDbType = GenericDbType.Integer,
                        Value = (int)TipoForma.CartaoCredito
                    }}
                });

                IImpressoraFormaPagto forma = formas[0];

                IPagamento pag = new Pagamento(cf);
                pag.Pagar(forma, 15.00M, cf.COO.ToString());
                if(cf.Estado == ACBrFramework.ECF.EstadoECF.Pagamento &&
                    cf.TotalPago == cf.SubTotal)
                    cf.FechaCupom("Obrigado. Volte sempre!");
                pag.ImprimirTransacoesPendentes();
                pag.Confirmacao();
            }

            using (ICupomFiscal c = new ECF.CupomFiscal())
            {

            }
        }
예제 #2
0
        public override void Gravar()
        {
            #region Impressora fiscal
            ImpressoraTest impressoraTest = new ImpressoraTest();
            impressoraTest.Gravar();
            #endregion

            #region Forma de pagamento
            FormaPagamentoTest formaPgtoTest = new FormaPagamentoTest();
            formaPgtoTest.Gravar();
            #endregion

            IImpressoraFormaPagto forma = new ImpressoraFormaPagto();
            forma.Impressora = new Impressora(impressoraTest.GUID);
            forma.FormaPagamento = new FormaPagamento(formaPgtoTest.GUID);
            forma.Indice = 1;
            GUID = forma.Save();
        }
예제 #3
0
파일: TEFTest.cs 프로젝트: njmube/openposbr
        public void ConsultaChequeTest()
        {
            using (ICupomFiscal cf = new ECF.CupomFiscal())
            {
                cf.AbreCupom(string.Empty, string.Empty, string.Empty);
                cf.VendeItem("00001", "Caneta preta", "I", 5M, 1.50M, 0, "UN", "%", "D", 1);
                cf.SubTotalizaCupom(0, string.Empty);

                IList<IImpressoraFormaPagto> formas = new ImpressoraFormaPagto().Find<IImpressoraFormaPagto>(new Where {
                    {"cad_FormaPagto.TipoForma = @p1", new Parameter {
                        ParameterName = "@p1",
                        GenericDbType = GenericDbType.Integer,
                        Value = (int)TipoForma.Cheque
                    }}
                });

                IImpressoraFormaPagto forma = formas[0];

                IPagamento cheque = new Pagamento(cf);
                cheque.Pagar(forma, cf.SubTotal);
                cf.FechaCupom(string.Empty);
            }
        }
예제 #4
0
        public override bool PerformStep()
        {
            bool result = base.PerformStep();

            if(result)
            {
                IList<IImpressoraFormaPagto> impressoraFormasPagto = new List<IImpressoraFormaPagto>();
                IList<IFormaPagamento> formas = new FormaPagamento().Find<IFormaPagamento>();

                try
                {

                    foreach(DataGridViewRow item in grdFPECF.Rows)
                    {
                        if (!String.IsNullOrEmpty(Unimake.Convert.ToString(item.Cells[colTipoForma.Index].Value)))
                        {
                            IImpressoraFormaPagto impForma = new ImpressoraFormaPagto();

                            IFormaPagamento forma = new Data.Cadastro.FormaPagamento
                            {
                                Descricao = item.Cells[colDescricao.Index].Value.ToString(),
                                TipoForma = Unimake.Convert.ToEnum<TipoForma>(item.Cells[colTipoForma.Index].Value),
                                FrenteCaixa = true
                            };

                            impForma.Impressora = CurrentConfig.Impressora;
                            impForma.FormaPagamento = forma;
                            impForma.Indice = Unimake.Convert.ToInt(item.Cells[colIndice.Index].Value);

                            impressoraFormasPagto.Add(impForma);
                        }
                    }

                    CurrentConfig.FormasPagto = impressoraFormasPagto;

                }
                catch(Exception ex)
                {
                    MessageBox.ShowError(ex);
                    return false;
                }
            }

            return result;
        }
예제 #5
0
        private void lstFormaPagto_SelectedIndexChanged(object sender, EventArgs e)
        {
            //achar o tipo e identificar se o mesmo é dinheiro, cheque, cartão ...
            usParcela.Visible = false;
            grbCheque.Visible = false;
            txtNSU.Visible = false;
            lblNumNSU.Visible = false;
            lblNumNSU.Text = "NSU:";
            maskValorRecebido.ReadOnly = false;
            // maskValorRecebido.Clear();
            usParcela.Clear();

            if (lstFormaPagto.SelectedItem == null)
                return;

            if (Unimake.Convert.ToBoolean(Settings.Setting.EmissaoConsumidorFinalNFCe))
            {
                FormaPagto = new OpenPOS.Data.Cadastro.FormaPagamento(((FormaPagamentoValue)lstFormaPagto.SelectedItem).value);
                Tipo = ((OpenPOS.Model.Cadastro.IFormaPagamento)FormaPagto).TipoForma;
            }
            else
            {
                FormaPagto = new ImpressoraFormaPagto(((FormaPagamentoValue)lstFormaPagto.SelectedItem).value);
                Tipo = ((OpenPOS.Model.ECF.Cadastro.IImpressoraFormaPagto)FormaPagto).FormaPagamento.TipoForma;
            }

            switch (Tipo)
            {
                case Enuns.Cadastro.TipoForma.Cheque:
                    grbCheque.Visible = true;
                    grbCheque.Left = 14;
                    grbCheque.Top = 263;
                    Size = new Size(490, grbCheque.Bottom + pnlValorRecebido.Height);
                    break;
                case Enuns.Cadastro.TipoForma.Dinheiro:
                case Enuns.Cadastro.TipoForma.CartaoDebito:
                case Enuns.Cadastro.TipoForma.CartaoCredito:
                    if (!Settings.TEF.UsaTEF &&
                        Tipo != Enuns.Cadastro.TipoForma.Dinheiro)
                        txtNSU.Visible = lblNumNSU.Visible = true;
                    Size = new Size(490, 420);
                    break;
                case Enuns.Cadastro.TipoForma.CartaoPrivateLabel:
                case Enuns.Cadastro.TipoForma.ConfirmacaoPreAutorizacao:
                case Enuns.Cadastro.TipoForma.CreditoConsumidor:
                    MessageBox.ShowWarning("Forma de pagamento ainda não foi implementada.");
                    break;
                case Enuns.Cadastro.TipoForma.Parcelado:
                    usParcela.Visible = true;
                    usParcela.Height = 234;
                    usParcela.Left = 14;
                    usParcela.Top = 263;
                    usParcela.ValorTotalLiquido = Value;
                    Size = new Size(765, usParcela.Bottom + pnlValorRecebido.Height);
                    break;
                case TipoForma.Voucher:
                    txtNSU.Visible = lblNumNSU.Visible = true;
                    lblNumNSU.Text = "Voucher:";
                    Size = new Size(490, 420);
                    maskValorRecebido.ReadOnly = true;
                    txtNSU.TabIndex = maskValorRecebido.TabIndex;
                    break;
            }
        }
예제 #6
0
        public FormaPagamento(bool somenteAvista)
        {
            InitializeComponent();
            SomenteAVista = somenteAvista;
            if (Settings.RuntimeMode)
            {
                //-------------------------------------------------------------------------
                // Aqui só podemos trazer as formas de pagamentos que estão associadas com esta impressora
                //-------------------------------------------------------------------------
                IDisplayValues formas = null;

                if (!Unimake.Convert.ToBoolean(Settings.Setting.EmissaoConsumidorFinalNFCe))
                    formas = new ImpressoraFormaPagto().GetDisplayValues(new Where {
                                    {
                                        "GUIDImpressora = @p1", new Parameter[]{
                                        new Parameter {
                                        ParameterName = "@p1",
                                        Value = Settings.ECF.ECFAtual.GUID
                                    }
                                }
                        }
                });
                else
                    formas = new Data.Cadastro.FormaPagamento().GetDisplayValues(SomenteAVista ? new Where {
                                    {
                                        "TipoForma <> @p1 AND TipoForma <> @p2 AND TipoForma <> @p3", new Parameter[]{
                                        new Parameter {
                                        ParameterName = "@p1",
                                         GenericDbType = Unimake.Data.Generic.GenericDbType.Integer,
                                        Value = (int)TipoForma.Cheque
                                    },
                                    new Parameter {
                                        ParameterName = "@p2",
                                        GenericDbType = Unimake.Data.Generic.GenericDbType.Integer,
                                        Value = (int)TipoForma.Parcelado
                                    },
                                    new Parameter {
                                        ParameterName = "@p3",
                                        GenericDbType = Unimake.Data.Generic.GenericDbType.Integer,
                                        Value = (int)TipoForma.CreditoConsumidor
                                    }
                                }
                        }
                } :
                null);

                lstFormaPagto.Items.Clear();
                foreach (var f in formas.Values.OrderBy(o => o[1]))
                {
                    lstFormaPagto.Items.Add(new FormaPagamentoValue
                             {
                                 value = Unimake.Convert.ToString(f[0]),
                                 text = Unimake.Convert.ToString(f[2])
                             });
                }

                if (lstFormaPagto.Items.Count > 0)
                    lstFormaPagto.SelectedIndex = 0;
                sfChequeBanco.DataSource = new Banco().GetDisplayValues();
                usParcela.Visible = false;
                usParcela.OnParcelaRecalculada += (s) =>
                {
                    maskValorRecebido.Value = s.Sum(x => x.Valor);
                };
            }
        }
예제 #7
0
        private void btnOK_Click(object sender, System.EventArgs e)
        {
            ParentForm.DialogResult = DialogResult.None;
            #region Validar antes de continuar
            if (GUID.IsNullOrEmpty(lstFormaPagto.SelectedItem == null ? GUID.Empty : ((FormaPagamentoValue)lstFormaPagto.SelectedItem).value))
            {
                MessageBox.RequiredField(lstFormaPagto, "Forma de Pagamento");
                return;
            }

            if (maskValorRecebido.Value <= 0)
            {
                MessageBox.RequiredField(maskValorRecebido, "Valor Recebido");
                return;
            }

            //Validar o campo "Condição de Pagamento" e "Parcelas", somente se for o pagamento parcelado
            IImpressoraFormaPagto impForma = new ImpressoraFormaPagto(((FormaPagamentoValue)lstFormaPagto.SelectedItem).value.ToString());
            if (Tipo == Enuns.Cadastro.TipoForma.Parcelado)
            {
                if (GUID.IsNullOrEmpty(usParcela.CondicaoPagamento == null ? GUID.Empty : usParcela.CondicaoPagamento.GUID))
                {
                    MessageBox.RequiredField(usParcela, "Condição de Pagamento");
                    return;
                }
                else if (usParcela.Parcelas.Count == 0)
                {
                    MessageBox.RequiredField(usParcela, "Parcelas");
                    return;
                }
            }

            if (!Settings.TEF.UsaTEF &&
                Tipo.IsTEF())
            {
                if (txtNSU.Text.IsNullOrEmpty())
                {
                    MessageBox.RequiredField(txtNSU, "Valor NSU");
                    return;
                }
            }

            #endregion

            ParentForm.DialogResult = DialogResult.OK;

            if (OnOkClick != null)
            {
                FormaPagamentoEventArgs f = new FormaPagamentoEventArgs(FormaPagto.GUID);
                DadosCheque d = new DadosCheque();
                d.Agencia = txtChequeAgencia.Text;
                d.AgenciaDC = txtChequeC1.Text;
                d.Compensacao = Unimake.Convert.ToInt(txtChequeComp.Text);
                d.ContaCorrente = txtChequeContaCorrente.Text;
                d.ContaCorrenteDC = txtChequeC2.Text;
                d.Numero = txtChequeNumero.Text;
                d.NumeroDC = txtChequeC3.Text;
                d.Banco = new Banco(sfChequeBanco.SelectedItem.GUID);
                d.NumeroAutorizacao = txtNumAutorizacao.Text;
                f.Cheque = d;
                f.NSU = NSU;
                f.Voucher = Voucher;
                f.FormaPagamentoSelecionada = FormaPagto;

                OnOkClick(this, f);
            }
        }
예제 #8
0
 public override void Popular()
 {
     IImpressoraFormaPagto forma = new ImpressoraFormaPagto(GUID);
     DumpElement(forma);
 }
예제 #9
0
 public override void Editar()
 {
     IImpressoraFormaPagto forma = new ImpressoraFormaPagto(GUID);
     forma.Indice = 2;
     forma.Save();
 }
예제 #10
0
        /// <summary>
        /// Vincula as formas de pagamento da impressora fiscal com as formas de pagamento do sistema
        /// </summary>
        /// <param name="sender">Objeto que disparou o evento</param>
        /// <param name="e">Argumento do evento gerado</param>
        private void btnOK_Click(object sender, System.EventArgs e)
        {
            string formaPagto = string.Empty;

            Connection connection = null;

            #region validar
            foreach (DataGridViewRow item in grdFPECF.Rows)
            {
                if (item.IsNewRow) continue;

                if (String.IsNullOrEmpty(Unimake.Convert.ToString(item.Cells[colDescricao.Index].Value)))
                {
                    MessageBox.RequiredField("Descrição");
                    item.Selected = true;
                    return;
                }
            }
            #endregion

            #region salvar
            IConfiguracao conf = null;
            try
            {
                Wait.Show();
                connection = DbContext.CreateConnection();
                connection.BeginTransaction();
                using (conf = new OpenPOS.ECF.Configuracao(Settings.ECF.ECFAtual.ModeloACBR, Settings.ECF.ECFAtual.Porta))
                {
                    foreach (DataGridViewRow item in grdFPECF.Rows)
                    {
                        if (item.IsNewRow) continue;

                        int indice = Unimake.Convert.ToInt(item.Cells[colIndice.Index].Value);

                        IImpressoraFormaPagto impForma = item.Cells[colGUIDImpressoraForma.Index].Value as IImpressoraFormaPagto
                            ?? new ImpressoraFormaPagto();

                        IFormaPagamento forma = null;

                        formaPagto = item.Cells[colVinculado.Index].Value.ToString();

                        if (!formaPagto.IsNullOrEmpty())
                        {
                            //Pesquisa se tem a forma de pagamento selecionada da coluna "Vinculado" na base de dados na tabela ecf_ImpressoraFormaPagto
                            IList<IImpressoraFormaPagto> formasImp = new ImpressoraFormaPagto().Find<IImpressoraFormaPagto>(new Where
                        {
                            {
                                "ecf_ImpressoraFormaPagto.GUIDImpressora = @guidimp",
                                new Parameter
                                {
                                    ParameterName = "@guidimp",
                                    Value = Settings.ECF.ECFAtual.GUID.ToString()
                                }
                            },
                            {
                                "ecf_ImpressoraFormaPagto.Indice = @indice",
                                new Parameter
                                {
                                    ParameterName = "@indice",
                                    Value = indice
                                }
                            }
                        });

                            //Se já existe formas de pagamentos vinculadas, sabemos que é uma alteração
                            if (formasImp.Count > 0)
                            {
                                //Deletar todas as formas de pagamento vinculada para esse índice da forma de pagamento da impressora fiscal
                                foreach (IImpressoraFormaPagto fi in formasImp)
                                {
                                    impForma = new ImpressoraFormaPagto(fi.GUID);
                                    impForma.Delete();
                                }
                            }

                            //Salvar(Vincular) com a forma de pagamento selecionada
                            forma = new Data.Cadastro.FormaPagamento
                            {
                                GUID = formaPagto,
                                Descricao = item.Cells[colDescricao.Index].Value.ToString()
                            };

                            // verifica se tem forma cadastrada na impressora, se não, cadastra
                            #region cadastraFormImpressora
                            bool temImpForma = false;
                            for (int i = 0; i < conf.FormasPagamento.Length; i++)
                            {
                                if (item.Cells[colDescricao.Index].Value.ToString() == conf.FormasPagamento[i].Descricao)
                                {
                                    temImpForma = true;
                                    break;
                                }
                            }
                            if (!temImpForma)
                            {
                                //Descrição da forma de pagamento
                                string descricao = item.Cells[colDescricao.Index].Value.ToString();
                                //Permite o cupom vinculado
                                bool permiteVinculado = true;
                                //Posição da forma de pagamento
                                string posicao = "";

                                try
                                {
                                    conf.ProgramaFormaPagamento(descricao, permiteVinculado, posicao);
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(ex.Message);
                                }
                            }
                            #endregion cadastraFormImpressora

                            impForma.Impressora = Settings.ECF.ECFAtual;
                            impForma.FormaPagamento = forma;
                            impForma.Indice = indice;
                            impForma.Save();
                        }
                    }
                }

                connection.CommitTransaction();
                MessageBox.Show("Forma de pagamento vinculado com sucesso.");
                Close();
            }
            catch (Exception ex)
            {
                if (connection != null &&
                   connection.Transaction.State == TransactionState.Begin)
                    connection.BeginTransaction();

                MessageBox.ShowError(ex);
            }
            finally
            {
                connection.Close();
                conf.Dispose();
                Wait.Close();
            }
            #endregion
        }
예제 #11
0
        private void grdFPECF_OnToolbarDeleteClick(object sender, DataGridViewCellCancelEventArgs e)
        {
            foreach (DataGridViewRow row in grdFPECF.SelectedRows)
            {
                int indice = Unimake.Convert.ToInt(row.Cells[colIndice.Index].Value);
                string formaPagto = string.Empty;
                formaPagto = row.Cells[colVinculado.Index].Value.ToString();
                IImpressoraFormaPagto impForma = row.Cells[colGUIDImpressoraForma.Index].Value as IImpressoraFormaPagto
                            ?? new ImpressoraFormaPagto();

                if (!formaPagto.IsNullOrEmpty())
                {
                    //Pesquisa se tem a forma de pagamento selecionada da coluna "Vinculado" na base de dados na tabela ecf_ImpressoraFormaPagto
                    IList<IImpressoraFormaPagto> formasImp = new ImpressoraFormaPagto().Find<IImpressoraFormaPagto>(new Where
                    {
                        {
                            "ecf_ImpressoraFormaPagto.GUIDImpressora = @guidimp",
                            new Parameter
                            {
                                ParameterName = "@guidimp",
                                Value = Settings.ECF.ECFAtual.GUID.ToString()
                            }
                        },
                        {
                            "ecf_ImpressoraFormaPagto.Indice = @indice",
                            new Parameter
                            {
                                ParameterName = "@indice",
                                Value = indice
                            }
                        }
                    });

                    //Se já existe formas de pagamentos vinculadas
                    if (formasImp.Count > 0)
                    {
                        //Deletar todas as formas de pagamento vinculada para esse índice da forma de pagamento da impressora fiscal
                        foreach (IImpressoraFormaPagto fi in formasImp)
                        {
                            impForma = new ImpressoraFormaPagto(fi.GUID);
                            impForma.Delete();
                        }
                        row.Cells[colVinculado.Index].Value = "";  // limpa campo
                    }
                }
            }
        }