Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can properties from one class be object for another clas
Message
From
26/04/2019 05:27:05
 
 
To
All
General information
Forum:
C#
Category:
Coding, syntax and commands
Title:
How can properties from one class be object for another clas
Miscellaneous
Thread ID:
01668295
Message ID:
01668295
Views:
102
Hello everybody !

These are my old classes yet from 2015, and they're work fine.
But, I've some questions about it.

I've base form and some properties (this is base win form class):
public partial class BaseFormM2M<T> : Form where T : DataSet 

    {
        public int pos;
        public string rc;
        public int nformstatus = 0;

        string FilterWasSet = "";  
        string SortWasSet = "";  

        public string cPkValue = "";         
        protected  string cPkName = "";     
        public string cUpdateDeletemsg = "Uspešno sam ažurirao slog ";    

        protected bool IsEmptyStartData = true;          
        protected bool IsResetBinding = false;           


        bool ledit = true;

        bool lcopy = true;
        bool lcut = true;
        bool lpaste = true;

        bool ltop = true;
        bool lprev = true;
        bool lnext = true;
        bool lbottom = true;

        bool lfind = false;
        bool lrecordcopy = false;

        bool lprint = true;

        bool lRequery = true;
        bool lsave = true;
        bool lundo = true;
        bool ldelete = true;
        bool lnew = true;
        bool lexit = true;

        bool lcanedit = true;
        bool lcaninsert = true;
        bool lcandelete = true;
        bool lcancopy = true;
        bool lcanprint = true;

        public BindingSource bsOrders = new BindingSource();

        public IBusObj<T> obiz { get; set; }
	...
}
and Interface (this is base Interface)
public interface IBusObj<T> where T : DataSet 
    {
        string cErrobjCODP { get; set; }
        T oDS { get; set; }                    

        T dsChanged { get; set; }             
        T dsDeleted { get; set; }              

        DataTable MyBaseDt { get; set; }            

        void GetData(T ds);
        T GetData();                          
        bool SaveData(T ds);
        bool SaveData(DataTable dt);
        void AddToErrorMessage(string msg);

        T BlankDs();

        void OnRevert();                             
        void OnNew();                                
        void OnDelete();                             

        bool IsEmptyDt();

        bool IsChangedForSaveDs();  

        void RefreshData(T ds, string Parameter);  
        int MaxRowForFilterBs { get; set; }        
        string SqlQueryClmn   { get; set; }        

    }
and in Business layer I've got class (this is base BusinessClass)
public class BusinessObject<T> : IBusObj<T> where T : DataSet, new()  

    {
        protected string sTableName = "";
        protected string sFields = "*";

        public string cErrobjCODP { get; set; }
        public T oDS { get; set; }                              

        public T dsChanged { get; set; }                        
        public T dsDeleted { get; set; }                        

        public DataTable MyBaseDt { get; set; }              // dt base table

      
       ....
    }
And next class:
public class BoOrders : BusinessObject<CODPDataSet>      
    {
        private CODPDL objCODP = new CODPDL();

        public string cCustomerId   { get; set; }  
        public string cOrderId      { get; set; }                                       
        public DateTime dtOd       = new DateTime(1997, 09, 19);
        public DateTime dtDo       = DateTime.Today ;

        public decimal lnTotalOD {get;set;}

        private DataRowView dataRowView;     
        public DataRowView DataRowView       
        {
            get { return dataRowView; }
            set { dataRowView = value; }
        }


        public BoOrders ()
        {
        }
	....
     }
and form:
public partial class MojaM2M : ThreeTierArhitecture_win.BaseFormM2M<CODPDataSet>  

    {

        BindingSource bsCustomers = new BindingSource();
        BindingSource bsOrederDetails = new BindingSource();
        BindingSource bsProducts = new BindingSource();

        TextBox txtTotaldgODFooter = new TextBox();                            // 01.12.2016..
        Label   lblTotaldgODFooter = new Label();                              // 01.12.2016..


        public MojaM2M()
        {
            InitializeComponent();
            
            cPkName = "Orderid";


            obiz = new BoOrders();

	    ...	
        }

	protected override void HookBeforeOnRequery() 
        {

            cPkValue = MojUtlt.GetPkValue(bsOrders, cPkName);

            base.HookBeforeOnRequery();

            ((BoOrders)this.obiz).dtOd = dateTimePickerOd.Value.Date;
            ((BoOrders)this.obiz).dtDo = dateTimePickerDo.Value.Date;
            ((BoOrders)this.obiz).cCustomerId = this.txtFindCustomerid.Text.ToString();
            ((BoOrders)this.obiz).cOrderId = txtFindOrderid.Text.ToString();

        }
        ...
    }
Ok,this is works fine:
((BoOrders)this.obiz).dtOd = dateTimePickerOd.Value.Date;
((BoOrders)this.obiz).dtDo = dateTimePickerDo.Value.Date;
((BoOrders)this.obiz).cCustomerId = this.txtFindCustomerid.Text.ToString();
((BoOrders)this.obiz).cOrderId = txtFindOrderid.Text.ToString();
My question is:

why not work this way
obiz.dtOd = dateTimePickerOd.Value.Date;
obiz.dtDo = dateTimePickerDo.Value.Date;
obiz.cCustomerId = this.txtFindCustomerid.Text.ToString();
obiz.cOrderId = txtFindOrderid.Text.ToString();
In this case, I can't see these BoOrders properties in the form:
obiz.dtOd
obiz.dtDo
obiz.cCustomerId
obiz.cOrderId
If these properties there are in the interface IBusObj, then I can see these properties.
But I will not this way, because IbusObj is my base Interface (for all Business classes) and it not used only for BoOrders, MojaM2M ....

Is this only right way ?

Thanks

Vojislav
Next
Reply
Map
View

Click here to load this message in the networking platform