Subversion Repositories Code-Repo

Rev

Rev 53 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 53 Rev 63
Line 8... Line 8...
8
using System.Windows.Forms;
8
using System.Windows.Forms;
9
using System.DirectoryServices.AccountManagement;
9
using System.DirectoryServices.AccountManagement;
10
 
10
 
11
namespace SWAT_Office_App
11
namespace SWAT_Office_App
12
{
12
{
13
    public partial class ManageUserAccounts_Form : Form
13
    public partial class Manage_User_Accounts_Form : Form
14
    {
14
    {
15
        public ManageUserAccounts_Form()
15
        public Manage_User_Accounts_Form()
16
        {
16
        {
17
            InitializeComponent();
17
            InitializeComponent();
18
            // Designate columns to include in listview for the Manage User Accounts Form
18
            // Designate columns to include in listview for the Manage User Accounts Form
19
            ColumnHeader Column_1 = new ColumnHeader();
19
            ColumnHeader Column_1 = new ColumnHeader();
20
            Column_1.Text = "Username";
20
            Column_1.Text = "Username";
Line 49... Line 49...
49
        {
49
        {
50
            try
50
            try
51
            {
51
            {
52
                // Function for refreshing/painting the listbox
52
                // Function for refreshing/painting the listbox
53
                this.lst_UserAccounts.BeginUpdate();
53
                this.lst_UserAccounts.BeginUpdate();
54
                ManageUserAccounts.QueryUserAccounts();
54
                Manage_User_Accounts.QueryUserAccounts();
55
 
55
 
56
                // Temporary entries in listview
56
                // Temporary entries in listview
57
                //ListViewItem entry;
57
                //ListViewItem entry;
58
                //ListViewItem.ListViewSubItem s_entry;
58
                //ListViewItem.ListViewSubItem s_entry;
59
                //entry = new ListViewItem();
59
                //entry = new ListViewItem();
Line 69... Line 69...
69
                //entry.SubItems.Add(s_entry);
69
                //entry.SubItems.Add(s_entry);
70
                //this.lst_User_Accounts.Items.Add(entry);
70
                //this.lst_User_Accounts.Items.Add(entry);
71
 
71
 
72
                this.lst_UserAccounts.Items.Clear();
72
                this.lst_UserAccounts.Items.Clear();
73
                // Prevents system accounts from showing, depending on settings
73
                // Prevents system accounts from showing, depending on settings
74
                foreach (UserPrincipal user in ManageUserAccounts.UserAccountsList)
74
                foreach (UserPrincipal user in Manage_User_Accounts.UserAccountsList)
75
                {
75
                {
76
                    ListViewItem entry = new ListViewItem();
76
                    ListViewItem entry = new ListViewItem();
77
                    bool remove = false;
77
                    bool remove = false;
78
                    foreach (string hiddenUser in Settings_Form.hiddenAccounts)
78
                    foreach (string hiddenUser in Settings_Form.hiddenAccounts)
79
                    {
79
                    {
Line 85... Line 85...
85
                    }
85
                    }
86
                    // Populates the subitem columns for each entry
86
                    // Populates the subitem columns for each entry
87
                    if (remove == false)
87
                    if (remove == false)
88
                    {
88
                    {
89
                        ListViewItem.ListViewSubItem s_share = new ListViewItem.ListViewSubItem();
89
                        ListViewItem.ListViewSubItem s_share = new ListViewItem.ListViewSubItem();
90
                        if (ManageUserAccounts.QueryUserSharedFolderExist(user.Name))
90
                        if (Manage_User_Accounts.QueryUserSharedFolderExist(user.Name))
91
                            s_share.Text = "Yes";
91
                            s_share.Text = "Yes";
92
                        else
92
                        else
93
                            s_share.Text = "No";
93
                            s_share.Text = "No";
94
                        entry.SubItems.Add(s_share);
94
                        entry.SubItems.Add(s_share);
95
                        ListViewItem.ListViewSubItem s_size = new ListViewItem.ListViewSubItem();
95
                        ListViewItem.ListViewSubItem s_size = new ListViewItem.ListViewSubItem();
96
                        long size = ManageUserAccounts.GetShareSize(user.Name);
96
                        long size = Manage_User_Accounts.GetShareSize(user.Name);
97
                        if ((size / 1073741824) > 0)
97
                        if ((size / 1073741824) > 0)
98
                            s_size.Text = (size / 1073741824).ToString() + " GB";
98
                            s_size.Text = (size / 1073741824).ToString() + " GB";
99
                        else
99
                        else
100
                            s_size.Text = (size / 1048576).ToString() + " MB";
100
                            s_size.Text = (size / 1048576).ToString() + " MB";
101
                        entry.SubItems.Add(s_size);
101
                        entry.SubItems.Add(s_size);
Line 112... Line 112...
112
                this.lst_UserAccounts.EndUpdate();
112
                this.lst_UserAccounts.EndUpdate();
113
            }
113
            }
114
            catch (Exception e)
114
            catch (Exception e)
115
            {
115
            {
116
                //MessageBox.Show(e.ToString(), "Error");
116
                //MessageBox.Show(e.ToString(), "Error");
117
                DebugText.appendText(e.ToString());
117
                Debug.appendText(e.ToString());
118
                MessageBox.Show("An error has occured. Please notify a supervisor to debug.", "Error");
118
                MessageBox.Show("An error has occured. Please notify a supervisor to debug.", "Error");
119
            }
119
            }
120
        }
120
        }
121
        private void lst_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
121
        private void lst_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
122
        {
122
        {
Line 171... Line 171...
171
            }
171
            }
172
        }
172
        }
173
        private void form_Activated(object sender, EventArgs e)
173
        private void form_Activated(object sender, EventArgs e)
174
        {
174
        {
175
            // Refreshes form on form activation
175
            // Refreshes form on form activation
176
            ManageUserAccounts.QueryUserAccounts();
176
            Manage_User_Accounts.QueryUserAccounts();
177
            PaintUserListbox();
177
            PaintUserListbox();
178
        }
178
        }
179
        private void btn_Exit_Click(object sender, EventArgs e)
179
        private void btn_Exit_Click(object sender, EventArgs e)
180
        {
180
        {
181
            this.Close();
181
            this.Close();
Line 184... Line 184...
184
        {
184
        {
185
            PaintUserListbox();
185
            PaintUserListbox();
186
        }
186
        }
187
        private void btn_Add_Click(object sender, EventArgs e)
187
        private void btn_Add_Click(object sender, EventArgs e)
188
        {
188
        {
189
            AddUserAccount_Form.Add_User_Account_Instance.ShowDialog();
189
            Add_User_Account_Form.Add_User_Account_Instance.ShowDialog();
190
            lst_ValidateAll();
190
            lst_ValidateAll();
191
        }
191
        }
192
        private void btn_Delete_Click(object sender, EventArgs e)
192
        private void btn_Delete_Click(object sender, EventArgs e)
193
        {
193
        {
194
            if (!ManageUserAccounts.SessionsOpen())
194
            if (!Manage_User_Accounts.SessionsOpen())
195
            {
195
            {
196
                ListView.SelectedListViewItemCollection selectedItems = this.lst_UserAccounts.SelectedItems;
196
                ListView.SelectedListViewItemCollection selectedItems = this.lst_UserAccounts.SelectedItems;
197
                List<string> userList = new List<string>();
197
                List<string> userList = new List<string>();
198
                foreach (ListViewItem user in selectedItems)
198
                foreach (ListViewItem user in selectedItems)
199
                    userList.Add(user.Text);
199
                    userList.Add(user.Text);
200
                DeleteUserVerify_Form newForm = new DeleteUserVerify_Form(userList);
200
                Delete_User_Verify_Form newForm = new Delete_User_Verify_Form(userList);
201
                newForm.ShowDialog();
201
                newForm.ShowDialog();
202
            }
202
            }
203
            else
203
            else
204
                MessageBox.Show("Sessions are still open. Please close them before deleting accounts", "Error");
204
                MessageBox.Show("Sessions are still open. Please close them before deleting accounts", "Error");
205
            PaintUserListbox();
205
            PaintUserListbox();
206
            lst_ValidateAll();
206
            lst_ValidateAll();
207
        }
207
        }
208
        private void btn_Pass_Click(object sender, EventArgs e)
208
        private void btn_Pass_Click(object sender, EventArgs e)
209
        {
209
        {
210
            ListView.SelectedListViewItemCollection selectedItems = this.lst_UserAccounts.SelectedItems;
210
            ListView.SelectedListViewItemCollection selectedItems = this.lst_UserAccounts.SelectedItems;
211
            ResetUserPassword_Form newForm = new ResetUserPassword_Form(selectedItems[0].Text);
211
            Reset_User_Password_Form newForm = new Reset_User_Password_Form(selectedItems[0].Text);
212
            newForm.ShowDialog();
212
            newForm.ShowDialog();
213
 
213
 
214
            PaintUserListbox();
214
            PaintUserListbox();
215
            lst_ValidateAll();
215
            lst_ValidateAll();
216
        }
216
        }
217
        private void btn_Share_Click(object sender, EventArgs e)
217
        private void btn_Share_Click(object sender, EventArgs e)
218
        {
218
        {
219
            ListView.SelectedListViewItemCollection selectedItems = this.lst_UserAccounts.SelectedItems;
219
            ListView.SelectedListViewItemCollection selectedItems = this.lst_UserAccounts.SelectedItems;
220
            ToggleUserVerify_Form newForm = new ToggleUserVerify_Form(selectedItems[0].Text);
220
            Toggle_User_Verify_Form newForm = new Toggle_User_Verify_Form(selectedItems[0].Text);
221
            newForm.ShowDialog();
221
            newForm.ShowDialog();
222
 
222
 
223
            PaintUserListbox();
223
            PaintUserListbox();
224
            lst_ValidateAll();
224
            lst_ValidateAll();
225
        }
225
        }