コード例 #1
0
ファイル: frmImportarBO.cs プロジェクト: nicolaslen/auditur
        private void BO_ReadFile(string fileName)
        {
            int              iLinea = 0;
            string           Linea;
            List <BO_Ticket> lstDetalles = new List <BO_Ticket>();
            BO_Ticket        oBO_Detalle = null;

            try
            {
                if (!File.Exists(fileName))
                {
                    return;
                }

                Companias       companias    = new Companias();
                List <Compania> lstCompanias = companias.GetAll();
                companias.CloseConnection();
                List <Compania> lstNuevasCompanias = new List <Compania>();

                semanaToImport.TicketsBO = new List <BO_Ticket>();

                StreamReader fileReader = new StreamReader(fileName);
                fileReader.ReadLine();
                while ((Linea = fileReader.ReadLine()) != null)
                {
                    iLinea++;
                    oBO_Detalle = BOActions.GetDetalles(ref Linea, iLinea, lstCompanias);
                    if (oBO_Detalle != null)
                    {
                        if (!lstCompanias.Any(x => x.Codigo == oBO_Detalle.Compania.Codigo) && !lstNuevasCompanias.Any(x => x.Codigo == oBO_Detalle.Compania.Codigo))
                        {
                            lstNuevasCompanias.Add(oBO_Detalle.Compania);
                        }
                        lstDetalles.Add(oBO_Detalle);
                    }
                }

                fileReader.Close();

                semanaToImport.TicketsBO = lstDetalles;
                semanaToImport.BOCargado = true;

                if (lstNuevasCompanias.Count > 0)
                {
                    string mensaje = "Se han encontrado Compañías Aéreas que no estaban registradas en el sistema:\n\n";
                    lstNuevasCompanias.ForEach(x => mensaje += "Código: " + x.Codigo + "\n");
                    mensaje += "\nPor favor, ingrese al \"ABM de Compañías\" y agregue estas compañías.\n";
                    mensaje += "Muchas gracias.";
                    MessageBox.Show(mensaje, "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception Exception1)
            {
                MessageBox.Show("Error: " + Exception1.Message + "\nfileName: " + fileName + "\nline: " + iLinea, "Error");
            }
        }
コード例 #2
0
ファイル: frmImportarBO.cs プロジェクト: nicolaslen/auditur
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            bool             blnResult = false;
            BackgroundWorker bw        = sender as BackgroundWorker;

            BO_ReadFile(txtFilePath_BO.Text);
            if ((bool)e.Argument)
            {
                BOActions.Guardar(semanaToImport, backgroundWorker1);
            }

            blnResult = true;

            e.Result = blnResult;
        }