如何比较日期,如果第一个日期大于第二个日期,那么加上100卢比的金额是多少? [英] how to compare date and if 1st date is greater than 2nd date, then add 100 rupee in amount fied?

查看:79
本文介绍了如何比较日期,如果第一个日期大于第二个日期,那么加上100卢比的金额是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮我解决这个程序吗?实际上它的财务类型项目...截止日期已经结束,然后罚款将自动添加到适当的金额。它取决于第二个日期。

can anyone help me to solve this program? actually its finance type project... due date is over then penalty charge will be automatically add to due amount. its depent on 2nd date.

private void Paydate_ValueChanged(object sender, EventArgs e)
{
DateTime paydate = Convert.ToDateTime(Paydate.Text);
DateTime duedate1 = Convert.ToDateTime(duedate.Text);
TimeSpan diff = paydate - duedate1;
 
if (diff.TotalDays>30)

{
 

OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\finance.accdb");
con.Open();
string s = "select Duedate,Dueamount from Duedetails" + textBox1.Text + " where SNo='" + noofdue.Text + "'";
OleDbCommand cmd = new OleDbCommand(s, con);
OleDbDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
double a = Convert.ToDouble(textBox4.Text);
double b = a + 100;
string c = Convert.ToString(b);

//duedate.Text = dr.GetString(0);
//c = dr.GetString(1);
textBox4.Text = c.ToString();
 
}

推荐答案

参考: DateTime.Compare方法 [ ^ ]


问题看起来不完整,因为它不清楚。



但如果你想比较提交的日期,你可以查看DateTime.Compare(d1,d2)方法。这需要2个日期变量进行比较并返回日期差异数的整数值,因此返回值小于0然后d1小于d2,如果等于0则两者都是相同的日期,如果返回值id大于0则d1的日期大于d2。



希望这会对你有所帮助。
The question looks incomplete, as its not clear.

But if you are trying to compare the date filed you can look into DateTime.Compare(d1,d2) method. Which expects 2 date variables to compare and returns an integer value of number of date differences, so return value is less than 0 then d1 is smaller than d2, if equals to 0 then both are same dates and if returned value id greater than 0 then d1 is greater date than d2.

Hope that this helps you.


这篇关于如何比较日期,如果第一个日期大于第二个日期,那么加上100卢比的金额是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆