Sathya Narayan

Sathya Narayan

  • NA
  • 155
  • 63.7k

Autoincrement

Oct 6 2015 3:43 AM
HI ,
Here i am facing the issue with the condition statement,so i need to change the value that is in dropdownlist
which is selecteditem.value changed event.Here i need the "JEEVES CONSUMER SERVICES" remains as Existing value and "SERVICE FRANCHISES" and
"VENDOR" should get autogenerated to new value.The values for "SERVICE FRANCHISES" and
"VENDOR" Which has been binding in the series JCS-E526-SUN and for "JEEVES CONSUMER SERVICES" in the series J-10254 can anyone help?? Here is my code
string strmemcode = string.Empty;
if (ddlType.SelectedItem.Value == "JEEVES CONSUMER SERVICES")
if(txtEmpNo.Text =="J-%")
{
strmemcode = "J";
}
else if (ddlType.SelectedItem.Value == "SERVICE FRANCHISES")
if (txtEmpNo.Text == "JCS-%")
{
strmemcode = "F";
txtEmpNo.Text = GenerateEmpNo(strmemcode);
}
else if (ddlType.SelectedItem.Value == "VENDOR")
if (txtEmpNo.Text == "JCS-%")
{
strmemcode = "V";
}
txtEmpNo.Text = GenerateEmpNo(strmemcode);
protected string GenerateEmpNo(string Type)
{
string qry = "select ISNULL(max(SUBSTRING(EmpNo,3,6)),0) from tblEngineer where EmpNo like '" + Type + "-%'";
ServiceBLL objServiceBLL = new ServiceBLL();
DataSet ds = objServiceBLL.SelectByQuery(qry);
if (ds.Tables[0].Rows.Count > 0 && Int32.Parse(ds.Tables[0].Rows[0][0].ToString().Replace('-', ' ')) > 0)
{
int EmpID = Int32.Parse(ds.Tables[0].Rows[0][0].ToString().Replace('-', ' '));
txtEmpNo.Text = Type + "-" + (EmpID + 1);
}
else
{
if (Type == "V")
txtEmpNo.Text = Type + "-" + (30000 + 1);
else if (Type == "F")
txtEmpNo.Text = Type + "-" + (20000 + 1);
else if (Type == "J")
txtEmpNo.Text = Type + "-" + (10000 + 1);
}
string rename = txtEmpNo.Text;
return rename;
}

Answers (1)