How to pass a value from a method to property procedure in c#?
- by sameer
Here is my code:
The jewellery class is my main class in which i am inheriting a connection string class.
class Jewellery : Connectionstr
{
string lmcode;
public string LM_code/**/Here i want to access the value of the method ReadData i.e displaystring and i want to store this value in the insert query below.**
{
get { return lmcode; }
set { lmcode = value; }
}
string mname;
public string M_Name
{
get { return mname; }
set { mname = value; }
}
string desc;
public string Desc
{
get { return desc; }
set { desc = value; }
}
public string ReadData()
{
OleDbDataReader dr;
string jid = string.Empty;
string displayString = string.Empty;
String query = "select max(LM_code)from Master_Accounts";
Datamanager.RunExecuteReader(Constr, query);
if (dr.Read())
{
jid = dr[0].ToString();
if (string.IsNullOrEmpty(jid))
{
jid = "AM0000";
}
int len = jid.Length;
string split = jid.Substring(2, len - 2);
int num = Convert.ToInt32(split);
num++;
displayString = jid.Substring(0, 2) + num.ToString("0000");
dr.Close();
}
**return displayString;** I want to pass this value to the above property procedure above i.e LM_code.
}
public void add()
{
String query ="insert into Master_Accounts values ('" + LM_code + "','" + M_Name + "'," + "'" + Desc + "')";
Datamanager.RunExecuteNonQuery(Constr , query);//
}
If possible can u edit this code!
Anticipated thanks by sameer