Mám WPF aplikace, která Im snaží dostat se do ASP.net rámec, jsem nový ASP.net a potřebují nějakou pomoc zobrazování některých veličin a výpočtů v pohledu. To je třída, kterou jsem použil již dříve ve WPF aplikace, která získává hodnoty, počítá je a pak se zobrazí na řetězec metodou v seznamu.
{
public class Module
//Getters and setters for variables
{
public string Code { get; set; }
public string Name { get; set; }
public int Credits { get; set; }
public int ClassHours { get; set; }
public int HoursSpent { get; set; }
public int Weeks { get; set; }
public string WorkingDate { get; set; }
public string Username { get; set; }
public double StudyHours;
public double RemainingStudyHours;
//default constructor
public Module()
{
}
//constructor for class variables
public Module(string code, string name, int credits, int classHours, int hoursSpent, int weeks, string workingdate, string username)
{
Code = code;
Name = name;
Credits = credits;
ClassHours = classHours;
HoursSpent = hoursSpent;
Weeks = weeks;
WorkingDate = workingdate;
Username = username;
// assigning method with necessary parameters to variables
StudyHours = CalculateStudyHours(credits, classHours, weeks);
RemainingStudyHours = CalculateRemainingStudyHours(credits, classHours, weeks, hoursSpent);
}
//Method calculating study hours
public double CalculateStudyHours(int credits, int classHours, int weeks)
{
return (credits * 10 / weeks) - classHours;
}
//method calculating remaining study hours
public double CalculateRemainingStudyHours(int credits, int classHours, int weeks, int hoursSpent)
{
int value = (credits * 10 / weeks) - classHours;
return value - hoursSpent;
}
//ToString method displaying the object and details
public override string ToString()
{
return Code + "\n" + Name + "\n" + "Credits: " + Credits + "\n" + "Class hours per week: " + ClassHours + "\n" + "Requires " + StudyHours + " hours of self study per week." + "\n" +
"Based on your hours spent working on this module you have: " + RemainingStudyHours + " remaining hours left ";
}
}
}
Chci být schopen zobrazit výpočty, jako je tento formát např.: ale místo toho, výpočet proměnné v tabulce a jejich vlastní čísla jména zadejte popis obrázku zde
Nějaké tipy na to, jak k němu přistupovat správně, bude velmi ocenil