Exemplo n.º 1
0
        private void SaveUser()
        {
            string NetworkUserName = string.Empty;

            if (!IsValid())
            {
                return;
            }

            try
            {
                UserID          = 0;
                NetworkUserName = tNetworkName.Text;

                using (DataStuff sn = new DataStuff())
                {
                    if (sn.SaveNetworkSystemUser(UserID, NetworkUserName, tName.Text, tEmail.Text, "Y"))
                    {
                        if (sn.SaveUserRole(cbRole.Text, NetworkUserName))
                        {
                            MessageBox.Show("User successfully saved.", "User Maintenance", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }

                        tNetworkName.Focus();
                    }
                }
            }

            catch
            {
                MessageBox.Show("There was an error saving the user.", "User Maintenance", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 2
0
        private void tsbSaveUser_Click(object sender, EventArgs e)
        {
            string NetworkUserName = string.Empty;

            if (!IsValid())
            {
                return;
            }

            try
            {
                if (tNetworkName.Visible)
                {
                    UserID          = 0;
                    NetworkUserName = tNetworkName.Text;
                }
                else
                {
                    NetworkUserName = cbNetworkName.Text;
                }

                using (DataStuff sn = new DataStuff())
                {
                    if (sn.SaveNetworkSystemUser(UserID, NetworkUserName, tName.Text, tEmail.Text, cUserActive.Checked ? "Y" : "N"))
                    {
                        if (sn.SaveUserRole(cbRole.Text, NetworkUserName))
                        {
                            MessageBox.Show("User successfully saved.", "User Maintenance", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }

                        tNetworkName.Visible      = false;
                        cbNetworkName.Visible     = true;
                        tsbCancelUserEdit.Enabled = false;
                        tsbSaveUser.Enabled       = true;
                        tsbDeleteUser.Enabled     = true;

                        LoadUsers();

                        //cbNetworkName.SelectedIndex = 1;
                        cbNetworkName.Focus();
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("There was an error saving the user.", "User Maintenance", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }