Пример #1
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
                //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_Processar -

            case event_Processar:
            {
                //InitEventCode event_Processar

                if (i_Form.TxtFile.Text == "")
                {
                    return(false);
                }

                i_Form.BtnProcessar.Enabled = false;

                ArrayList lstLines   = new ArrayList();
                string    id_archive = "";
                string    line       = "";
                string    line_final = "";
                long      sizeInfo   = 100;
                long      max        = Convert.ToInt64(new InstallData().maxPacket) / sizeInfo;
                long      index      = 0;

                StreamReader file = new StreamReader(i_Form.TxtFile.Text);

                line = file.ReadLine();

                bool debitoConta = false;

                if (line [0] == '1')
                {
                    debitoConta = true;
                }

                while (!file.EndOfStream)
                {
                    line = file.ReadLine();

                    if (debitoConta)                               // deb em conta
                    {
                        if (line [0] == 'Z')
                        {
                            break;
                        }

                        line_final = line.Substring(1, 25) +
                                     line.Substring(67, 2) +
                                     " ".PadLeft(42, '0') +
                                     line.Substring(54, 13);
                    }
                    else                             // doc
                    {
                        if (line [0] == '9')
                        {
                            break;
                        }

                        line_final = line.Substring(37, 25) +
                                     line.Substring(108, 2) +
                                     line.Substring(110, 42) +
                                     line.Substring(253, 13);
                    }

                    // substring

                    DataPortable port = new DataPortable();

                    port.setValue("line", line_final);

                    lstLines.Add(port);

                    if (++index == max)
                    {
                        var_exchange.upload_archive(id_archive,
                                                    ref header,
                                                    ref lstLines,
                                                    ref id_archive);
                        index = 0;
                        lstLines.Clear();
                    }
                }

                if (index > 0)
                {
                    var_exchange.upload_archive(id_archive,
                                                ref header,
                                                ref lstLines,
                                                ref id_archive);
                }

                file.Close();

                var_exchange.exec_processaArqBancario(id_archive, ref header);

                MessageBox.Show("Arquivo processado");

                i_Form.BtnProcessar.Enabled = true;

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BtnProcurarClick -

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

                #endregion

                #region - event_BtnProcessarClick -

            case event_BtnProcessarClick:
            {
                //InitEventCode event_BtnProcessarClick
                //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

                                        #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_TxtCodEmpresa.AcquireTextBox(i_Form.TxtCodEmpresa, this, event_val_TxtCodEmpresa, 6);

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

            case event_Processar:
            {
                //InitEventCode event_Processar

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

                if (i_Form.TxtFile.Text == "")
                {
                    return(false);
                }

                i_Form.BtnProc.Enabled = false;

                ArrayList lstLines = new ArrayList();

                string id_archive = "";

                long sizeInfo = 100;
                long max      = Convert.ToInt64(new InstallData().maxPacket) / sizeInfo;
                long index    = 0;

                StreamReader file = new StreamReader(i_Form.TxtFile.Text);

                while (!file.EndOfStream)
                {
                    DataPortable port = new DataPortable();

                    port.setValue("line", file.ReadLine());

                    lstLines.Add(port);

                    if (++index == max)
                    {
                        var_exchange.upload_archive(id_archive,
                                                    ref header,
                                                    ref lstLines,
                                                    ref id_archive);
                        index = 0;
                        lstLines.Clear();
                    }
                }

                if (index > 0)
                {
                    var_exchange.upload_archive(id_archive,
                                                ref header,
                                                ref lstLines,
                                                ref id_archive);
                }

                file.Close();

                if (var_exchange.exec_processaArqConvenio(id_archive, ctrl_TxtCodEmpresa.getTextBoxValue(), ref header))
                {
                    MessageBox.Show("Arquivo processado");
                }

                i_Form.BtnProc.Enabled = true;

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtCodEmpresa -

            case event_val_TxtCodEmpresa:
            {
                //InitEventCode event_val_TxtCodEmpresa

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

                    break;
                }

                default: break;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BtnBuscarClick -

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

                #endregion

                #region - event_BtnProcClick -

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

                #endregion

            default: break;
            }

            return(false);
        }