Ejemplo n.º 1
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     using (SQLiteConnection connection = SqlConnectionFactory.GetSQLiteConnectionWithLock())
     {
         DateTime dt = MainActivity.GetLocalTime();
         if (!string.IsNullOrWhiteSpace(txtToNewEmail.Text))
         {
             connection.Insert(new EmailAddresses()
             {
                 Date      = dt,
                 IsValid   = true,
                 EmailType = 1,
                 Email     = txtToNewEmail.Text
             });
             EmailAddresses newto = connection.Table <EmailAddresses>().Where(x => x.EmailType == 1).Last();
             lblOutEmail.Text += $"OK TO=> {newto.ToString()}\n";
         }
         if (!string.IsNullOrWhiteSpace(txtFromNewEmail.Text))
         {
             connection.Insert(new EmailAddresses()
             {
                 Date      = dt,
                 IsValid   = true,
                 EmailType = 2,
                 Email     = txtFromNewEmail.Text
             });
             EmailAddresses newfrom = connection.Table <EmailAddresses>().Where(x => x.EmailType == 2).Last();
             lblOutEmail.Text += $"OK FROM=> {newfrom.ToString()}\n";
         }
         if (!string.IsNullOrWhiteSpace(txtBCCNewEmail.Text))
         {
             connection.Insert(new EmailAddresses()
             {
                 Date      = dt,
                 IsValid   = true,
                 EmailType = 3,
                 Email     = txtBCCNewEmail.Text
             });
             EmailAddresses newbcc = connection.Table <EmailAddresses>().Where(x => x.EmailType == 3).Last();
             lblOutEmail.Text += $"OK BCC=> {newbcc.ToString()}\n";
         }
         if (!string.IsNullOrWhiteSpace(pass1.Text))
         {
             connection.Insert(new FromPassword()
             {
                 Date    = dt,
                 IsValid = true,
                 Pass    = pass1.Text,
             });
             FromPassword ea = connection.Table <FromPassword>().Last();
             lblOut.Text = $"OK pw=> {ea.ToString()}";
         }
         if (!string.IsNullOrWhiteSpace(txtRate.Text))
         {
             connection.Insert(new HourlyRate()
             {
                 Date    = dt,
                 IsValid = true,
                 Rate    = (float)Convert.ToDouble(txtRate.Text),
             });
             HourlyRate ea = connection.Table <HourlyRate>().Last();
             lblOut.Text = $"OK Hourlyrate=> {ea.ToString()}";
         }
         if (!string.IsNullOrWhiteSpace(txtServer.Text))
         {
             connection.Insert(new ServerOut()
             {
                 Date    = dt,
                 IsValid = true,
                 Server  = txtServer.Text,
             });
             ServerOut ea = connection.Table <ServerOut>().Last();
             lblOut.Text = $"OK Server=> {ea.ToString()}";
         }
         else if (connection.Table <ServerOut>().Count() == 0)
         {
             connection.Insert(new ServerOut()
             {
                 Date    = dt,
                 IsValid = true,
                 Server  = "smtp.office365.com",
             });
             ServerOut ea = connection.Table <ServerOut>().Last();
             lblOut.Text = $"OK Server=> {ea.ToString()}";
         }
     }
 }