public override bool doEvent(int event_number, object arg)
        {
            switch (event_number)
            {
                #region - event_Load -

            case event_Load:
            {
                //InitEventCode event_Load

                doEvent(event_Translate, null);
                doEvent(event_FormIsOpening, null);

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Translate -

            case event_Translate:
            {
                //InitEventCode event_Translate
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_FormIsOpening -

            case event_FormIsOpening:
            {
                //InitEventCode event_FormIsOpening

                ctrl_TxtMoney_Valor.AcquireTextBox(i_Form.TxtMoney_Valor, this, event_val_TxtMoney_Valor, "R$", 8);
                ctrl_TxtMoney_Valor.SetupErrorProvider(ErrorIconAlignment.MiddleRight, false);

                ctrl_TxtSenha.AcquireTextBox(i_Form.TxtSenha, this, event_val_TxtSenha, 4);
                ctrl_TxtCartao.AcquireTextBox(i_Form.TxtCartao, this, event_val_TxtCartao, 15);

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtMoney_Valor -

            case event_val_TxtMoney_Valor:
            {
                //InitEventCode event_val_TxtMoney_Valor

                string myValEv = arg as string;

                if (myValEv == moneyTextController.MONEY_ZERO)
                {
                    i_Form.TxtMoney_Valor.BackColor     = Color.Lavender;
                    ctrl_TxtMoney_Valor.IsUserValidated = false;
                    ctrl_TxtMoney_Valor.CleanError();
                }
                else
                {
                    i_Form.TxtMoney_Valor.BackColor     = Color.White;
                    ctrl_TxtMoney_Valor.IsUserValidated = true;
                    ctrl_TxtMoney_Valor.CleanError();
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtCartao -

            case event_val_TxtCartao:
            {
                //InitEventCode event_val_TxtCartao

                switch (arg as string)
                {
                case pincardTextController.PINCARD_INCOMPLETE:
                {
                    i_Form.TxtCartao.BackColor     = colorInvalid;
                    ctrl_TxtCartao.IsUserValidated = false;
                    break;
                }

                case pincardTextController.PINCARD_COMPLETE:
                {
                    i_Form.TxtCartao.BackColor     = Color.White;
                    ctrl_TxtCartao.IsUserValidated = true;
                    ctrl_TxtCartao.CleanError();

                    if (ctrl_TxtCartao.IsTermInput)
                    {
                        i_Form.TxtSenha.Focus();
                    }

                    break;
                }

                default: break;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtSenha -

            case event_val_TxtSenha:
            {
                //InitEventCode event_val_TxtSenha

                switch (arg as string)
                {
                case pinpadTextController.PINPAD_INCOMPLETE:
                case pinpadTextController.PINPAD_COMPLETE:
                {
                    if (i_Form.TxtSenha.Text.Length > 3)
                    {
                        i_Form.TxtSenha.BackColor     = Color.White;
                        ctrl_TxtSenha.IsUserValidated = true;
                        ctrl_TxtSenha.CleanError();
                    }
                    else
                    {
                        i_Form.TxtSenha.BackColor     = colorInvalid;
                        ctrl_TxtSenha.IsUserValidated = false;
                    }

                    break;
                }

                case pinpadTextController.PINPAD_ENTRA:
                {
                    doEvent(event_Confirmar, null);
                    break;
                }

                default: break;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Confirmar -

            case event_Confirmar:
            {
                //InitEventCode event_Confirmar

                if (!ctrl_TxtMoney_Valor.IsUserValidated)
                {
                    return(false);
                }

                var_exchange.m_Client.QuietMode = true;

                POS_Entrada pe = new POS_Entrada();

                string cript_senha = new ApplicationUtil().DESCript(ctrl_TxtSenha.getTextBoxValue().PadLeft(8, '*'), "12345678");

                pe.set_st_senha(cript_senha);
                pe.set_st_empresa(ctrl_TxtCartao.getTextBoxValue().Substring(0, 6));
                pe.set_st_matricula(ctrl_TxtCartao.getTextBoxValue().Substring(6, 6));
                pe.set_st_titularidade(ctrl_TxtCartao.getTextBoxValue().Substring(12, 2));
                pe.set_vr_valor(ctrl_TxtMoney_Valor.getTextBoxValue_NumberStr().PadLeft(12, '0'));
                pe.set_st_terminal(header.get_nu_terminal());
                pe.set_nu_parcelas("1");

                pe.set_st_valores(ctrl_TxtMoney_Valor.getTextBoxValue_NumberStr().PadLeft(12, '0'));

                POS_Resposta resp = new POS_Resposta();

                string msg = "";

                if (var_exchange.exec_pos_vendaEmpresarial(ref pe,
                                                           ref msg,
                                                           ref resp))
                {
                    string nsu_venda = resp.get_st_nsuRcb();

                    if (var_exchange.exec_pos_confirmaVendaEmpresarial(nsu_venda,
                                                                       ref pe,
                                                                       ref msg,
                                                                       ref resp))
                    {
                        MessageBox.Show("Venda online confirmada", "Aviso");
                    }
                }

                //EndEventCode
                return(true);
            }

                #endregion

            default: break;
            }

            return(false);
        }
示例#2
0
        public override bool doEvent(int event_number, object arg)
        {
            switch (event_number)
            {
                #region - event_Load -

            case event_Load:
            {
                //InitEventCode event_Load

                doEvent(event_Translate, null);
                doEvent(event_FormIsOpening, null);

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Translate -

            case event_Translate:
            {
                //InitEventCode event_Translate
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_FormIsOpening -

            case event_FormIsOpening:
            {
                //InitEventCode event_FormIsOpening

                string st_content = "";

                if (var_exchange.fetch_canc_dia_lojista(ref header, ref st_content))
                {
                    while (st_content != "")
                    {
                        ArrayList tmp_memory = new ArrayList();

                        if (var_exchange.fetch_memory(st_content, "200",
                                                      ref st_content,
                                                      ref tmp_memory))
                        {
                            for (int t = 0; t < tmp_memory.Count; ++t)
                            {
                                DadosConsultaTransacao dct = new DadosConsultaTransacao(tmp_memory [t] as DataPortable);

                                string [] full_row = new string [] { dct.get_st_cartao(),
                                                                     "R$ " + new money().formatToMoney(dct.get_vr_valor()),
                                                                     var_util.getDDMMYYYY_format(dct.get_dt_transacao()),
                                                                     dct.get_st_nsu() };

                                i_Form.LstVendas.Items.Add(var_util.GetListViewItem(null, full_row));
                            }
                        }
                    }
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BtnCancelarClick -

            case event_BtnCancelarClick:
            {
                //InitEventCode event_BtnCancelarClick

                if (i_Form.LstVendas.SelectedItems.Count == 0)
                {
                    return(false);
                }

                string dtax = i_Form.LstVendas.SelectedItems[0].SubItems[2].Text;
                string nsu  = i_Form.LstVendas.SelectedItems[0].SubItems[3].Text;

                string dta = var_util.GetDataBaseTimeFormat(
                    new DateTime(Convert.ToInt32(dtax.Substring(6, 4)),
                                 Convert.ToInt32(dtax.Substring(3, 2)),
                                 Convert.ToInt32(dtax.Substring(0, 2))));

                if (!var_exchange.fetch_dadosNSU(nsu,
                                                 dta,
                                                 TipoConfirmacao.Confirmada,
                                                 ref header,
                                                 ref dn))
                {
                    return(false);
                }

                POS_Entrada  pe = new POS_Entrada();
                POS_Resposta pr = new POS_Resposta();

                pe.set_st_terminal(dn.get_st_terminal());
                pe.set_st_empresa(dn.get_st_empresa());
                pe.set_st_matricula(dn.get_st_matricula());
                pe.set_st_titularidade(dn.get_st_titularidade());
                pe.set_nu_parcelas("0");

                string st_msg = "";

                var_exchange.m_Client.QuietMode = true;

                if (var_exchange.exec_pos_cancelaVendaEmpresarial(nsu,
                                                                  dta,
                                                                  header.get_st_user_id(),
                                                                  ref pe,
                                                                  ref st_msg,
                                                                  ref pr))
                {
                    MessageBox.Show("Sucesso no cancelamento", "Aviso");
                }
                else
                {
                    MessageBox.Show(st_msg, "Erro");
                }

                var_exchange.m_Client.QuietMode = false;

                doEvent(event_FormIsOpening, null);

                //EndEventCode
                return(true);
            }

                #endregion

            default: break;
            }

            return(false);
        }
        public override bool doEvent(int event_number, object arg)
        {
            switch (event_number)
            {
                #region - event_Load -

            case event_Load:
            {
                //InitEventCode event_Load

                                        #if ROBOT
                var_util.execDefinedRobot(this, var_alias);
                                        #else
                doEvent(event_Translate, null);
                doEvent(event_FormIsOpening, null);
                                        #endif

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Translate -

            case event_Translate:
            {
                //InitEventCode event_Translate
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_FormIsOpening -

            case event_FormIsOpening:
            {
                //InitEventCode event_FormIsOpening

                ctrl_TxtNSU.AcquireTextBox(i_Form.TxtNSU, this, event_val_TxtNSU, 6);
                ctrl_TxtDtIni.AcquireTextBox(i_Form.TxtDtIni, this, event_val_TxtDtIni, dateTextController.FORMAT_DDMMYYYY);

                ctrl_TxtDtIni.SetTextBoxText(DateTime.Now.Day.ToString().PadLeft(2, '0') +
                                             DateTime.Now.Month.ToString().PadLeft(2, '0') +
                                             DateTime.Now.Year.ToString().PadLeft(2, '0'));

                ctrl_TxtNSU.SetupErrorProvider(ErrorIconAlignment.MiddleRight, false);

                //EndEventCode
                return(true);
            }

                #endregion

                #region - robot_ShowDialog -

            case robot_ShowDialog:
            {
                //InitEventCode robot_ShowDialog
                //EndEventCode
                return(true);
            }

                #endregion

                #region - robot_CloseDialog -

            case robot_CloseDialog:
            {
                //InitEventCode robot_CloseDialog
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtNSU -

            case event_val_TxtNSU:
            {
                //InitEventCode event_val_TxtNSU

                switch (arg as string)
                {
                case numberTextController.NUMBER_INCOMPLETE:
                case numberTextController.NUMBER_COMPLETE:
                {
                    if (i_Form.TxtNSU.Text.Length > 0)
                    {
                        i_Form.TxtNSU.BackColor     = Color.White;
                        ctrl_TxtNSU.IsUserValidated = true;
                        ctrl_TxtNSU.CleanError();

                        if (ctrl_TxtNSU.GetEnterPressed())
                        {
                            doEvent(event_BuscaDados, null);
                        }
                    }
                    else
                    {
                        i_Form.TxtNSU.BackColor     = colorInvalid;
                        ctrl_TxtNSU.IsUserValidated = false;
                    }

                    break;
                }

                default: break;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Confirmar -

            case event_Confirmar:
            {
                //InitEventCode event_Confirmar

                bool IsDone = true;

                if (!ctrl_TxtNSU.IsUserValidated)
                {
                    ctrl_TxtNSU.SetErrorMessage("O numerode NSU deve ser informado"); IsDone = false;
                }

                if (!IsDone)
                {
                    return(false);
                }

                if (!doEvent(event_BuscaDados, null))
                {
                    return(false);
                }

                POS_Entrada  pe = new POS_Entrada();
                POS_Resposta pr = new POS_Resposta();

                pe.set_st_terminal(dn.get_st_terminal());
                pe.set_st_empresa(dn.get_st_empresa());
                pe.set_st_matricula(dn.get_st_matricula());
                pe.set_st_titularidade(dn.get_st_titularidade());
                pe.set_nu_parcelas("0");

                string st_msg = "";

                var_exchange.m_Client.QuietMode = true;

                if (var_exchange.exec_pos_cancelaVendaEmpresarial(ctrl_TxtNSU.getTextBoxValue(),
                                                                  var_util.GetDataBaseTimeFormat(ctrl_TxtDtIni.getTextBoxValue_Date()),
                                                                  header.get_st_user_id(),
                                                                  ref pe,
                                                                  ref st_msg,
                                                                  ref pr))
                {
                    MessageBox.Show("Sucesso no cancelamento", "Aviso");
                }
                else
                {
                    MessageBox.Show(st_msg, "Erro");
                }

                var_exchange.m_Client.QuietMode = false;

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BuscaDados -

            case event_BuscaDados:
            {
                //InitEventCode event_BuscaDados

                if (var_exchange.fetch_dadosNSU(ctrl_TxtNSU.getTextBoxValue(),
                                                var_util.GetDataBaseTimeFormat(ctrl_TxtDtIni.getTextBoxValue_Date()),
                                                TipoConfirmacao.Confirmada,
                                                ref header,
                                                ref dn))
                {
                    i_Form.TxtNome.Text   = dn.get_st_nome();
                    i_Form.TxtCartao.Text = dn.get_st_cartao();
                    i_Form.TxtData.Text   = dn.get_dt_operacao();
                    i_Form.TxtValor.Text  = "R$ " + new money().formatToMoney(dn.get_vr_valor());

                    ctrl_TxtNSU.SetTextBoxText(ctrl_TxtNSU.getTextBoxValue().PadLeft(6, '0'));
                }
                else
                {
                    return(false);
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtDtIni -

            case event_val_TxtDtIni:
            {
                //InitEventCode event_val_TxtDtIni

                switch (arg as string)
                {
                case dateTextController.DATE_INVALID:
                {
                    i_Form.TxtDtIni.BackColor     = colorInvalid;
                    ctrl_TxtDtIni.IsUserValidated = false;
                    break;
                }

                case dateTextController.DATE_VALID:
                {
                    i_Form.TxtDtIni.BackColor     = Color.White;
                    ctrl_TxtDtIni.IsUserValidated = true;
                    ctrl_TxtDtIni.CleanError();

                    if (ctrl_TxtDtIni.GetEnterPressed())
                    {
                        doEvent(event_BuscaDados, null);
                    }
                    break;
                }

                default: break;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BtnConfirmarClick -

            case event_BtnConfirmarClick:
            {
                //InitEventCode event_BtnConfirmarClick
                //EndEventCode
                return(true);
            }

                #endregion

            default: break;
            }

            return(false);
        }
        public override bool doEvent(int event_number, object arg)
        {
            switch (event_number)
            {
                #region - event_Load -

            case event_Load:
            {
                //InitEventCode event_Load

                                        #if ROBOT
                var_util.execDefinedRobot(this, var_alias);
                                        #else
                doEvent(event_Translate, null);
                doEvent(event_FormIsOpening, null);
                                        #endif

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Translate -

            case event_Translate:
            {
                //InitEventCode event_Translate
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_FormIsOpening -

            case event_FormIsOpening:
            {
                //InitEventCode event_FormIsOpening

                ctrl_TxtEmpresa.AcquireTextBox(i_Form.TxtEmpresa, this, event_val_TxtEmpresa, 6);
                ctrl_TxtMatricula.AcquireTextBox(i_Form.TxtMatricula, this, event_val_TxtMatricula, 6);
                ctrl_TxtTitularidade.AcquireTextBox(i_Form.TxtTitularidade, this, event_val_TxtTitularidade, 4);
                ctrl_TxtValor.AcquireTextBox(i_Form.TxtValor, this, event_val_TxtValor, "R$", 9);

                ctrl_TxtCodAcesso.AcquireTextBox(i_Form.TxtCodAcesso, this, event_val_TxtCodAcesso, 4);

                ctrl_TxtEmpresa.SetupErrorProvider(ErrorIconAlignment.MiddleRight, false);
                ctrl_TxtMatricula.SetupErrorProvider(ErrorIconAlignment.MiddleRight, false);
                ctrl_TxtTitularidade.SetupErrorProvider(ErrorIconAlignment.MiddleRight, false);
                ctrl_TxtValor.SetupErrorProvider(ErrorIconAlignment.MiddleRight, false);

                if (header.get_tg_user_type() == TipoUsuario.VendedorGift ||
                    header.get_tg_user_type() == TipoUsuario.AdminGift ||
                    header.get_tg_user_type() == TipoUsuario.Operador ||
                    header.get_tg_user_type() == TipoUsuario.Administrador)
                {
                    ctrl_TxtEmpresa.SetTextBoxText(header.get_st_empresa());
                    i_Form.TxtEmpresa.ReadOnly = true;
                }

                DadosConsultaLoja dcl = new DadosConsultaLoja();

                dcl.set_st_empresa(header.get_st_empresa());

                string st_csv_id = "";

                if (var_exchange.fetch_consultaLojasGift(header.get_st_empresa(),
                                                         ref header,
                                                         ref st_csv_id))
                {
                    ArrayList tmp_memory = new ArrayList();

                    while (st_csv_id != "")
                    {
                        if (var_exchange.fetch_memory(st_csv_id, "120", ref st_csv_id, ref tmp_memory))
                        {
                            for (int t = 0; t < tmp_memory.Count; ++t)
                            {
                                lstLojas.Add(tmp_memory[t]);
                            }
                        }
                    }

                    for (int t = 0; t < lstLojas.Count; ++t)
                    {
                        DadosLoja dl = new DadosLoja(lstLojas[t] as DataPortable);

                        i_Form.LstLojas.Items.Add(dl.get_st_nome());
                    }
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - robot_ShowDialog -

            case robot_ShowDialog:
            {
                //InitEventCode robot_ShowDialog
                //EndEventCode
                return(true);
            }

                #endregion

                #region - robot_CloseDialog -

            case robot_CloseDialog:
            {
                //InitEventCode robot_CloseDialog
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Confirmar -

            case event_Confirmar:
            {
                //InitEventCode event_Confirmar

                bool IsDone = true;

                if (!ctrl_TxtEmpresa.IsUserValidated)
                {
                    ctrl_TxtEmpresa.SetErrorMessage("O código da empresa deve ser informado");      IsDone = false;
                }
                if (!ctrl_TxtMatricula.IsUserValidated)
                {
                    ctrl_TxtMatricula.SetErrorMessage("O código da matricula deve ser informado");      IsDone = false;
                }
                if (!ctrl_TxtTitularidade.IsUserValidated)
                {
                    ctrl_TxtTitularidade.SetErrorMessage("A titularidade do cartão deve ser informada");      IsDone = false;
                }
                if (!ctrl_TxtValor.IsUserValidated)
                {
                    ctrl_TxtValor.SetErrorMessage("O valor da venda deve ser informado");      IsDone = false;
                }
                if (!ctrl_TxtCodAcesso.IsUserValidated)
                {
                    ctrl_TxtValor.SetErrorMessage("O código de acesso deve ser informado");      IsDone = false;
                }

                if (i_Form.LstLojas.SelectedIndex == -1)
                {
                    MessageBox.Show("Selecione a loja");
                    return(false);
                }

                if (!IsDone)
                {
                    return(false);
                }

                if (MessageBox.Show("Confirma venda no valor de R$ " +
                                    ctrl_TxtValor.getTextBoxValue() +
                                    " para " +
                                    i_Form.LstLojas.SelectedItem.ToString() +
                                    " ?",
                                    "Aviso",
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question,
                                    MessageBoxDefaultButton.Button2) == DialogResult.No)
                {
                    return(false);
                }

                string cript_senha = new ApplicationUtil().DESCript("9999".PadLeft(8, '*'), "12345678");

                DadosLoja dl = new DadosLoja(lstLojas [i_Form.LstLojas.SelectedIndex] as DataPortable);

                POS_Entrada pe = new POS_Entrada();

                pe.set_st_senha(cript_senha);
                pe.set_st_empresa(ctrl_TxtEmpresa.getTextBoxValue().PadLeft(6, '0'));
                pe.set_st_matricula(ctrl_TxtMatricula.getTextBoxValue().PadLeft(6, '0'));
                pe.set_st_titularidade("01");
                pe.set_vr_valor(ctrl_TxtValor.getTextBoxValue_NumberStr().PadLeft(12, '0'));
                pe.set_st_terminal(dl.get_st_obs());
                pe.set_nu_parcelas("1");
                pe.set_st_valores(ctrl_TxtValor.getTextBoxValue_NumberStr().PadLeft(12, '0'));

                POS_Resposta resp = new POS_Resposta();

                string msg = "";

                var_exchange.m_Client.QuietMode = true;


                string codAc = var_util.calculaCodigoAcesso(ctrl_TxtEmpresa.getTextBoxValue().PadLeft(6, '0'),
                                                            ctrl_TxtMatricula.getTextBoxValue().PadLeft(6, '0'),
                                                            ctrl_TxtTitularidade.getTextBoxValue());

                if (codAc != ctrl_TxtCodAcesso.getTextBoxValue())
                {
                    MessageBox.Show("Cartão inválido", "Aviso");
                    return(false);
                }

                if (var_exchange.exec_pos_vendaEmpresarial(ref pe,
                                                           ref msg,
                                                           ref resp))
                {
                    nsu_venda = resp.get_st_nsuRcb();

                    if (var_exchange.exec_pos_confirmaVendaEmpresarial(nsu_venda,
                                                                       ref pe,
                                                                       ref msg,
                                                                       ref resp))
                    {
                        var_exchange.m_Client.QuietMode = false;

                        MessageBox.Show("NSU: " + nsu_venda, "Transação confirmada");

                        PrintDocument pd      = new PrintDocument();
                        PrintDialog   pDialog = new PrintDialog();

                        pDialog.Document = pd;

                        PrintPreviewDialog prevDialog = new PrintPreviewDialog();
                        prevDialog.Document = pd;

                        pd.PrintPage += new PrintPageEventHandler(i_Form.Inven_Report);
                        prevDialog.ShowDialog();

                        if (pDialog.ShowDialog() == DialogResult.OK)
                        {
                            pd.Print();
                        }
                    }
                    else
                    {
                        MessageBox.Show(msg, "Erro na transação");
                    }
                }
                else
                {
                    MessageBox.Show(msg, "Erro na transação");
                }

                var_exchange.m_Client.QuietMode = false;

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtEmpresa -

            case event_val_TxtEmpresa:
            {
                //InitEventCode event_val_TxtEmpresa

                switch (arg as string)
                {
                case numberTextController.NUMBER_INCOMPLETE:
                case numberTextController.NUMBER_COMPLETE:
                {
                    if (i_Form.TxtEmpresa.Text.Length > 0)
                    {
                        i_Form.TxtEmpresa.BackColor     = Color.White;
                        ctrl_TxtEmpresa.IsUserValidated = true;
                        ctrl_TxtEmpresa.CleanError();
                    }
                    else
                    {
                        i_Form.TxtEmpresa.BackColor     = colorInvalid;
                        ctrl_TxtEmpresa.IsUserValidated = false;
                    }

                    break;
                }

                default: break;
                }

                if (ctrl_TxtEmpresa.GetEnterPressed())
                {
                    doEvent(event_BuscaDados, null);
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtMatricula -

            case event_val_TxtMatricula:
            {
                //InitEventCode event_val_TxtMatricula

                switch (arg as string)
                {
                case numberTextController.NUMBER_INCOMPLETE:
                case numberTextController.NUMBER_COMPLETE:
                {
                    if (i_Form.TxtMatricula.Text.Length > 0)
                    {
                        i_Form.TxtMatricula.BackColor     = Color.White;
                        ctrl_TxtMatricula.IsUserValidated = true;
                        ctrl_TxtMatricula.CleanError();
                    }
                    else
                    {
                        i_Form.TxtMatricula.BackColor     = colorInvalid;
                        ctrl_TxtMatricula.IsUserValidated = false;
                    }

                    break;
                }

                default: break;
                }

                if (ctrl_TxtMatricula.GetEnterPressed())
                {
                    doEvent(event_BuscaDados, null);
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtTitularidade -

            case event_val_TxtTitularidade:
            {
                //InitEventCode event_val_TxtTitularidade

                switch (arg as string)
                {
                case numberTextController.NUMBER_INCOMPLETE:
                case numberTextController.NUMBER_COMPLETE:
                {
                    if (i_Form.TxtTitularidade.Text.Length == 4)
                    {
                        i_Form.TxtTitularidade.BackColor     = Color.White;
                        ctrl_TxtTitularidade.IsUserValidated = true;
                        ctrl_TxtTitularidade.CleanError();
                    }
                    else
                    {
                        i_Form.TxtTitularidade.BackColor     = colorInvalid;
                        ctrl_TxtTitularidade.IsUserValidated = false;
                    }

                    break;
                }

                default: break;
                }

                if (ctrl_TxtTitularidade.GetEnterPressed())
                {
                    doEvent(event_BuscaDados, null);
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtValor -

            case event_val_TxtValor:
            {
                //InitEventCode event_val_TxtValor

                if (arg as string == moneyTextController.MONEY_ZERO)
                {
                    i_Form.TxtValor.BackColor     = colorInvalid;
                    ctrl_TxtValor.IsUserValidated = false;
                }
                else
                {
                    i_Form.TxtValor.BackColor     = Color.White;
                    ctrl_TxtValor.IsUserValidated = true;
                    ctrl_TxtValor.CleanError();
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BuscaDados -

            case event_BuscaDados:
            {
                //InitEventCode event_BuscaDados

                string st_nu_maxParcelas = "";
                string st_vr_dispMes     = "";
                string st_vr_dispTotal   = "";
                string st_nome           = "";

                if (var_exchange.fetch_dadosCartao(ctrl_TxtEmpresa.getTextBoxValue(),
                                                   ctrl_TxtMatricula.getTextBoxValue(),
                                                   "01",
                                                   ref header,
                                                   ref st_nu_maxParcelas,
                                                   ref st_vr_dispMes,
                                                   ref st_vr_dispTotal,
                                                   ref st_nome))
                {
                    i_Form.TxtVrDispTotal.Text = new money().formatToMoney(st_vr_dispTotal);
                    i_Form.TxtNome.Text        = st_nome;
                }
                else
                {
                    i_Form.TxtVrDispTotal.Text = "";
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Print -

            case event_Print:
            {
                //InitEventCode event_Print

                ArrayList lst = new ArrayList();

                var_exchange.fetch_reciboVendaGift(nsu_venda, ref header, ref lst);

                PrintPageEventArgs e = arg as PrintPageEventArgs;

                Graphics g      = e.Graphics;
                int      n      = 0;
                Font     myFont = new Font("Courier New", 10);

                try
                {
                    for (int t = 0; t < lst.Count; ++t)
                    {
                        DataPortable port = lst[t] as DataPortable;

                        g.DrawString(port.getValue("linha"), myFont, Brushes.Black, 10, 10 + (n * 20)); ++n;
                    }

                    myFont.Dispose();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtCodAcesso -

            case event_val_TxtCodAcesso:
            {
                //InitEventCode event_val_TxtCodAcesso

                switch (arg as string)
                {
                case numberTextController.NUMBER_INCOMPLETE:
                case numberTextController.NUMBER_COMPLETE:
                {
                    if (i_Form.TxtCodAcesso.Text.Length == 4)
                    {
                        i_Form.TxtCodAcesso.BackColor     = Color.White;
                        ctrl_TxtCodAcesso.IsUserValidated = true;
                        ctrl_TxtCodAcesso.CleanError();
                    }
                    else
                    {
                        i_Form.TxtCodAcesso.BackColor     = colorInvalid;
                        ctrl_TxtCodAcesso.IsUserValidated = false;
                    }

                    break;
                }

                default: break;
                }

                if (ctrl_TxtCodAcesso.GetEnterPressed())
                {
                    doEvent(event_BuscaDados, null);
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BtnConfirmarClick -

            case event_BtnConfirmarClick:
            {
                //InitEventCode event_BtnConfirmarClick
                //EndEventCode
                return(true);
            }

                #endregion

            default: break;
            }

            return(false);
        }
        public override bool doEvent(int event_number, object arg)
        {
            switch (event_number)
            {
                #region - event_Load -

            case event_Load:
            {
                //InitEventCode event_Load

                                        #if ROBOT
                var_util.execDefinedRobot(this, var_alias);
                                        #else
                doEvent(event_Translate, null);
                doEvent(event_FormIsOpening, null);
                                        #endif

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Translate -

            case event_Translate:
            {
                //InitEventCode event_Translate
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_FormIsOpening -

            case event_FormIsOpening:
            {
                //InitEventCode event_FormIsOpening

                ctrl_TxtSenha.AcquireTextBox(i_Form.TxtSenha, this, event_val_TxtSenha, 4);
                ctrl_TxtCartao.AcquireTextBox(i_Form.TxtCartao, this, event_val_TxtCartao, 15);
                ctrl_TxtValor.AcquireTextBox(i_Form.TxtValor, this, event_val_TxtValor, "R$", 9);

                ctrl_TxtParcelas.AcquireTextBox(i_Form.TxtParcelas, this, event_val_TxtParcelas, 2);

                ctrl_TxtSenha.SetupErrorProvider(ErrorIconAlignment.MiddleRight, false);
                ctrl_TxtCartao.SetupErrorProvider(ErrorIconAlignment.MiddleRight, false);

                ctrl_TxtParcelas.SetTextBoxText("1");

                //EndEventCode
                return(true);
            }

                #endregion

                #region - robot_ShowDialog -

            case robot_ShowDialog:
            {
                //InitEventCode robot_ShowDialog
                //EndEventCode
                return(true);
            }

                #endregion

                #region - robot_CloseDialog -

            case robot_CloseDialog:
            {
                //InitEventCode robot_CloseDialog
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtSenha -

            case event_val_TxtSenha:
            {
                //InitEventCode event_val_TxtSenha

                switch (arg as string)
                {
                case pinpadTextController.PINPAD_INCOMPLETE:
                case pinpadTextController.PINPAD_COMPLETE:
                {
                    if (i_Form.TxtSenha.Text.Length > 3)
                    {
                        i_Form.TxtSenha.BackColor     = Color.White;
                        ctrl_TxtSenha.IsUserValidated = true;
                        ctrl_TxtSenha.CleanError();
                    }
                    else
                    {
                        i_Form.TxtSenha.BackColor     = colorInvalid;
                        ctrl_TxtSenha.IsUserValidated = false;
                    }

                    break;
                }

                case pinpadTextController.PINPAD_ENTRA:
                {
                    doEvent(event_Confirmar, null);
                    break;
                }

                default: break;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtCartao -

            case event_val_TxtCartao:
            {
                //InitEventCode event_val_TxtCartao

                switch (arg as string)
                {
                case pincardTextController.PINCARD_INCOMPLETE:
                {
                    i_Form.TxtCartao.BackColor     = colorInvalid;
                    ctrl_TxtCartao.IsUserValidated = false;
                    break;
                }

                case pincardTextController.PINCARD_COMPLETE:
                {
                    i_Form.TxtCartao.BackColor     = Color.White;
                    ctrl_TxtCartao.IsUserValidated = true;
                    ctrl_TxtCartao.CleanError();

                    if (ctrl_TxtCartao.IsTermInput)
                    {
                        i_Form.TxtSenha.Focus();
                    }

                    break;
                }

                default: break;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtValor -

            case event_val_TxtValor:
            {
                //InitEventCode event_val_TxtValor

                if (arg as string == moneyTextController.MONEY_ZERO)
                {
                    i_Form.TxtValor.BackColor     = colorInvalid;
                    ctrl_TxtValor.IsUserValidated = false;
                }
                else
                {
                    i_Form.TxtValor.BackColor     = Color.White;
                    ctrl_TxtValor.IsUserValidated = true;
                    ctrl_TxtValor.CleanError();
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Confirmar -

            case event_Confirmar:
            {
                //InitEventCode event_Confirmar

                if (!ctrl_TxtValor.IsUserValidated)
                {
                    return(false);
                }

                var_exchange.m_Client.QuietMode = true;

                POS_Entrada pe = new POS_Entrada();

                string cript_senha = new ApplicationUtil().DESCript(ctrl_TxtSenha.getTextBoxValue().PadLeft(8, '*'), "12345678");

                pe.set_st_senha(cript_senha);
                pe.set_st_empresa(ctrl_TxtCartao.getTextBoxValue().Substring(0, 6));
                pe.set_st_matricula(ctrl_TxtCartao.getTextBoxValue().Substring(6, 6));
                pe.set_st_titularidade(ctrl_TxtCartao.getTextBoxValue().Substring(12, 2));
                pe.set_vr_valor(ctrl_TxtValor.getTextBoxValue_NumberStr().PadLeft(12, '0'));
                pe.set_st_terminal(header.get_nu_terminal());
                pe.set_nu_parcelas(ctrl_TxtParcelas.getTextBoxValue());

                if (ctrl_TxtParcelas.getTextBoxValue_Long() == 1)
                {
                    pe.set_st_valores(ctrl_TxtValor.getTextBoxValue_NumberStr().PadLeft(12, '0'));
                }
                else
                {
                    string st_lst_val = "";

                    for (int t = 0; t < lstPar.Count; ++t)
                    {
                        st_lst_val += lstPar[t].ToString().PadLeft(12, '0');
                    }

                    pe.set_st_valores(st_lst_val);
                }

                POS_Resposta resp = new POS_Resposta();

                string msg = "";

                if (var_exchange.exec_pos_vendaEmpresarial(ref pe,
                                                           ref msg,
                                                           ref resp))
                {
                    nsu_venda = resp.get_st_nsuRcb();

                    if (var_exchange.exec_pos_confirmaVendaEmpresarial(nsu_venda,
                                                                       ref pe,
                                                                       ref msg,
                                                                       ref resp))
                    {
                        var_exchange.m_Client.QuietMode = false;

                        MessageBox.Show("NSU: " + nsu_venda, "Transação confirmada");

                        PrintDocument pd      = new PrintDocument();
                        PrintDialog   pDialog = new PrintDialog();

                        pDialog.Document = pd;

                        PrintPreviewDialog prevDialog = new PrintPreviewDialog();
                        prevDialog.Document = pd;

                        pd.PrintPage += new PrintPageEventHandler(i_Form.Inven_Report);
                        prevDialog.ShowDialog();

                        if (pDialog.ShowDialog() == DialogResult.OK)
                        {
                            pd.Print();
                        }
                    }
                    else
                    {
                        MessageBox.Show(msg, "Erro na transação");
                    }
                }
                else
                {
                    MessageBox.Show(msg, "Erro na transação");
                }

                var_exchange.m_Client.QuietMode = false;

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Print -

            case event_Print:
            {
                //InitEventCode event_Print

                ArrayList lst = new ArrayList();

                var_exchange.fetch_reciboVendaLojista(nsu_venda, ref header, ref lst);

                PrintPageEventArgs e = arg as PrintPageEventArgs;

                Graphics g      = e.Graphics;
                int      n      = 0;
                Font     myFont = new Font("Courier New", 10);

                try
                {
                    for (int t = 0; t < lst.Count; ++t)
                    {
                        DataPortable port = lst[t] as DataPortable;

                        g.DrawString(port.getValue("linha"), myFont, Brushes.Black, 10, 10 + (n * 20)); ++n;
                    }

                    myFont.Dispose();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }

                i_Form.Close();

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Definir -

            case event_Definir:
            {
                //InitEventCode event_Definir

                event_dlgVendaParcelada ev_call = new event_dlgVendaParcelada(var_util, var_exchange);

                ev_call.header    = header;
                ev_call.lstPar    = lstPar;
                ev_call.tot_parcs = ctrl_TxtParcelas.getTextBoxValue_Long();
                ev_call.tot_valor = ctrl_TxtValor.getTextBoxValue_Long();

                ev_call.i_Form.ShowDialog();

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtParcelas -

            case event_val_TxtParcelas:
            {
                //InitEventCode event_val_TxtParcelas
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BtnConfirmarClick -

            case event_BtnConfirmarClick:
            {
                //InitEventCode event_BtnConfirmarClick
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BtnDivisaoClick -

            case event_BtnDivisaoClick:
            {
                //InitEventCode event_BtnDivisaoClick
                //EndEventCode
                return(true);
            }

                #endregion

            default: break;
            }

            return(false);
        }