Пример #1
0
 public PermissionTypeState(PermissionType type, PermissionState state)
 {
     permissionType = type;
     permissionState = state;
 }
		public Result Delete(PermissionType permissionType)
		{
			Result result = new Result();
			if (OnBeforeDeletePermissionType != null)
				OnBeforeDeletePermissionType(permissionType, result);
			SqlConnection conn = null;
			if (result.Succeeded)
			{
				try
				{
					using (TransactionScope scope = new TransactionScope())
					{
						conn = (SqlConnection)DatabaseManager.DatabaseEngine.GetConnection();
						try
						{
							SqlCommand cmd = new SqlCommand("DeletePermissionType", conn);
							cmd.CommandType = CommandType.StoredProcedure;
							cmd.Parameters.Add(new SqlParameter("@PermissionTypeID", permissionType.PermissionTypeID));
							cmd.ExecuteNonQuery();
							scope.Complete();
						}
						catch (Exception ex)
						{
							return new Result(ex.Message);
						}
					}
				}
				finally
				{
					DatabaseManager.DatabaseEngine.ReleaseConnection(conn);
				}
				if (OnPermissionTypeDeleted != null)
					OnPermissionTypeDeleted(permissionType);
			}
			return result;
		}
Пример #3
0
 public PermissionTypeState(PermissionType type, PermissionState state)
 {
     permissionType  = type;
     permissionState = state;
 }
		public Result Store(PermissionType permissionType)
		{
			SqlConnection conn = null;
			try
			{
				using (TransactionScope scope = new TransactionScope())
				{
					conn = (SqlConnection)DatabaseManager.DatabaseEngine.GetConnection();
					try
					{
						SqlCommand cmd = new SqlCommand("StorePermissionType", conn);
						cmd.CommandType = CommandType.StoredProcedure;
						SqlParameter prm = new SqlParameter("@PermissionTypeID", permissionType.PermissionTypeID);
						prm.Direction = ParameterDirection.InputOutput;
						cmd.Parameters.Add(prm);
						cmd.Parameters.Add(new SqlParameter("@PermissionTypeCode", permissionType.PermissionTypeCode));
						cmd.Parameters.Add(new SqlParameter("@Description", permissionType.Description));
						cmd.Parameters.Add(new SqlParameter("@DefaultValue", permissionType.DefaultValue));
						for (int i = 0; i < cmd.Parameters.Count; i++)
							if (cmd.Parameters[i].Value == null)
								cmd.Parameters[i].Value = DBNull.Value;
						cmd.ExecuteNonQuery();
						permissionType.PermissionTypeID = (long)prm.Value;
						scope.Complete();
					}
					catch (Exception ex)
					{
						return new Result(ex.Message);
					}
				}
			}
			finally
			{
				DatabaseManager.DatabaseEngine.ReleaseConnection(conn);
			}
			return new Result();
		}