I have created a class as the following it has one global variable.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LankaLab
{
class dbConnect
{
public String strSuperPatID;
public String StrSuperPatID
{
get { return strSuperPatID; }
set { strSuperPatID = value; }
}
}
}
Now I have created another class and I have created an instance of the dbConnect class.
public partial class frmFulBldCuntDet : Form
{
private dbConnect dbConn = new dbConnect();
}
Now I want to set values to the global variable in the dbConnect class from the frmBldCuntDet class. I already created the getter() & setter() methods. But now I want to add values to the strSuperPatID from the frmBldCuntDet and display it from another class ( haven't created yet). All I need is to use getter() & setter(0 methods.
Thank You!
Moved to question from OP "solution" - OriginalGriff
frmBldCuntDet class has the following variables and those use to generate a automatic patient id.
Class - 01
public partial class frmFulBldCuntDet : Form
{
private dbConnect dbConn = new dbConnect();
private String strID;
private String strPatID;
private int intYear;
private String strYear;
private int intMonth;
private String strMonth;
private void btnPrint_Click(object sender, EventArgs e)
{
intYear = DateTime.Now.Year;
strYear = intYear.ToString();
intMonth = DateTime.Now.Month;
strID = cmbPatID.Text;
MyMethod();
frmHBAIC HbIAC01 = new frmHBAIC();
HbIAC01.show();
}
private string MyMethod() {
return(dbConn.StrSuperPatID = strPatID);
}
}
Class - 02
public partial class frmHBAIC : Form
{
private dbConnect dbConn = new dbConnect();
private void button1_Click(object sender, EventArgs e)
{
MessageBox.show(dbConn.StrSuperPatID);
}
}
Class - 03 - This class includes the global variables and getter & setter metohds of its'.
class dbConnect
{
public String strSuperPatID;
public String StrSuperPatID
{
get { return strSuperPatID; }
set { strSuperPatID = value; }
}
}
I cannot find the problem yet that preventing passing the values to the global variable.
Hope that you will help me
Thank You!