private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtUsername.Text)) { MessageBox.Show("The Username cannot be blank"); } else { AWBProfile profile = new AWBProfile { Username = txtUsername.Text }; if (chkSavePassword.Checked && !string.IsNullOrEmpty(txtPassword.Text)) { profile.Password = txtPassword.Text; } profile.DefaultSettings = txtPath.Text; int idUpload = AWBProfiles.GetIDOfUploadAccount(); if (chkUseForUpload.Checked && (idUpload != -1) && (idUpload != Editid)) { AWBProfiles.SetOtherAccountsAsNotForUpload(); } profile.UseForUpload = chkUseForUpload.Checked; profile.Notes = txtNotes.Text; profile.ID = Editid; AWBProfiles.AddEditProfile(profile); DialogResult = DialogResult.Yes; } }
private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtUsername.Text)) { MessageBox.Show("The Username cannot be blank"); } else { // warn user if profile for entered user ID already exists if (Editid == -1 && AWBProfiles.GetProfile(txtUsername.Text) != null) { if (MessageBox.Show("Username \"" + txtUsername.Text + "\" is already used in another profile. Are you sure you want to use this username again?", "Username already used in another profile", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } } AWBProfile profile = new AWBProfile { Username = txtUsername.Text }; if (chkSavePassword.Checked && !string.IsNullOrEmpty(txtPassword.Text)) { profile.Password = txtPassword.Text; } else { profile.Password = ""; } profile.DefaultSettings = txtPath.Text; int idUpload = AWBProfiles.GetIDOfUploadAccount(); if (chkUseForUpload.Checked && (idUpload != -1) && (idUpload != Editid)) { AWBProfiles.SetOtherAccountsAsNotForUpload(); } profile.UseForUpload = chkUseForUpload.Checked; profile.Notes = txtNotes.Text; profile.ID = Editid; AWBProfiles.AddEditProfile(profile); DialogResult = DialogResult.Yes; } }
private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtUsername.Text)) { MessageBox.Show("The Username cannot be blank"); } else { AWBProfile profile = new AWBProfile(); profile.Username = txtUsername.Text; profile.Password = txtPassword.Text; profile.defaultsettings = txtPath.Text; int idUpload = AWBProfiles.GetIDOfUploadAccount(); if (chkUseForUpload.Checked && idUpload != -1 && idUpload != editid) { AWBProfiles.SetOtherAccountsAsNotForUpload(); } profile.useforupload = chkUseForUpload.Checked; profile.notes = txtNotes.Text; if (editid == -1) { AWBProfiles.AddProfile(profile); } else { profile.id = editid; AWBProfiles.EditProfile(profile); } this.DialogResult = DialogResult.Yes; } }