예제 #1
0
        private void botaoF2_Click(object sender, EventArgs e)
        {
            if (CurrentCaixa == null)
                return;

            IAbreFechaCaixa t = CurrentCaixa;
            Data.FrenteCaixa.Conferencia.Caixa cx = new Data.FrenteCaixa.Conferencia.Caixa();
            cx.AbreFechaCaixa = t;
            cx.UsuarioConferencia = Settings.UsuarioAtual;
            foreach (object[] obj in grdFormasPagamento.DataSource.Values)
            {
                cx.FormasPagamento.Add(new CaixaFormaPagto()
                {
                    Status = Enuns.FrenteCaixa.Conferencia.Status.Conferido,
                    ValorConferido = Unimake.Convert.ToDouble(obj[3]),
                    ValorMovimento = Unimake.Convert.ToDouble(obj[2]),
                    Tipo = Unimake.Convert.ToEnum<TipoForma>(obj[1])
                });
            }
            cx.Tipo = Enuns.FrenteCaixa.Conferencia.Tipo.Auditoria;
            cx.Save();
            System.Windows.Forms.MessageBox.Show("Auditoria executada com sucesso!", "Mensagem");
            grdFormasPagamento.Clear();
            PopulateLanc();
        }
예제 #2
0
        /// <summary>
        /// Evento Click do botão de fechamento 
        /// </summary>
        /// <param name="sender">Objeto que disparou o evento</param>
        /// <param name="e">Parametros do evento</param>
        private void btnFechamentoCaixa_Click(object sender, System.EventArgs e)
        {
            #region fechar

            Wait.Show();

            if(!Validate())
            {
                Wait.Close();
                return;
            }

            //Procurar pela abertura do caixa através do usuário e caixa selecionados na tabela de "cxa_lancccaixa", ou seja tabela responsável por
            //armazenar todos os lançamentos feitos pelo usuário sendo eles: sangria, suprimento, cupom fiscal, etc
            IList<IContaCorrenteCaixa> lancamentosCaixa = new LancamentoCaixa().Find
                (
                    new Data.FrenteCaixa.Cadastro.Caixa
                    {
                        GUID = sfVlrNumeroCaixa.SelectedItem.GUID
                    },
                    new Usuario
                    {
                        GUID = sfUsuario.SelectedItem.GUID
                    }
                );

            GUID caixaAberto = null;

            foreach(IContaCorrenteCaixa lancamento in lancamentosCaixa.OrderBy(o => o.AbreFechaCaixa.DataHoraAbertura))
            {
                if(lancamento.AbreFechaCaixa.Status == Enuns.FrenteCaixa.Cadastro.Caixa.Status.Aberto)
                {
                    caixaAberto = lancamento.AbreFechaCaixa.GUID;
                    break;
                }
            }

            if(!caixaAberto.IsNullOrEmpty())
            {
                //Fazer o fechamento do caixa aberto
                FechaCaixa t = new FechaCaixa(caixaAberto);

                t.Caixa = new OpenPOS.Data.FrenteCaixa.Cadastro.Caixa(sfVlrNumeroCaixa.SelectedItem.GUID);
                t.DataHoraFechamento = Unimake.Convert.ToDateTime(String.Format("{0:dd/MM/yyyy HH:mm:ss}", DateTime.Now));

                Data.FrenteCaixa.Conferencia.Caixa cx = new Data.FrenteCaixa.Conferencia.Caixa();

                cx.AbreFechaCaixa = Data.FrenteCaixa.Lancamento.AbreCaixa.Create(caixaAberto);
                cx.UsuarioConferencia = Usuario;
                cx.Tipo = Enuns.FrenteCaixa.Conferencia.Tipo.Conferencia;

                foreach(object[] obj in grdLancamentos.DataSource.Values)
                {
                    if(PermiteVerCaixa)
                    {
                        cx.FormasPagamento.Add(new CaixaFormaPagto()
                        {
                            Status = Enuns.FrenteCaixa.Conferencia.Status.Conferido,
                            ValorConferido = Unimake.Convert.ToDouble(obj[3]),
                            ValorMovimento = Unimake.Convert.ToDouble(obj[2]),
                            Tipo = Unimake.Convert.ToEnum<TipoForma>(obj[1])
                        });
                    }
                    else
                    {
                        cx.FormasPagamento.Add(new CaixaFormaPagto()
                        {
                            Status = Enuns.FrenteCaixa.Conferencia.Status.Conferido,
                            ValorConferido = Unimake.Convert.ToDouble(obj[2]),
                            Tipo = Unimake.Convert.ToEnum<TipoForma>(obj[1])
                        });
                    }
                }

                t.OperadorAFechar = Usuario;
                t.Save();

                //Encerra o processo de fechamento do caixa
                if(t.Status == Enuns.FrenteCaixa.Cadastro.Caixa.Status.Fechado)
                {
                    //Atualizar as informações dos componentes do formulário
                    lblCaixaFechado.Visible = true;
                    lblCaixaFechado.Text = t.Status.ToString();
                    lblMensagem.Visible = true;
                }

                //Fazer a conferência do caixa pelos operadores
                cx.Save();

                PopulateCombo();
                sfVlrNumeroCaixa.Clear();
                sfUsuario.Clear();
            }
            #endregion

            Wait.Close();

            grdLancamentos.Clear();
            MessageBox.Show("Caixa fechado com sucesso.");
        }