hi there
Below is my code for a webmethod which checks if data is existent in a table and then amends if bool is true or adds new if bool is false
For some reason my amend works fine but it seems to jump the else condition altogether. Only passes the if when gets to else comes back to the if again
I tested it by swapping the condition around and it does the same thing....skips the else
would really appreciate if someone can look at the code and tell me where I am going wrong...
WebMethod(Description= "Add or Amend Availability & Rates")]
public bool Availability(string username, string password, DateTime dattm,int ResortID, string RoomType, int Qty, double curprice)
{
bool boolReturnValue = false;
GetAuthCredentials(username, password);
ResortID = UserAccounts.strTypeID;
// RoomType = ResortRooms.strRoomType;
//int intPriceType = 0;
Available.curPrice = curprice;
Available.dtm = dattm;
//Available.intPriceType = intPriceType;
Available.intQty = Qty;
Available.intResortID = UserAccounts.strTypeID;
Available.strRoomType = RoomType;
string connStr = ConfigurationManager.ConnectionStrings["bedbankstandssConnectionString"].ConnectionString;
SqlConnection mySQLconnection = new SqlConnection(connStr);
String strSQL = "select * from available where ResortID="+UserAccounts.strTypeID;
SqlCommand dbCommand = new SqlCommand(strSQL,mySQLconnection);
SqlDataReader dr;
mySQLconnection.Open();
dr = dbCommand.ExecuteReader();
while (dr.Read())
{
if (dattm== Convert.ToDateTime(dr["dtm"].ToString()) & ResortID == Convert.ToInt16(dr["intResortID"].ToString()) & (RoomType == dr["strRoomType"].ToString()))
{
boolReturnValue = true;
}
if (boolReturnValue == true)
{
AmendAvailability(username, password, dattm, RoomType, Qty, curprice);
}
else
{
AddAvailability(username, password, ResortID, dattm, RoomType, Qty, curprice);
}
}
dr.Close();
return boolReturnValue;
}
thanks