i wrote this function to set the member status but its not checking the 3rd and 4th condtion please check and tell me where i go wrong???
private void BindCheck(string code)
{
// SqlConnection con = new SqlConnection("");
SqlConnection con = new SqlConnection("");
con.Open();
string query = "SELECT * FROM Registration_Master WHERE regCode= '" + code + "'";
com = new SqlCommand(query, con);
com.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter(com);
DataTable dt = new DataTable();
da.Fill(dt);
try
{
if (dt.Rows.Count > 0)
{
BindCheck(dt.Rows[0]["sponcorid"].ToString());
int count_mem = Convert.ToInt32(dt.Rows[0]["count_mem"]);
count_mem++;
com = new SqlCommand();
com.Connection = con;
com.CommandText = "UPDATE Registration_Master SET count_mem = '" + count_mem + "' ,modifieddate='" + DateTime.Now + "' WHERE regCode = '" + code + "'";
com.CommandType = CommandType.Text;
com.ExecuteNonQuery();
if (Convert.ToInt32(dt.Rows[0]["count_mem"]) > 20)
{
query = "UPDATE Registration_Master SET member_status= 'MANAGER' ,modifieddate='" + DateTime.Now + "' WHERE regCode= '" + code + "'";
com = new SqlCommand(query, con);
com.CommandType = CommandType.Text;
com.ExecuteNonQuery();
}
else if (Convert.ToInt32(dt.Rows[0]["count_mem"]) > 40)
{
query = "UPDATE Registration_Master SET member_status= 'CHIEF MANAGER' ,modifieddate='" + DateTime.Now + "' WHERE regCode= '" + code + "'";
com = new SqlCommand(query, con);
com.CommandType = CommandType.Text;
com.ExecuteNonQuery();
}
else if (Convert.ToInt32(dt.Rows[0]["count_mem"]) > 60)
{
query = "UPDATE Registration_Master SET member_status= 'DIRECTOR' ,modifieddate='" + DateTime.Now + "' WHERE regCode= '" + code + "'";
com = new SqlCommand(query, con);
com.CommandType = CommandType.Text;
com.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
}
}