private void UpdateInsertPermission(GridViewRowInfo row) { if (row != null) { try { int selectedIndex = -1; selectedIndex = row.Index; int add, edit, view, delete; int authid, userid, authuserid; add = (string.IsNullOrEmpty(row.Cells["add"].Value.ToString()) ? 0 : int.Parse(row.Cells["add"].Value.ToString())); edit = (string.IsNullOrEmpty(row.Cells["edit"].Value.ToString()) ? 0 : int.Parse(row.Cells["edit"].Value.ToString())); view = (string.IsNullOrEmpty(row.Cells["view"].Value.ToString()) ? 0 : int.Parse(row.Cells["view"].Value.ToString())); delete = (string.IsNullOrEmpty(row.Cells["delete"].Value.ToString()) ? 0 : int.Parse(row.Cells["delete"].Value.ToString())); authid = int.Parse(row.Cells["authid"].Value.ToString()); userid = int.Parse(rddStaff.SelectedValue.ToString()); authuserid = (string.IsNullOrEmpty(row.Cells["authuserid"].Value.ToString()) ? 0 : int.Parse(row.Cells["authuserid"].Value.ToString())); //Check if it is an update or an insert using (fingermachDataSetTableAdapters.authuserTableAdapter tbl = new fingermachDataSetTableAdapters.authuserTableAdapter()) { if (authuserid == 0) { tbl.pInsertPermission(authid, userid, add, edit, view, delete); } else { tbl.pUpdatePermission(authuserid, authid, userid, add, edit, view, delete); } } radGridView1.Rows[selectedIndex].IsSelected = true; radGridView1.CurrentRow = radGridView1.Rows[selectedIndex]; } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void radGridView1_CommandCellClick(object sender, EventArgs e) { string command; int selectedIndex = -1; int add, edit, view, delete; int authid, userid, authuserid; GridViewRowInfo row = radGridView1.CurrentRow; selectedIndex = row.Index; add = 0; edit = 0; view = 0; delete = 0; authid = int.Parse(row.Cells["authid"].Value.ToString()); userid = int.Parse(rddStaff.SelectedValue.ToString()); authuserid = (string.IsNullOrEmpty(row.Cells["authuserid"].Value.ToString()) ? 0 : int.Parse(row.Cells["authuserid"].Value.ToString())); GridCommandCellElement cell = (GridCommandCellElement)sender; command = cell.CommandButton.Text; //GridViewCommandColumn col = (GridViewCommandColumn)sender; switch (command.ToLower()) { case "allow": add = 1; edit = 1; view = 1; delete = 1; break; case "deny": add = 0; edit = 0; view = 0; delete = 0; break; case "dup": add = (string.IsNullOrEmpty(row.Cells["add"].Value.ToString()) ? 0 : int.Parse(row.Cells["add"].Value.ToString())); edit = (string.IsNullOrEmpty(row.Cells["edit"].Value.ToString()) ? 0 : int.Parse(row.Cells["edit"].Value.ToString())); view = (string.IsNullOrEmpty(row.Cells["view"].Value.ToString()) ? 0 : int.Parse(row.Cells["view"].Value.ToString())); delete = (string.IsNullOrEmpty(row.Cells["delete"].Value.ToString()) ? 0 : int.Parse(row.Cells["delete"].Value.ToString())); break; } try { //Check if it is an update or an insert using (fingermachDataSetTableAdapters.authuserTableAdapter tbl = new fingermachDataSetTableAdapters.authuserTableAdapter()) { if (authuserid == 0) { tbl.pInsertPermission(authid, userid, add, edit, view, delete); } else { tbl.pUpdatePermission(authuserid, authid, userid, add, edit, view, delete); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } RefreshMenuGrid(); radGridView1.Rows[selectedIndex].IsSelected = true; radGridView1.CurrentRow = radGridView1.Rows[selectedIndex]; }