private void btnSave_Click(object sender, EventArgs e)
        {
            if (validations())
            {
                getDataFromForm();

                if (accountBL.CheckUsername(accountInfo).Rows.Count == 0)
                {
                    if (accountBL.Insert(accountInfo) > 0)
                    {
                        frmAccounts.loadData(frmAccounts.txtSearch.Text);
                        MessageBox.Show("Success.");
                        clearControls();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Failed.");
                    }
                }
                else
                {
                    MessageBox.Show("Username is already taken.");
                }
            }
        }
Exemple #2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (validations())
     {
         getDataFromForm();
         if (accountBL.Edit(accountInfo))
         {
             frmAccounts.loadData(frmAccounts.txtSearch.Text);
             MessageBox.Show("Success.");
             clearControls();
             this.Close();
         }
         else
         {
             MessageBox.Show("Failed.");
         }
     }
     else
     {
         MessageBox.Show("Please complete the required fields.");
     }
 }