public string generateInvoiceNo(string PRODUCTNAME)
{
try
{
if (con.State != ConnectionState.Open)
{
con.Open();
string number;
OleDbDataAdapter DA1 = new OleDbDataAdapter("SELECT MAX(SUBSTR(INVOICE_NO,9,5)+1) AS MAXINVOICE FROM PRODUCT_DETAILS", con);
DataTable DT1 = new DataTable();
DA1.Fill(DT1);
if (DT1.Rows.Count > 0)
{
number = DT1.Rows[0]["MAXINVOICE"].ToString();
}
else
{
number = "00001";
}
OleDbCommand cmd2 = new OleDbCommand("SELECT SUBSTR(D_NO,0,2) AS D_NO FROM PRODUCT_MASTER WHERE PRODUCT_NAME='" + PRODUCTNAME + "'", con);
OleDbDataAdapter DA2 = new OleDbDataAdapter(cmd2);
DataTable DT2 = new DataTable();
DA2.Fill(DT2);
string dno = DT2.Rows[0]["D_NO"].ToString() + System.DateTime.Today.ToString() + number;
return dno;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return null;
}
finally
{
con.Close();
}
}
Rimmi90 0 Newbie Poster
Momerath 1,327 Nearly a Senior Poster Featured Poster
Rimmi90 0 Newbie Poster
Momerath 1,327 Nearly a Senior Poster Featured Poster
ckchaudhary 5 Newbie Poster
Rimmi90 0 Newbie Poster
Mitja Bonca 557 Nearly a Posting Maven
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.