private void Btn_ok_Click(object sender, EventArgs e) { string str_new_usergroup = txt_name.Text.Trim(); string str_usergroup_description = txt_description.Text.Trim(); if (str_new_usergroup.Length == 0) { MessageBox.Show("Usergroup name is required.", "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!Permission_ds.Usergroup_available(str_new_usergroup, _usergroup)) { MessageBox.Show("Usergroup name already in use.", "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (_usergroup == "") { // Adding new usergroup if (!Program.System_user.Has_permission(Class_enum.User_permission.ADD_USERGROUP)) { MessageBox.Show("You do not have permission to add usergroup!", "ACCESS DENIED", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } Permission_ds.Insert_usergroup(str_new_usergroup, str_usergroup_description); } else { // editing existing usergroup if (!Program.System_user.Has_permission(Class_enum.User_permission.EDIT_USERGROUP)) { MessageBox.Show("You do not have permission to edit usergroup!", "ACCESS DENIED", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } string str_perm_combine = Class_listview.Get_checked_results_as_string(listview_permission, "permission"); Permission_ds.Update_usergroup(str_new_usergroup, str_usergroup_description, _usergroup); } string str_permission_combine = Class_listview.Get_checked_results_as_string(listview_permission, "permission"); if (str_permission_combine == "") { MessageBox.Show("Select one or more permission.", "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Permission_ds.Update_usergroup_permission(str_new_usergroup, str_permission_combine); _usergroup = str_new_usergroup; this.DialogResult = DialogResult.OK; this.Close(); }
public Form_listview_select(DataTable dttable, string value_colname = "", string[] cols_to_hide = null, string[] cols_money = null) { InitializeComponent(); // if value col name is not given, assume first column of datatable if (value_colname == "") { _value_colname = dttable.Columns[0].ColumnName; } else { _value_colname = value_colname; } Class_listview.Setup_listview(Listview_main, dttable, cols_to_hide, cols_money); }
private void Init_form() { Class_listview.Setup_listview(listview_permission, Permission_ds.Select_all_permission()); }