private bool writeCelPhones()
        {
            bool result             = false;
            ContactoController func = new ContactoController();

            try
            {
                dt = func.mostrar();

                string jsonFile = "";
                foreach (DataRow row in dt.Rows)
                {
                    string cell = row[2].ToString();

                    string cellPhone = Regex.Match(cell, @"(.{9})\s*$").ToString();

                    jsonFile += cellPhone + Environment.NewLine;
                }

                TextWriter writer;
                using (writer = new StreamWriter(path + "basecamoana.txt", append: false))
                {
                    writer.WriteLine(jsonFile);
                }
                result = true;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error");
                result = false;
            }

            return(result);
        }
Example #2
0
        public void mostrar()
        {
            try {
                ContactoController func = new ContactoController();
                dt = func.mostrar();
                datalistado.Columns["Eliminar"].Visible = false;

                if (dt.Rows.Count != 0)
                {
                    datalistado.DataSource           = dt;
                    txtBuscar.Enabled                = true;
                    datalistado.ColumnHeadersVisible = true;
                    inexistente.Visible              = true;
                }
                else
                {
                    datalistado.DataSource           = null;
                    txtBuscar.Enabled                = false;
                    datalistado.ColumnHeadersVisible = false;
                    inexistente.Visible              = true;
                }
            } catch (Exception e) {
                MessageBox.Show(e.Message, "Error");
            }
            btnEditar.Enabled = false;
            buscar();
        }