0
現在Visual C#でWebフォームを作成していますが、このアプリは財務計算機になります。C#Webフォーム - カレンダーから選択した日付の後の月の最初の月曜日の日付を取得する場合
以下のコードの大部分は無関係で、ページ全体を表示するためにのみ含まれています。タイトルに詳述されているように、私はWebフォームのカレンダーから日付を選択できるようになっています。それをラベルに表示します。私は現在、日付を選択し、それを表示することができます。
namespace FinanceCalc
{
public partial class About : Page
{
decimal NumPmt = 0;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Price_TextChanged(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(Price.Text))
{
Response.Write("Please enter the Vehicle Price");
}
}
protected void DepositCalc_Click(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(Price.Text))
{
Response.Write("Please enter the Vehicle Price");
}
else
{
decimal price = Convert.ToDecimal(Price.Text);
decimal depositamount = (price/100 * 15);
Deposit.Text = depositamount.ToString();
}
}
protected void FinanceCalc_Click(object sender, EventArgs e)
{
// This works out if all required boxes have been populated and displays a warning message if they have not been.
if (String.IsNullOrEmpty(Price.Text))
{
Response.Write("Please enter the Vehicle Price.");
}
if (String.IsNullOrEmpty(Deposit.Text))
{
Response.Write("Please calculate the deposit.");
}
if (String.IsNullOrEmpty(Length.Text))
{
Response.Write("Please enter the finance length.");
}
if (Convert.ToInt32(Length.Text) < 1)
{
Response.Write("Please choose between 1, 2 and 3 years.");
}
if (Convert.ToInt32(Length.Text) > 3)
{
Response.Write("Please choose between 1, 2 and 3 years.");
}
else
{
// This works out payment amounts
NumPmt = 12 * int.Parse(Length.Text);
decimal price = Convert.ToDecimal(Price.Text);
decimal deposit = Convert.ToDecimal(Deposit.Text);
decimal MonthlyPayments = (price - deposit)/NumPmt;
// This populates the Finance Info text box with the information
Results.Text = "Deposit Amount - £" + Deposit.Text + Environment.NewLine + "Arrangement Fee - £88" + Environment.NewLine + "Completion Fee - £20" + Environment.NewLine + "Number of Payments: " + NumPmt
+ Environment.NewLine + "Delivery Date: " + DeliveryDate.SelectedDate + Environment.NewLine + "First Payment Date: " + Environment.NewLine + "First Payment Amount: £" + MonthlyPayments + " plus your £88 Arrangement Fee."
+ Environment.NewLine + "Monthly Payments: £" + MonthlyPayments + " for " + (12 * int.Parse(Length.Text) - 2) + " months." + Environment.NewLine + "Final Payment Amount: £" + MonthlyPayments + " plus your £20 Completion Fee";
}
}
protected void Reset_Click(object sender, EventArgs e)
{
//This resets all of the information boxes, allowing the user to start again
Price.Text = "";
Deposit.Text = "";
Results.Text = "";
}
protected void Length_TextChanged(object sender, EventArgs e)
{
// This works out how many monthly payments will be made.
NumPmt = 12 * int.Parse(Length.Text);
}
}
}
はどうなりますか?あなたはその1か翌月を表示していますか? – Xiaoy312
この投稿を見て、月の最初の日を取得します。そこから、曜日が月曜日か日曜日かなどを確認できます。https://stackoverflow.com/questions/25233520/how-あなたが考えるかもしれないように、これは実際には難しいことではありません。たくさんの日付と月機能を使用することができます。 C#、https://stackoverflow.com/questions/25233520/how-to-get-the-first-and-last-day-of-a-month-calendar-view-sunday-saturday – MethodMan