private void btnSaveAccount_Click(object sender, EventArgs e)
        {
            string err = "";

            if (txtGroupName.Text == "")
            {
                err += "Provide a valid Group Name.\r\n";
            }

            if (err != "")
            {
                MessageBox.Show(err, "Error Found.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            else
            {
                db = new SQLiteDatabase();
                Dictionary <String, String> data = new Dictionary <String, String>();
                data.Add("groupName", txtGroupName.Text);

                try
                {
                    if (isWhat == 0)
                    {
                        db.Insert("tblGroup", data);
                        MessageBox.Show("New Mail Group Account created!", "Success.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        isWhat = 1;
                    }
                    else
                    {
                        updateEmails(txtGroupName.Text);
                        db.Update("tblGroup", data, String.Format("tblGroup.groupName = '{0}'", this.txtList.SelectedItem.ToString()));
                        MessageBox.Show("Group updated succesfully!", "Success.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        isWhat = 1;
                    }


                    loadAccounts();
                    txtGroupName.Focus();
                    btnDeleteGroup.Enabled = true;
                    btnBrowseFile.Enabled  = true;
                    btnDelete.Enabled      = true;
                    btnImport.Enabled      = true;
                    btnNewAccount.Enabled  = true;
                    txtList.Enabled        = true;
                    btnAddNewMail.Enabled  = true;
                    txtList.SelectedItem   = txtGroupName.Text;

                    speedyMailMain form1 = (speedyMailMain)System.Windows.Forms.Application.OpenForms["MDIParent1"];
                    form1.loadEmailGroup();
                }
                catch (Exception crap)
                {
                    MessageBox.Show(crap.Message);
                }
            }
        }
Exemple #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string err = "";

            if (txtAccountName.Text == "")
            {
                err += "Provide a valid Account Name.\r\n";
            }
            if (txtEmail.Text == "")
            {
                err += "Provide a valid Email Account.\r\n";
            }
            if (txtFullName.Text == "")
            {
                err += "Provide a valid Name.\r\n";
            }
            if (txtPassword.Text == "")
            {
                err += "Provide a valid Account Password.\r\n";
            }
            if (txtSMTPServer.Text == "")
            {
                err += "Provide a valid SMTP Server.\r\n";
            }

            if (err != "")
            {
                MessageBox.Show(err, "Error Found.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            else
            {
                db = new SQLiteDatabase();
                Dictionary <String, String> data = new Dictionary <String, String>();
                data.Add("title", txtAccountName.Text);
                data.Add("smtp", txtSMTPServer.Text);
                data.Add("username", txtEmail.Text);
                data.Add("password", txtPassword.Text);
                data.Add("fullname", txtFullName.Text);
                try
                {
                    if (isWhat == 0)
                    {
                        db.Insert("tblEmailAccount", data);
                        MessageBox.Show("New Email SMTP Account created!", "Success.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        db.Update("tblEmailAccount", data, String.Format("tblEmailAccount.title = '{0}'", this.txtTitle.Text));
                        MessageBox.Show("Account updated succesfully!", "Success.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }

                    toggleButtons(false);
                    loadAccounts();
                    btnEdit.Enabled   = false;
                    btnDelete.Enabled = false;
                    listBox1.Enabled  = true;

                    speedyMailMain form1 = (speedyMailMain)Application.OpenForms["MDIParent1"];
                    form1.loadAccounts();
                }
                catch (Exception crap)
                {
                    MessageBox.Show(crap.Message);
                }
            }
        }