public void check_function_and_group(string name, string descr) { acl_functionTableAdapters.acl_functionTableAdapter af = new acl_functionTableAdapters.acl_functionTableAdapter(); af.Connection = (SqlConnection)connection_; acl_groupTableAdapters.acl_groupTableAdapter ag = new acl_groupTableAdapters.acl_groupTableAdapter(); ag.Connection = (SqlConnection)connection_; Object func_idx_ = af.HasFunction(name);; Object group_idx_ = ag.HasGroup(name); if (null == func_idx_ || func_idx_.GetType() == typeof(DBNull)) { func_idx_ = af.InsertFunction(name, descr).Value; } if (null == group_idx_ || group_idx_.GetType() == typeof(DBNull)) { group_idx_ = ag.InsertGroup(System.Guid.NewGuid(), 500, name, descr).Value; } { SqlCommand cmd = build_command_(String.Format("select idx from acl_function_grants where group_idx='{0}' and func_idx={1};", group_idx_, func_idx_)); Object idx_ = cmd.ExecuteScalar(); if (null == idx_ || idx_.GetType() == typeof(DBNull)) { grant_((int)group_idx_, (int)func_idx_); } } }
public static int create(IDbConnection conn, string name) { acl_groupTableAdapters.acl_groupTableAdapter ad = new acl_groupTableAdapters.acl_groupTableAdapter(); ad.Connection = (SqlConnection)conn; return(ad.InsertGroup(System.Guid.NewGuid(), 500, name, "system_created").Value); }