private void RequestAuthoritiesData() { try { AuthoritiesVM vm = new AuthoritiesVM { MenuName = this.teMenuName.Text.Trim(), Name = this.teQueryAuthorityName.Text.Trim() }; this.gcAuthorities.DataSource = null; this.gcAuthorities.DataSource = _bll.GetAuthorities(vm); } catch (Exception ex) { } }
public int DeleteAuthorities(AuthoritiesVM vm) { StringBuilder sb = new StringBuilder(); try { SqlParameter paramID = new SqlParameter("@ID", vm.ID); string sql = @"DELETE FROM [dbo].[Authorities] WHERE ID=@ID "; return(SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, new SqlParameter[] { paramID })); } catch (Exception ex) { return(0); } }
private void ribeDeleteAuthority_Click(object sender, EventArgs e) { AuthoritiesVM vm = this.gvAuthorities.GetRow(this.gvAuthorities.FocusedRowHandle) as AuthoritiesVM;//获取选中行的实体 var res = _bll.DeleteAuthorities(vm); if (res > 0) { XtraMessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK); RequestAuthoritiesData(); } else { XtraMessageBox.Show("删除失败!", "提示", MessageBoxButtons.OK); } }
private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.teAuthorityName.Text)) { XtraMessageBox.Show("button text is empty!", "提示", MessageBoxButtons.OK); return; } var source = tlueMenu.Properties.DataSource as List <MenusVM>; if (this.tlueMenu.EditValue == null) { XtraMessageBox.Show("menu is empty!", "提示", MessageBoxButtons.OK); return; } var item = this.tlueMenu.EditValue as MenusVM;//当前选中的实体 if (item.ParentID == 0) { if (source.Any(p => p.ParentID == item.ID))//有孩子 { XtraMessageBox.Show("please select children menu!", "提示", MessageBoxButtons.OK); return; } } AuthoritiesVM vm = new AuthoritiesVM() { MenuID = item.ID, Name = this.teAuthorityName.Text.Trim() }; var res = _bll.AddAuthorities(vm); if (res > 0) { XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK); RequestAuthoritiesData(); } else { XtraMessageBox.Show("保存失败!", "提示", MessageBoxButtons.OK); } }
public int AddAuthorities(AuthoritiesVM vm) { StringBuilder sb = new StringBuilder(); try { string sql = @" INSERT INTO [dbo].[Authorities] ([MenuID],[Name]) VALUES (@MenuID,@Name ); "; SqlParameter paramMenuID = new SqlParameter("@MenuID", vm.MenuID); SqlParameter paramName = new SqlParameter("@Name", vm.Name); return(SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, new SqlParameter[] { paramMenuID, paramName })); } catch (Exception ex) { return(0); } }
public List <AuthoritiesVM> GetAuthorities(AuthoritiesVM vm) { StringBuilder sb = new StringBuilder(); try { StringBuilder sql = new StringBuilder(@" select a.ID,a.Name,m.TabHeaderText MenuName from [dbo].[Authorities] a join [dbo].[Menus] m on a.[MenuID]=m.ID "); List <SqlParameter> paramList = new List <SqlParameter>(); StringBuilder where = new StringBuilder(" where 1=1 and m.[Status]=1 "); if (!string.IsNullOrEmpty(vm.MenuName)) { where.Append(" and m.TabHeaderText like @MenuName"); SqlParameter paramMenuName = new SqlParameter("@MenuName", string.Format("%{0}%", vm.MenuName)); paramList.Add(paramMenuName); } if (!string.IsNullOrEmpty(vm.Name)) { where.Append(" and a.Name like @Name"); SqlParameter paramName = new SqlParameter("@Name", string.Format("%{0}%", vm.Name)); paramList.Add(paramName); } if (vm.MenuID != 0) { where.Append(" and a.MenuID = @MenuID"); SqlParameter paramMenuID = new SqlParameter("@MenuID", vm.MenuID); paramList.Add(paramMenuID); } sql.Append(where); return(DataTableToList.DataSetToList <AuthoritiesVM>(SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql.ToString(), paramList.ToArray()))); } catch (Exception ex) { return(null); } }
public int DeleteAuthorities(AuthoritiesVM vm) { return(_dal.DeleteAuthorities(vm)); }
public List <AuthoritiesVM> GetAuthorities(AuthoritiesVM vm) { return(_dal.GetAuthorities(vm)); }
public int AddAuthorities(AuthoritiesVM vm) { return(_dal.AddAuthorities(vm)); }