J
John6272
Guest
hi there, i have 4 projects in my solution. 1st is "UI", 2nd is "BAL", 3rd is "DLL" and 4th is "Library". i write a code for custom id and my code working perfectly, only if the code written in only "UI" project form. But i don't want to write all code on UI form. so i write the code on DAL Class, and trying to access using BAL Class, But i the custom id didn't show in textbox.
Please help me.. here is my code
Library Project, Class Name: CustomIDEntity
public string CustomID { get; set; }
DLL Project, Class Name: CustomIDDLL
public static string customid(CustomIDEntity cide)
{
using (SQLiteConnection conn = new SQLiteConnection("Data Source=customid2.db;Version=3;"))
{
string CommandText = "SELECT * FROM cusid2 order by Id";
using (SQLiteCommand cmd = new SQLiteCommand(CommandText, conn))
{
conn.Open();
DataTable dt = new DataTable();
SQLiteDataAdapter adapter = new SQLiteDataAdapter(cmd);
adapter.Fill(dt);
if (dt.Rows.Count < 1)
{
return cide.CustomID = "ABC-1000";
}
else
{
int count = dt.Rows.Count;
string oldId = dt.Rows[count - 1]["Id"].ToString();
string[] array = oldId.Split('-');
Int32 value = Convert.ToInt32(array[1]) + 1;
return cide.CustomID = "ABC" + "-" + value.ToString();
}
}
}
}
DAL Project, Class Name: CustomIDBAL
public static string cusid(CustomIDEntity cide)
{
return CustomIDDLL.customid(cide);
}
UI Project, Form Name: MainForm
private void MainForm_Load(object sender, EventArgs e)
{
CustomID();
}
public string CustomID()
{
CustomIDEntity cide = new CustomIDEntity();
cide.CustomID = cusid.Text;
return CustomIDBAL.cusid(cide);
}
Help me where i'm wrong.
Continue reading...
Please help me.. here is my code
Library Project, Class Name: CustomIDEntity
public string CustomID { get; set; }
DLL Project, Class Name: CustomIDDLL
public static string customid(CustomIDEntity cide)
{
using (SQLiteConnection conn = new SQLiteConnection("Data Source=customid2.db;Version=3;"))
{
string CommandText = "SELECT * FROM cusid2 order by Id";
using (SQLiteCommand cmd = new SQLiteCommand(CommandText, conn))
{
conn.Open();
DataTable dt = new DataTable();
SQLiteDataAdapter adapter = new SQLiteDataAdapter(cmd);
adapter.Fill(dt);
if (dt.Rows.Count < 1)
{
return cide.CustomID = "ABC-1000";
}
else
{
int count = dt.Rows.Count;
string oldId = dt.Rows[count - 1]["Id"].ToString();
string[] array = oldId.Split('-');
Int32 value = Convert.ToInt32(array[1]) + 1;
return cide.CustomID = "ABC" + "-" + value.ToString();
}
}
}
}
DAL Project, Class Name: CustomIDBAL
public static string cusid(CustomIDEntity cide)
{
return CustomIDDLL.customid(cide);
}
UI Project, Form Name: MainForm
private void MainForm_Load(object sender, EventArgs e)
{
CustomID();
}
public string CustomID()
{
CustomIDEntity cide = new CustomIDEntity();
cide.CustomID = cusid.Text;
return CustomIDBAL.cusid(cide);
}
Help me where i'm wrong.
Continue reading...