>using MyCompany.Business.MyBiz; > >namespace MyCompany.WinUI.MyUI >{ > public class MyForm : MyBaseForm > { > private long CustomerKey; > private MyDataSet dsData; > private MyBizCustomer oBiz; > > public MyForm(long key) > { > this.CustomerKey = key; > InitializeComponent(); > this.FillData(); > } > > public void FillData() > { > // To simplify, I'm directly calling a Biz class. > // In reality, I use a Web Service here instead > // which in turn calls the Biz class. > > oBiz = new MyBizCustomer(); > dsData = oBiz.GetCustomer(this.CustomerKey); > } > } >} >>Now in your MyBiz project, you'd have a Biz class:
>using MyCompany.DataAccess.MyDataAccess > >namespace MyCompany.Business.MyBiz >{ > public class MyBizCustomer > { > private MyDataSet dsData; > > public MyDataSet GetCustomer(long CustomerKey) > { > MyDataAccessCustomer oDA = new MyDataAccessCustomer(); > this.dsData = oDA.GetCustomer(CustomerKey); > > // if you have other Biz things to do to this customer > // do it here before returning the DataSet > > return this.dsData; > } > } >} >>And, lastly, in your MyDataAccess project, you'd have this class:
>namespace MyCompany.DataAccess.MyDataAccess >{ > public class MyDataAccessCustomer > { > public MyDataSet GetCustomer(long CustomerKey) > { > // Here's where you'd put all the SqlCommand and DataAdapter stuff > // and fill your DataSet. > > return dsData; > } > } >} >>
>MyTextBox.DataBinding.Add("Text", MyDataSet.Tables["MyTable"], "MyColumn"); >>Although, I've sub-classed all my base controls and included a DataBind method in each one. Here's a sample for my TextBox subclass:
>public virtual void DataBind(System.Data.DataTable Data, string Path) >{ > for (int i = 0; i < this.DataBindings.Count; i++) > { > if (this.DataBindings[i].Equals(this.oBinding)) > { > this.DataBindings.Remove(this.oBinding); > break; > } > } > > this.Text = ""; > this.m_BoundTable = Data; > this.m_BoundColumn = Path; > this.oBinding = new Binding(this.m_BoundProperty, Data, Path); > this.oBinding.Format += new ConvertEventHandler(this.FormatHandler); > this.oBinding.Parse += new ConvertEventHandler(this.ParseHandler); > this.DataBindings.Add(this.oBinding); >} >>