Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Business Rules and Default Values don't work!?
Message
From
23/05/2005 23:40:01
Dave Porter
Medical Systematics, Inc.
Merced, California, United States
 
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01016948
Message ID:
01016955
Views:
20
>Can you post your business object class and your business rule class? We set default values and check rules all the time, and things work just fine.
>
>I'd be interested to see how you're going about it.
>
>Mike

Thanks for responding Mike, plz see below
Dave
using System;
using System.Data;
using OakLeaf.MM.Main.Business;
using OakLeaf.MM.Main.Data;

namespace msi.pdx.dxServices
{
	/// <summary>
	/// Summary description for Dx.
	/// </summary>
	public class Dx : ABusinessObject
	{
		public Dx()
		{
			//
			// TODO: Add constructor logic here
			//
			this.UpdateSelectStatement = "Select * from DX";
			this.TableName = "DX";
			this.PrimaryKey = "ICDACode";
			this.RetrieveAutoIncrementPK = false;


		}
		public DataSet GetAllDx()
		{
			return this.GetDataSet("SELECT * From DX");
		}
		public DataSet GetAllDx(string xdx)
		{
			return this.GetDataSet("SELECT * From DX where ICDACODE like '" + xdx + "%'");
		}
		protected override void HookSetDefaultValues(DataRow dataRow)
		{
			if (this.DefaultValues != null)
			{
				DxDefaultValues Defaults = (DxDefaultValues)this.DefaultValues;
				dataRow["Valid"] = Defaults.Valid;
			}
		}
		protected override mmBusinessRule CreateBusinessRuleObject()
		{
			return new DxRules(this);
		}
		


	}
}
using System;

namespace msi.pdx.dxServices
{
	/// <summary>
	/// Summary description for DxDefaultValues.
	/// </summary>
	public struct DxDefaultValues
	{
		public string Valid;
		public DxDefaultValues(string Valid)
		{
			//
			// TODO: Add constructor logic here
			//
			this.Valid = "Y";
		}
	}
}
using System;
using System.Data;
using OakLeaf.MM.Main.Business;



namespace msi.pdx.dxServices
{
	/// <summary>
	/// Summary description for DxRules.
	/// </summary>
	public class DxRules : ABusinessRule
	{
		public DxRules(ImmBusinessRuleHost hostObject): base(hostObject)
		   {

			//
			// TODO: Add constructor logic here
			//
		   }
		public override bool CheckRulesHook(DataSet ds, string tableName)
		{
			if (ds != null)
			{
				DataRow dr = ds.Tables[tableName].Rows[0]; 
				this.CheckForDuplicateICDACode(dr["ICDACode"].ToString());
			}
			return this.ErrorProviderBrokenRuleCount == 0;
		}
		public string CheckForDuplicateICDACode(string icdacode)
		{
			//string message = null;
			string message = "Duplicate Key!";
			this.AddBrokenRule(message);
			return message;
		}
	}
}
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform