У меня небольшой вопрос, который меня смущает, у меня есть переменная типа double, названная RevisionRatio, в которой я использую это выражение.
RevisionRatio = ((WriterRevisions / TotalRevisions) * 100) теперь давайте посмотрим, что WriterRevisions = 5 и TotalRevisions = 11, поэтому он делает ((5/11) * 100) = 45,45%, но по какой-то причине он дает мне 0 все время, я знаю, что делаю небольшую ошибку, и я не могу найти ее в Google, ваша помощь очень ценится, это мой код.
protected void MyMonthlyRevisionRatio(bool DateSpecified)
{
int TotalRevisions = 0;
int WriterRevisions = 0;
double RevisionRatio = 0;
using (LogiConnection = new SqlConnection(CIPConnection))
{
LogiConnection.Open();
DateTime DT = DateTime.Now;
using (LogiCommand = new SqlCommand(Functions.NewString("SELECT COUNT(DISTINCT LCR.revision_id) AS revisions FROM LogiCpsRevisions AS LCR INNER JOIN LogiCpsLogs AS LCL ON LCL.project_id = LCR.project_id WHERE (DATENAME(mm, GETDATE()) = DATENAME(mm, LCL.creation_date))"), LogiConnection))
{
LogiCommand.Parameters.AddWithValue("@writer_id", HFSqlParameters.Value);
TotalRevisions = Convert.ToInt16(Functions.GetResults(LogiCommand)[0]);
}
if (DateSpecified)
{
using (LogiCommand = new SqlCommand(Functions.NewString("SELECT COUNT(DISTINCT LCR.revision_id) AS revisions FROM LogiCpsRevisions AS LCR INNER JOIN LogiCpsLogs AS LCL ON LCL.project_id = LCR.project_id WHERE (LCL.writer_id = @writer_id) AND (DATENAME(mm, GETDATE()) = DATENAME(mm, LCL.creation_date)) AND (creation_date BETWEEN @FromDate AND @ToDate)"), LogiConnection))
{
LogiCommand.Parameters.AddWithValue("@writer_id", HFSqlParameters.Value);
LogiCommand.Parameters.AddWithValue("@FromDate", FromDtPicker.SelectedDate);
LogiCommand.Parameters.AddWithValue("@ToDate", ToDtPicker.SelectedDate);
WriterRevisions = Convert.ToInt16(Functions.GetResults(LogiCommand)[0]);
RevisionRatio = ((WriterRevisions / TotalRevisions) * 100);
lblMyRevisionRatio.Text = "7. Revision ratio : " + RevisionRatio + "in the given period.";
}
}
else
{
using (LogiCommand = new SqlCommand(Functions.NewString("SELECT COUNT(DISTINCT LCR.revision_id) AS revisions FROM LogiCpsRevisions AS LCR INNER JOIN LogiCpsLogs AS LCL ON LCL.project_id = LCR.project_id WHERE (LCL.writer_id = @writer_id) AND (DATENAME(mm, GETDATE()) = DATENAME(mm, LCL.creation_date))"), LogiConnection))
{
LogiCommand.Parameters.AddWithValue("@writer_id", HFSqlParameters.Value);
WriterRevisions = Convert.ToInt16(Functions.GetResults(LogiCommand)[0]);
RevisionRatio = ((WriterRevisions / TotalRevisions) * 100);
//Response.Write(TotalRevisions);
//Response.Write(WriterRevisions);
//Response.Write(RevisionRatio.ToString());
lblMyRevisionRatio.Text = "7. Revision ratio : " + RevisionRatio + " in the month of " + DT.ToString("MMMM") + ".";
}
}
}
}
Спасибо.