如何在第一个月和一个月后打印 [英] how do print first month and after days of month
问题描述
嗨所有
用于创建账单我希望在第一个月打印,然后根据以下语法打印日期:
我们有2个日期:1-开始日期2-结束日期
i想要在这些日期之间打印月份和日期。 ..
假设开始日期是2009年5月12日,结束日期是2013年3月11日
i想要在第一个和结束日期之间首次打印18个月(从开始日期2012/06/12开始一个月后):
2009/06/12 < br $> b $ b 2009/07/12
2009/08/12
2009/09/12
2009/10 / / 12
。
。
。
2010/08/12
2010 / 09/12
2010/10/12
以及打印日期后如
2010 / 10/13
2010/10/14
2010/10/15
。
。
。
直到结束日期(2013/03/11)
我该怎么做?
i使用此代码:
hi all
for create a bill i want print first month and then days base on below syntax :
we have a 2 date : 1- start date 2- end date
i want print month and daye between this dates ...
suppose start date is 2009/05/12 and end date is 2013/03/11
i want first print 18 month between first and end date like this (start one month after start date 2012/06/12):
2009/06/12
2009/07/12
2009/08/12
2009/09/12
2009/10/12
.
.
.
2010/08/12
2010/09/12
2010/10/12
and after it print base on days like
2010/10/13
2010/10/14
2010/10/15
.
.
.
until end date (2013/03/11)
how do i this ?
i use this code :
private void showbill_Load(object sender, EventArgs e)
{
lbl_user_fullname.Text = Class_Variables.bill_user_firstname + " " + Class_Variables.bill_user_lastname;
lbl_debt_price.Text = Class_Variables.bill_dept_price;
lbl_peyments_count.Text = Class_Variables.bill_debt_peyments_count;
string debt_year = Class_Variables.bill_dept_date.Substring(0, 4);
string debt_month = Class_Variables.bill_dept_date.Substring(5,2);
string debt_day = Class_Variables.bill_dept_date.Substring(8,2);
string current_date_year = Class_Variables.bill_current_date.Substring(0, 4);
string current_date_month = Class_Variables.bill_current_date.Substring(5, 2);
string current_date_day = Class_Variables.bill_current_date.Substring(8, 2);
dtp_farsi.CustomFormat = "y/MM/dd";
dtp_farsi.Format = BehComponents.DateTimePickerX.FormatDate.Custom;
dtp_farsi.SetSelectedDate(BehComponents.CalendarTypes.Persian, Convert.ToInt32(debt_year), Convert.ToInt32(debt_month), Convert.ToInt32(debt_day));
dtp_farsi2.CustomFormat = "y/MM/dd";
dtp_farsi2.Format = BehComponents.DateTimePickerX.FormatDate.Custom;
dtp_farsi2.SetSelectedDate(BehComponents.CalendarTypes.Persian, Convert.ToInt32(current_date_year), Convert.ToInt32(current_date_month), Convert.ToInt32(current_date_day));
int debt_price = Convert.ToInt32( Class_Variables.bill_dept_price);
int peyments_count = Convert.ToInt32(Class_Variables.bill_debt_peyments_count);
string todaydate = dtp_farsi.Text;
//colnames names
string[] colnames = new string[5];
colnames[0] = "no";
colnames[1] = "date";
colnames[2] = "delay days";
colnames[3] = "delay percent";
colnames[4] = "delay price";
//--------------------------------------------------
const int dim = 1000;
string[,] array = new string[dim, 5];
int peyment_count = 1;
TimeSpan ts = new TimeSpan();
TimeSpan ts2 = new TimeSpan();
int daydiff = 31;
int daydiff2 = 0;
int while_loop_counter=0;
while(daydiff > 30)
{
ts = dtp_farsi2.GetSelectedDateInPersianDateTime().Subtract(dtp_farsi.GetSelectedDateInPersianDateTime().AddMonths(while_loop_counter+1));
daydiff = ts.Days;
for (int j = 0; j < 5; j++)
{
if (j == 0)
{
array[while_loop_counter, j] = (while_loop_counter + 1).ToString();
}
else
{
//Column #1
array[while_loop_counter, 1] = dtp_farsi.GetSelectedDateInPersianDateTime().AddMonths(peyment_count).ToStringFormat("y/MM/dd");
//Column #2
ts2 = dtp_farsi2.GetSelectedDateInPersianDateTime().Subtract(dtp_farsi.GetSelectedDateInPersianDateTime().AddMonths(peyment_count));
daydiff2 = ts2.Days;
array[while_loop_counter, 2] = daydiff2.ToString();
//Column #3
switch (while_loop_counter + 1)
{
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9: array[while_loop_counter, 3] = 26.ToString();
break;
case 10:
case 11:
case 12: array[while_loop_counter, 3] = 24.ToString();
break;
case 13:
case 14:
case 15:
case 16: array[while_loop_counter, 3] = 22.ToString();
break;
case 17:
case 18: array[while_loop_counter, 3] = 20.ToString();
break;
default: array[while_loop_counter, 3] = 28.ToString();
break;
}
//Column #4
if (while_loop_counter <= 18)
{
array[while_loop_counter, 4] = (((debt_price / peyments_count) * Convert.ToInt64(array[while_loop_counter, 3]) * Convert.ToInt64(array[while_loop_counter, 2])) / 36500).ToString();
}
else
{
array[while_loop_counter, 4] = (((debt_price / peyments_count) * Convert.ToInt64(array[while_loop_counter, 3]) * Convert.ToInt64(array[while_loop_counter, 2])) / 36500).ToString();
}
}
}
peyment_count++;
while_loop_counter++;
}
dgv_bill.DataSource = new Mommo.Data.ArrayDataView(array, colnames);
}
请帮帮我...
非常感谢
please help me ...
thanks a lot
推荐答案
DateTime startDate = ...
DateTime currentDate = startDate.AddMonths(1);
DateTime endDate = ...
while (true)
{
//Print current date or do whatever you need with it.
if (currentDate.AddMonths(1) < endDate)
currentDate = currentDate.AddMonths(1);
else
break;
}
if (currentDate < endDate)
{
while(true)
{
currentDate = currentDate.AddDays(1);
//Do whatever you need to do with the days.
}
}
类似的东西,我没有编译它,但是应该努力做你想做的事。
Something like that, I didn't compile it, but that should work to do what you are after.
这篇关于如何在第一个月和一个月后打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!