Click here to Skip to main content
15,886,046 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
C#
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();
 
}
Posted
Updated 7-Jan-15 1:33am
v2
Comments
King Fisher 7-Jan-15 7:01am    
we can't do the whole thing for you .what have you tried so far?
nagendrathecoder 7-Jan-15 7:02am    
Your question is not clear, please explain more.
Also what have you tried and what problems you are facing?
ArunRajendra 7-Jan-15 7:15am    
Post your code then we can help you to get the solution.
Sabarish Mahalingam 7-Jan-15 7:30am    
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();

}
i wrote this code according to my requirment. but its not working xactly.
Neetin_1809 7-Jan-15 8:57am    
Check OutThe Baisc Functionality Of Datetime.Campare() So That You Can Have Excat Idea

 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900