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);
        }
Exemplo n.º 2
0
        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_TxtCartao.AcquireTextBox(i_Form.TxtCartao, this, event_val_TxtCartao, 6);

                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;
                }

                //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_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();

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

                    break;
                }

                default: break;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtCartao -

            case event_val_TxtCartao:
            {
                //InitEventCode event_val_TxtCartao

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

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

                    break;
                }

                default: break;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Confirmar -

            case event_Confirmar:
            {
                //InitEventCode event_Confirmar

                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();
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BuscaDados -

            case event_BuscaDados:
            {
                //InitEventCode event_BuscaDados

                if (!ctrl_TxtEmpresa.IsUserValidated &&
                    !ctrl_TxtCartao.IsUserValidated)
                {
                    return(false);
                }

                ArrayList lstCred    = new ArrayList();
                ArrayList lstProd    = new ArrayList();
                ArrayList lstComprov = new ArrayList();

                string nome = "";
                string disp = "";
                string sit  = "";

                if (!var_exchange.fetch_consultaCartaoGift(ctrl_TxtEmpresa.getTextBoxValue(),
                                                           ctrl_TxtCartao.getTextBoxValue(),
                                                           ref header,
                                                           ref nome,
                                                           ref disp,
                                                           ref sit,
                                                           ref lstCred,
                                                           ref lstProd,
                                                           ref lstComprov))
                {
                    return(false);
                }

                i_Form.TxtNome.Text  = nome;
                i_Form.TxtSaldo.Text = new money().formatToMoney(disp);
                i_Form.TxtSit.Text   = sit;

                for (int t = 0; t < lstComprov.Count; ++t)
                {
                    DadosComprovGift dcg = new DadosComprovGift(lstComprov[t] as DataPortable);

                    string [] full_row = new string [] { dcg.get_dt_venda(),
                                                         "R$ " + new money().formatToMoney(dcg.get_vr_valor()),
                                                         dcg.get_st_tipo() };

                    i_Form.LstComprov.Items.Add(var_util.GetListViewItem(dcg.get_id_venda(), full_row));
                }

                if (i_Form.LstComprov.Items.Count > 0)
                {
                    i_Form.LstComprov.Items[0].Selected = true;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Print -

            case event_Print:
            {
                //InitEventCode event_Print

                ArrayList lst = new ArrayList();

                string id_gift = var_util.getSelectedListViewItemTag(i_Form.LstComprov);

                if (id_gift == "")
                {
                    return(false);
                }

                var_exchange.fetch_comprov_Gift(id_gift, Context.TRUE, 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_BtnConfirmarClick -

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

                #endregion

            default: break;
            }

            return(false);
        }
Exemplo n.º 3
0
        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

                i_Form.LblTotal.Text      = "Total: R$ " + new money().formatToMoney(total.ToString());
                i_Form.rbDinheiro.Checked = true;

                ctrl_TxtIdent.AcquireTextBox(i_Form.TxtIdent, this, event_val_TxtIdent, 20);

                i_Form.CboTipoCart.SelectedIndex = 0;

                if (recarga)
                {
                    i_Form.Text = "Efetuar pagamento para recarga de cartão Gift";
                }

                //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

                if (i_Form.rbCheque.Checked)
                {
                    if (i_Form.TxtIdent.Text.Length == 0)
                    {
                        MessageBox.Show("Informe a identificação do cheque", "Aviso");
                        return(false);
                    }
                }
                else if (i_Form.rbCartao.Checked)
                {
                    if (i_Form.TxtIdent.Text.Length == 0)
                    {
                        MessageBox.Show("Informe a identificação da venda pelo cartão", "Aviso");
                        return(false);
                    }

                    if (i_Form.CboTipoCart.SelectedIndex == -1)
                    {
                        MessageBox.Show("Escolha o tipo de cartão", "Aviso");
                        return(false);
                    }
                }

                dc.set_vr_dispTotal(carga.ToString());

                string tipoPag = TipoPagamento.Dinheiro;
                string info    = i_Form.TxtIdent.Text;;

                if (i_Form.rbCheque.Checked)
                {
                    tipoPag = TipoPagamento.Cheque;
                }
                else if (i_Form.rbCartao.Checked)
                {
                    tipoPag = TipoPagamento.Cartao;
                }
                else
                {
                    info = "";
                }

                ArrayList lst = new ArrayList();

                for (int t = 0; t < lstProdsNome.Count; ++t)
                {
                    DadosProdutoGift dpg = new DadosProdutoGift();

                    dpg.set_st_nome(lstProdsNome[t].ToString());
                    dpg.set_vr_valor(lstProdsValor[t].ToString());

                    lst.Add(dpg);
                }

                string tg_adesao = Context.TRUE;

                if (recarga)
                {
                    tg_adesao = Context.FALSE;
                }

                var_exchange.exec_recargaGift(dc.get_st_empresa(),
                                              dc.get_st_matricula(),
                                              carga.ToString(),
                                              tipoPag,
                                              i_Form.CboTipoCart.SelectedIndex.ToString(),
                                              info,
                                              tg_adesao,
                                              ref header,
                                              ref lst,
                                              ref id_gift);

                if (!recarga)
                {
                    if (!var_exchange.ins_cartaoProprietario("",
                                                             ref dc,
                                                             ref dp,
                                                             ref da,
                                                             ref header))
                    {
                        return(false);
                    }
                }

                IsTerm = true;

                bool Finish = false;

                while (!Finish)
                {
                    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();
                    }

                    if (MessageBox.Show("Impressão bem sucedida?",
                                        "Aviso",
                                        MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question,
                                        MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        Finish = true;
                    }
                }

                i_Form.Close();

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_FormIsClosing -

            case event_FormIsClosing:
            {
                //InitEventCode event_FormIsClosing

                if (MessageBox.Show("Confirma cancelamento de cadastro de cartão GiftCard?",
                                    "Aviso",
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question,
                                    MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    return(false);
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtIdent -

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

                #endregion

                #region - event_Print -

            case event_Print:
            {
                //InitEventCode event_Print

                ArrayList lst = new ArrayList();

                var_exchange.fetch_comprov_Gift(id_gift, Context.FALSE, 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_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_TxtDtIni.AcquireTextBox(i_Form.TxtDtIni, this, event_val_TxtDtIni, dateTextController.FORMAT_DDMMYYYY);
                ctrl_TxtDtFim.AcquireTextBox(i_Form.TxtDtFim, this, event_val_TxtDtFim, dateTextController.FORMAT_DDMMYYYY);

                ctrl_TxtDtIni.SetupErrorProvider(ErrorIconAlignment.MiddleRight, false);
                ctrl_TxtDtFim.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_Confirmar -

            case event_Confirmar:
            {
                //InitEventCode event_Confirmar

                bool bOk = true;

                if (!ctrl_TxtDtFim.IsUserValidated)
                {
                    ctrl_TxtDtFim.SetErrorMessage("Informe o dia final");
                    bOk = false;
                }

                if (!ctrl_TxtDtIni.IsUserValidated)
                {
                    ctrl_TxtDtIni.SetErrorMessage("Informe o dia inicial");
                    bOk = false;
                }

                if (i_Form.TxtFile.Text == "")
                {
                    MessageBox.Show("Informe o arquivo de saída", "Aviso");
                    bOk = false;
                }

                if (i_Form.CboOption.SelectedIndex == -1)
                {
                    MessageBox.Show("Informe a opção de cobrança", "Aviso");
                    bOk = false;
                }

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

                i_Form.BtnConfirmar.Enabled = false;

                string st_block = "";
                string nu_nsFat = "";

                dlgStatus stat = new dlgStatus("Faturamento");

                stat.LblActivity.Text = "Processando dados no servidor";

                stat.pgStatus.Maximum = 1;
                stat.pgStatus.Minimum = 0;

                stat.Show();
                Application.DoEvents();

                if (var_exchange.fetch_arquivoFat(var_util.GetDataBaseTimeFormat(ctrl_TxtDtIni.getTextBoxValue_Date()),
                                                  var_util.GetDataBaseTimeFormat(ctrl_TxtDtFim.getTextBoxValue_Date().AddDays(1)),
                                                  i_Form.CboOption.SelectedIndex.ToString(),
                                                  ref header,
                                                  ref st_block,
                                                  ref nu_nsFat))
                {
                    ArrayList full_memory = new ArrayList();

                    while (st_block != "")
                    {
                        ArrayList tmp_memory = new ArrayList();

                        if (var_exchange.fetch_memory(st_block, "600", ref st_block, ref tmp_memory))
                        {
                            for (int t = 0; t < tmp_memory.Count; ++t)
                            {
                                full_memory.Add(tmp_memory[t]);
                            }
                        }
                    }

                    string file = i_Form.TxtFile.Text.Replace("ZZ", nu_nsFat.PadLeft(2, '0'));

                    StreamWriter sw = new StreamWriter(file, false, Encoding.Default);

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

                        sw.WriteLine(port.getValue("line"));
                    }

                    sw.Close();

                    MessageBox.Show("Arquivo '" + file + "' gerado com sucesso", "Aviso");
                }

                stat.Close();
                Application.DoEvents();

                i_Form.BtnConfirmar.Enabled = true;

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Dir -

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

                #endregion

                #region - event_val_TxtDtFim -

            case event_val_TxtDtFim:
            {
                //InitEventCode event_val_TxtDtFim

                switch (arg as string)
                {
                case dateTextController.DATE_VALID:
                {
                    i_Form.TxtDtFim.BackColor     = Color.White;
                    ctrl_TxtDtFim.IsUserValidated = true;
                    ctrl_TxtDtFim.CleanError();
                    break;
                }

                case dateTextController.DATE_INVALID:
                {
                    i_Form.TxtDtFim.BackColor     = colorInvalid;
                    ctrl_TxtDtFim.IsUserValidated = false;
                    break;
                }

                default: break;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtDtIni -

            case event_val_TxtDtIni:
            {
                //InitEventCode event_val_TxtDtIni

                switch (arg as string)
                {
                case dateTextController.DATE_VALID:
                {
                    i_Form.TxtDtIni.BackColor     = Color.White;
                    ctrl_TxtDtIni.IsUserValidated = true;
                    ctrl_TxtDtIni.CleanError();
                    break;
                }

                case dateTextController.DATE_INVALID:
                {
                    i_Form.TxtDtIni.BackColor     = colorInvalid;
                    ctrl_TxtDtIni.IsUserValidated = false;
                    break;
                }

                default: break;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BtnDirClick -

            case event_BtnDirClick:
            {
                //InitEventCode event_BtnDirClick
                //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);
        }