Beispiel #1
0
        private void btnAddDestinatario_Click(object sender, EventArgs e)
        {
            var dest = new Destinatario()
            {
                Id           = Guid.NewGuid().ToString("N"),
                IdRecipiente = CurrentRecipientId,
                Nome         = "",
                Address      = ""
            };
            var dlg = new EditDestinatario();

            if (dlg.Execute(this, ref dest))
            {
                _elencoDestintari.Add(dest);
                AppRepo.AddDestinatario(dest);
            }
        }
Beispiel #2
0
        private void btnImporta_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog();

            ofd.DefaultExt      = "*.txt";
            ofd.CheckFileExists = true;
            ofd.Multiselect     = false;
            var dr = ofd.ShowDialog(this);

            if (dr == DialogResult.OK)
            {
                var l     = new List <Destinatario>();
                var lines = File.ReadAllLines(ofd.FileName);
                foreach (var line in lines)
                {
                    if (string.IsNullOrWhiteSpace(line))
                    {
                        continue;
                    }
                    var fields = line.Split(';');
                    if (string.IsNullOrWhiteSpace(fields[0]))
                    {
                        continue;
                    }
                    var d = new Destinatario()
                    {
                        IdRecipiente = CurrentRecipientId,
                        Id           = Guid.NewGuid().ToString("N"),
                        Address      = fields[0].Trim(),
                    };
                    if (fields.Length > 1)
                    {
                        d.Nome = fields[1].Trim();
                    }
                    AppRepo.AddDestinatario(d);
                    l.Add(d);
                }
                List <Destinatario> list = _elencoDestintari.ToList();
                list.AddRange(l);
                _elencoDestintari        = new BindingList <Destinatario>(list);
                dataGridView1.DataSource = _elencoDestintari;
            }
        }