예제 #1
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            if (!ValidateForm(false))
            {
                return;
            }
            if (string.IsNullOrEmpty(senderUserTxtBox.Text))
            {
                errorProvider1.SetError(senderUserTxtBox, "field required!");
                tabControl1.SelectedTab = tabControl1.TabPages["distPage"];
                senderUserTxtBox.Focus();
                return;
            }
            var envId         = ((ComboboxItem)comboBoxEnv.SelectedItem).Value;
            var user          = textBoxUser.Text;
            var pass          = textBoxPassword.Text.Protect();
            var envName       = ((ComboboxItem)comboBoxEnv.SelectedItem).Text;
            var serverAddress = textBoxServerAddress.Text;
            var db            = (string)comboBoxDb.SelectedItem;

            UpdateConnString();
            using (var dbContext = new AlisDbContext())
            {
                dbContext.SavedCredentialses.ToList().ForEach(c => c.ChoseLast = false);
                dbContext.SaveChanges();
                var toUpdate = dbContext.SavedCredentialses.Find(envId);
                if (toUpdate != null)
                {
                    toUpdate.Username   = user;
                    toUpdate.Password   = pass;
                    toUpdate.Host       = serverAddress;
                    toUpdate.Db         = db;
                    toUpdate.Name       = envName;
                    toUpdate.ConnString = _connString.ToString();
                    toUpdate.ChoseLast  = true;
                    toUpdate.Saved      = checkBoxSave.Checked;
                    if (checkBoxSave.Checked)
                    {
                        dbContext.SaveChanges();
                    }
                }
                Global.PropSetter(toUpdate);
                dbContext.SaveChanges();
            }
            Settings.Default.SenderMail    = senderUserTxtBox.Text;
            Settings.Default.SharingFolder = sharingFolderTxtBox.Text;
            Settings.Default.Save();
            Close();
        }
예제 #2
0
 private void removeMemberButton_Click(object sender, EventArgs e)
 {
     using (var db = new AlisDbContext())
     {
         var foundItemFromDb = db.Distributions.FirstOrDefault(i => i.Id == ((Distribution)inDistList.SelectedItem).Id);
         if (foundItemFromDb != null)
         {
             db.Distributions.Remove(foundItemFromDb);
             db.SaveChanges();
             PopulateDistList();
             ClearBoxes();
         }
     }
 }
예제 #3
0
        private void refreshButton_Click(object sender, EventArgs e)
        {
            var confirmResult = MessageBox.Show(@"To Delete Saved Credentials??",
                                                @"Confirm Delete!",
                                                MessageBoxButtons.YesNo);

            if (confirmResult == DialogResult.Yes)
            {
                using (var dbContext = new AlisDbContext())
                {
                    dbContext.SavedCredentialses.ToList().ForEach(cred => cred.Saved = false);
                    dbContext.SaveChanges();
                }
                InitComponents();
            }
        }
예제 #4
0
 private void addMemberButton_Click(object sender, EventArgs e)
 {
     if (!ValidateAddMember())
     {
         return;
     }
     if (string.IsNullOrEmpty(idTextBox.Text) || idTextBox.Value < 0)
     {
         Distribution dist = new Distribution
         {
             FirstName    = firstNameTextBox.Text,
             LastName     = lastNameTextBox.Text,
             EmailAddress = emailTextBox.Text,
             DistFlag     = true
         };
         dist.DisplayMember = dist.ToString();
         using (var db = new AlisDbContext())
         {
             db.Distributions.Add(dist);
             try
             {
                 db.SaveChanges();
             }
             catch (DbUpdateException)
             {
                 MessageBox.Show(@"Email Address Already Exists, Please Add A Different One", @"Duplicate Email Error");
             }
         }
     }
     else
     {
         using (var db = new AlisDbContext())
         {
             var foundItemFromDb = db.Distributions.FirstOrDefault(i => i.Id.ToString().Equals(idTextBox.Text));
             if (foundItemFromDb != null)
             {
                 foundItemFromDb.FirstName     = firstNameTextBox.Text;
                 foundItemFromDb.LastName      = lastNameTextBox.Text;
                 foundItemFromDb.EmailAddress  = emailTextBox.Text;
                 foundItemFromDb.DisplayMember = foundItemFromDb.ToString();
             }
             db.SaveChanges();
         }
     }
     PopulateDistList();
     ClearBoxes();
 }