using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Globalization;public partial class _Default : System.Web.UI.Page
{
private static ChineseLunisolarCalendar chineseDate = new ChineseLunisolarCalendar();
protected void Page_Load(object sender, EventArgs e)
{
ShowCurrentYearInfo();
}
protected void btnok_Click(object sender, EventArgs e)
{
Session["year"] = year.Text;
int y = Convert.ToInt32(Session["year"]);
if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0)
{
Response.Write(Session["year"] + "是闰年");
}
else
{
Response.Write(Session["year"] + "不是闰年");
} }
private void ShowCurrentYearInfo()
{
int inYear = Convert.ToInt32(year.Text);
int inMonth = Convert.ToInt32(month.Text);
int inDate = Convert.ToInt32(date.Text); int lYear = chineseDate.GetYear(DateTime.Now);
int lMonth = chineseDate.GetMonth(DateTime.Now);
int lDate = chineseDate.GetDayOfMonth(DateTime.Now); /** GetLeapMonth(int year)方法返回一个1到13之间的数字,
* 比如:1、该年阴历2月有闰月,则返回3
* 如果:2、该年阴历8月有闰月,则返回9
* GetMonth(DateTime dateTime)返回是当前月份,忽略是否闰月
* 比如:1、该年阴历2月有闰月,2月返回2,闰2月返回3
* 如果:2、该年阴历8月有闰月,8月返回8,闰8月返回9
*/
int leapMonth = chineseDate.GetLeapMonth(lYear);//获取第几个月是闰月,等于0表示本年无闰月
//如果今年有闰月
if (leapMonth > 0)
{
//闰月数等于当前月份
if (lMonth == leapMonth)
{
Response.Write("当前输入日期的农历日期:" + lYear + "年" + (lMonth - 1) + "月" + lDate + "日" );
//Console.WriteLine("今年的阴历日期:{0}年闰{1}月{2}日。", lYear, lMonth - 1, lDay);
}
else if (lMonth > leapMonth)
{
Response.Write("当前输入日期的农历日期:" + lYear + "年" + (lMonth - 1) + "月" + lDate + "日");
//Console.WriteLine("今年的阴历日期:{0}年{1}月{2}日。", lYear, lMonth - 1, lDay);
}
else
{
Response.Write("当前输入日期的农历日期:" + lYear + "年" + lMonth + "月" + lDate + "日");
//Console.WriteLine("今年的阴历日期:{0}年{1}月{2}日。", lYear, lMonth, lDay);
} }
else
{
Response.Write("当前输入日期的农历日期:" + lYear + "年" + lMonth + "月" + lDate + "日");
//Console.WriteLine("今年的阴历日期:{0}年{1}月{2}日。", lYear, lMonth, lDay);
} //throw new NotImplementedException();
}
}怎么使lYear输出的农历日期是inYear所对应的啊?
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Globalization;public partial class _Default : System.Web.UI.Page
{
private static ChineseLunisolarCalendar chineseDate = new ChineseLunisolarCalendar();
protected void Page_Load(object sender, EventArgs e)
{
ShowCurrentYearInfo();
}
protected void btnok_Click(object sender, EventArgs e)
{
Session["year"] = year.Text;
int y = Convert.ToInt32(Session["year"]);
if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0)
{
Response.Write(Session["year"] + "是闰年");
}
else
{
Response.Write(Session["year"] + "不是闰年");
} }
private void ShowCurrentYearInfo()
{
int inYear = Convert.ToInt32(year.Text);
int inMonth = Convert.ToInt32(month.Text);
int inDate = Convert.ToInt32(date.Text); int lYear = chineseDate.GetYear(DateTime.Now);
int lMonth = chineseDate.GetMonth(DateTime.Now);
int lDate = chineseDate.GetDayOfMonth(DateTime.Now); /** GetLeapMonth(int year)方法返回一个1到13之间的数字,
* 比如:1、该年阴历2月有闰月,则返回3
* 如果:2、该年阴历8月有闰月,则返回9
* GetMonth(DateTime dateTime)返回是当前月份,忽略是否闰月
* 比如:1、该年阴历2月有闰月,2月返回2,闰2月返回3
* 如果:2、该年阴历8月有闰月,8月返回8,闰8月返回9
*/
int leapMonth = chineseDate.GetLeapMonth(lYear);//获取第几个月是闰月,等于0表示本年无闰月
//如果今年有闰月
if (leapMonth > 0)
{
//闰月数等于当前月份
if (lMonth == leapMonth)
{
Response.Write("当前输入日期的农历日期:" + lYear + "年" + (lMonth - 1) + "月" + lDate + "日" );
//Console.WriteLine("今年的阴历日期:{0}年闰{1}月{2}日。", lYear, lMonth - 1, lDay);
}
else if (lMonth > leapMonth)
{
Response.Write("当前输入日期的农历日期:" + lYear + "年" + (lMonth - 1) + "月" + lDate + "日");
//Console.WriteLine("今年的阴历日期:{0}年{1}月{2}日。", lYear, lMonth - 1, lDay);
}
else
{
Response.Write("当前输入日期的农历日期:" + lYear + "年" + lMonth + "月" + lDate + "日");
//Console.WriteLine("今年的阴历日期:{0}年{1}月{2}日。", lYear, lMonth, lDay);
} }
else
{
Response.Write("当前输入日期的农历日期:" + lYear + "年" + lMonth + "月" + lDate + "日");
//Console.WriteLine("今年的阴历日期:{0}年{1}月{2}日。", lYear, lMonth, lDay);
} //throw new NotImplementedException();
}
}怎么使lYear输出的农历日期是inYear所对应的啊?
解决方案 »
- C#窗体怎样才可以让同一窗体只出现一次
- 自定义控件中,用List<customclass>作为控件的属性,怎么让他在设计模式的时候显示改变后的效果呢?
- Application.ExitThread()为何不能退出?
- GridView动态模板加单元格事件,在触发后数据丢失,求解(模范别人的)
- 弱弱问问ERP的几个简单问题
- 求一个vs2008 英文版的下载地址(不要试用版的,无msdn最好,电脑上已经有msdn了是vs2005的) !
- 软件的安装部署
- 请教高手:如何得到treeview中最后一层选中的行文本?
- 项目文件打不开是什么原因呢?
- 求解:在线等~~~ C# 共享内存 问题,CeateFileMapping 不是C#的就不要灌水了
- GDI+绘图遮挡消失,OnPaint如何重写
- c#动态调用C++代码。对PInvoke函数“InteropDemo!InteropDemo.Program+Add::Invoke”的调用导致堆栈不对称。
http://hi.baidu.com/liyukun8203/item/3e8193bc4551cf41bb0e12a5
int inMonth = Convert.ToInt32(month.Text);
int inDate = Convert.ToInt32(date.Text);
NongLi bllNL = new NongLi();
int str = bllNL.GetDate(inYear, inMonth, inDate);
这里GetDate(int a, int b, int c),为什么提示无法将string 转换为int啊?
GetDate返回值是string吧,不能赋给int