Esempio n. 1
0
        public void Sangria()
        {
            try
            {
                data = DateTime.Now.Date;
                decimal valorT        = 0;
                string  aberturaCupom = "";

                novaVenda = new RegraNegocio.VendaRegraNegocios();
                DataTable dadosTabela = new DataTable();
                dadosTabela = novaVenda.PesquisarSomaTotalDia(frmVenda.idUsuarioLogado, data);

                if (dadosTabela.Rows.Count > 0)
                {
                    valorT = Convert.ToDecimal(dadosTabela.Rows[0]["Total"].ToString());

                    if ((valorT > 0))
                    {
                        if (!String.IsNullOrEmpty(txtValorSangria.Text.Trim()) && (!String.IsNullOrEmpty(txtMotivoSangria.Text.Trim()) && (txtMotivoSangria.Text.Trim() != "0,00")))
                        {
                            valorSangria = Convert.ToDecimal(txtValorSangria.Text);

                            if (cbxSangria.Checked == true)
                            {
                                tipo      = true;
                                descricao = "SANGRIA";
                            }
                            else if (cbxSangria.Checked == false)
                            {
                                tipo      = false;
                                descricao = "DESPESA";
                            }

                            for (int i = 0; i < 2; i++)
                            {
                                if (nomeImpressora == "BEMATECH")
                                {
                                    aberturaCupom = ("----------------------------------\n" +
                                                     "         " + descricao + "         " +
                                                     "-----------------------------------");
                                    idRetorno = RegraNegocio.CupomFiscal.Bematech_FI_RelatorioGerencial(aberturaCupom + "\n");
                                    idRetorno = RegraNegocio.CupomFiscal.Bematech_FI_RelatorioGerencial(descricao.ToString() + ": " + lblQtde.Text + " ......................." + valorSangria.ToString("C2"));
                                    idRetorno = RegraNegocio.CupomFiscal.Bematech_FI_RelatorioGerencial("MOTIVO: " + txtMotivoSangria.Text);
                                    idRetorno = RegraNegocio.CupomFiscal.Bematech_FI_RelatorioGerencial("OPERADOR: " + frmVenda.operadorAtuante.ToString());
                                    idRetorno = RegraNegocio.CupomFiscal.Bematech_FI_RelatorioGerencial("Ass: ________________________________");
                                    idRetorno = RegraNegocio.CupomFiscal.Bematech_FI_FechaRelatorioGerencial();
                                }
                                else if ((nomeImpressora == "BEMASAT") || (nomeImpressora == "MP4200"))
                                {
                                    aberturaCupom = ("-----------------------------------------------\n" +
                                                     "                " + descricao + "            \n" +
                                                     "------------------------------------------------");

                                    string dadosSangriaBemasat = "";
                                    frmVenda.PesquisarNumCaixa_numBalanca_numPorstaCom_Xml();

                                    //ABRE IMPRESSORA
                                    idRetorno = RegraNegocio.MP2032.ConfiguraModeloImpressora(7);
                                    idRetorno = RegraNegocio.MP2032.IniciaPorta(frmVenda.numComimp);

                                    dadosSangriaBemasat = (descricao.ToString() + ": " + lblQtde.Text + " ......................." + valorSangria.ToString("C2") + "\n" +
                                                           "MOTIVO: " + txtMotivoSangria.Text + "\n" +
                                                           "OPERADOR: " + frmVenda.operadorAtuante.ToString() + "\n" +
                                                           "Ass: ________________________________\n");


                                    idRetorno = RegraNegocio.MP2032.BematechTX(aberturaCupom + "\n" + dadosSangriaBemasat);

                                    RegraNegocio.MP2032.BematechTX("\n\n\n\n");
                                    RegraNegocio.MP2032.AcionaGuilhotina(0);
                                    RegraNegocio.MP2032.FechaPorta();
                                }
                                else if (nomeImpressora == "ELGIN")
                                {
                                    string dadoSangriaElgin = "";

                                    aberturaCupom = ("---------------------------------------------\n" +
                                                     "                " + descricao + "            \n" +
                                                     "---------------- ------------------------------");

                                    var    configImpressora = new PrinterSettings();
                                    string printerName      = configImpressora.PrinterName;

                                    frmVenda.AbreCupomSegViaBemasat();
                                    string cabecalhoElgin = frmVenda.A;

                                    esc = new RegraNegocio.EscPos();
                                    this.esc.normalModeText(printerName);
                                    this.esc.printText(printerName, cabecalhoElgin + "\n");

                                    dadoSangriaElgin = (descricao.ToString() + ": " + lblQtde.Text + " ......................." + valorSangria.ToString("C2") + "\n" +
                                                        "MOTIVO: " + txtMotivoSangria.Text + "\n" +
                                                        "OPERADOR: " + frmVenda.operadorAtuante.ToString() + "\n" +
                                                        "Ass: ________________________________");

                                    esc = new RegraNegocio.EscPos();
                                    this.esc.printText(printerName, aberturaCupom + "\n" + dadoSangriaElgin);
                                    //this.esc.printBarcodeB(printerName, "{A012345678901234567", 73);

                                    this.esc.lineFeed(printerName, 2);
                                    feedAndCutter(printerName, 5);
                                }
                            }

                            novaVenda.GravarDadosSangria(frmVenda.idUsuarioLogado, Convert.ToDecimal(txtValorSangria.Text), txtMotivoSangria.Text, data, frmVenda.numcaixa, tipo, false);

                            MessageBox.Show("Registro de " + descricao + " foi Realizado com Sucesso.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            frmVenda.AtualizarGridAberto();
                            frmVenda.Refresh();
                            this.Close();
                            frmVenda.AtualizarGridAberto();
                            frmVenda.LimpaCampos();
                        }
                        else
                        {
                            MessageBox.Show("Informe Valor Desejado do Motivo da Retirada para Finalizar Sangria.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtMotivoSangria.Text = "";
                            txtMotivoSangria.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Não Contém Valor para Sangria.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LimparCampos();
                    }
                }

                else
                {
                    MessageBox.Show("Não foi Possivél Realizar a Operação Sangria de Caixa.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LimparCampos();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Saldo no Caixa Insuficiente para Realizar uma Sangria.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LimparCampos();
            }
        }
Esempio n. 2
0
        public void Logar()
        {
            try
            {
                if (txtLogin.Text != "")
                {
                    novoUsuario = new RegraNegocio.UsuarioRegraNegocio();
                    DataTable dadosTabela = new DataTable();
                    dadosTabela = novoUsuario.PesquisaLoginUsuario(txtLogin.Text);

                    caixaAberto = frmvenda.numcaixa;

                    if (dadosTabela.Rows.Count > 0)
                    {
                        caixaUsuario = Convert.ToInt32(dadosTabela.Rows[0]["NUM_CAIXA"].ToString());

                        if (caixaUsuario == caixaAberto)
                        {
                            AbrirCaixa();
                            frmvenda.AlterarStatusAbertura();

                            if (frmvenda.statusVenda == true)
                            {
                                novoUsuario = new RegraNegocio.UsuarioRegraNegocio();
                                novoUsuario.AlteraStatusUsuarioAberto(txtLogin.Text);

                                frmvenda.operadorAtuante = dadosTabela.Rows[0]["NOME"].ToString();
                                frmvenda.periodoAtuante_ = dadosTabela.Rows[0]["PERIODO"].ToString();

                                // AbrirCaixa();
                                // frmvenda.AlterarStatusAbertura();

                                frmvenda.DesbloquearBotoesTelaVenda();
                                frmvenda.AtualizarGridAberto();
                                frmvenda.LoadTela();
                                frmvenda.Refresh();
                                frmvenda.abrirCaixa = true;
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show("Caixa Nº: " + caixaAberto + "está Fechado.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                txtLogin.Focus();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Verifique se Usuário está Autorizado para Logar com Caixa Nº:" + caixaAberto + ", ou Entre em Contado com  Administrado.", "Atenção");
                            this.Close();
                            frmvenda.abrirCaixa = false;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Login está Incorreto para Realizar Operação Desejado.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtLogin.Focus();
                    }
                }
                else
                {
                    txtLogin.Focus();
                }
            }

            catch (Exception)
            {
                MessageBox.Show("Error no Método Logar.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }