I am simply calling a method and putting the return result in an int variable. However VS says its a string
Code: Select all
public int ADPTime = 0;
public int ADPId;
private ADPFunctions ADP = new ADPFunctions();
public void GetADPId()
{
ADPId = ADP.GetADPId(this.Id);
}
public void GetADPTime(string Start, string End)
{
ADPTime = ADP.GetADPTime(Start, End, this.ADPId); <---------This is where I get first error
}
Then you can see here it is an int. Yet I get an error saying cannot convert Int to string then another error, cannot convert string to int
Code: Select all
public string GetADPTime(string Start, string End,string ADPId)
{
int ADPTime = 0;
List<string> Times = new List<string>();
SqlConnection thisConnection = *removed
thisConnection.Open();
SqlCommand thisCommand = thisConnection.CreateCommand();
thisCommand.CommandText = "SELECT PUNCHDTM FROM PERSON AS PS JOIN PUNCHEVENT AS PE on PS.PERSONID = PE.EMPLOYEEID inner join DATASOURCE as DS on PE.DATASOURCEID = DS.DATASOURCEID WHERE PUNCHDTM > '" + Start + "' AND PUNCHDTM < '" + End + "' AND PE.DELETEDSW = 0 AND PS.PERSONNUM = '" + ADPId + "' order by PUNCHDTM ASC";
SqlDataReader thisReader;
thisReader = thisCommand.ExecuteReader();
while (thisReader.Read())
{
Times.Add(thisReader["PUNCHDTM"].ToString());
}
string ClockIn = "";
foreach (string TempTime in Times)
{
if (ClockIn == "")
{
ClockIn = TempTime;
}
else
{
double ClockTime = ((Convert.ToDateTime(TempTime) - Convert.ToDateTime(ClockIn)).TotalSeconds);
ADPTime += Convert.ToInt32(ClockTime);
ClockIn = "";
}
}
thisReader.Close();
thisConnection.Close();
return ADPTime; <---------This is where I get other error
}