Hi
I have created one business application in c#.net and I am using in server containing
multiple users. While creating the invoices by all the users once at a time it has been
taken more time and sometimes application getting not responding condition.
Note: When one user created on invoice no then automatically that will be incremented
saving the other user with incremented invoice no.
would you please suggest me how to overcome this problem.
My Code for creating Invoice
{
string strTran = "";
strTran = cfs.getTRNumber("INV", cpnyid);
ddl_Inv.Text = strTran;
if (txt_Cus_Name.Text == "")
{
MessageBox.Show("Please select Customer.", Properties.Settings.Default.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
txt_Cus_Name.Focus();
return;
}
else if (dataGridViewEx1.Rows.Count < 1)
{
MessageBox.Show("Please add Products to save your order.", Properties.Settings.Default.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
else
{
if (ddl_Inv.Text.Length < 9)
{
sqlstr = "select INV_NO from " + tablename + " where INV_NO='" + ddl_Inv.Text + "' and Deleted=0 ";
if (cfs.checktrno(sqlstr) == false)
{
strTran = cfs.getTRNumber("INV", cpnyid);
ddl_Inv.Text = strTran;
if (Basic.Default.ismulno == false)
{
cmd.CommandText = "update rstockno set RS_INV_NO='" + Properties.Settings.Default.trno.ToString() + "' where ID='" + cpnyid + "'";
cmd.ExecuteNonQuery();
cn.Close();
}
if (CheckForPrice(dataGridViewEx1).Count > 0)
{
string price = "";
foreach (string str in CheckForPrice(dataGridViewEx1))
{
price += str + ",";
}
DialogResult result = MessageBox.Show("Price can not be '0.00'.Do you want to proceed? This will effect the costing", "Warning",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (result == DialogResult.No)
{
return;
}
else
{
save();
txt_Quo_ExtRema.Enabled = true;
lsPrice();
lsPrice2();
}
}
}
else
{
save();
lsPrice();
lsPrice2();
}
}
}
catch { if(!dr.IsClosed==true)dr.Close(); }
Properties.Settings.Default.RowCount = 0;
}
In save method I have written insert query of invoice