Solved

default date alerts

Posted on 2007-03-31
4
191 Views
Last Modified: 2013-12-16
hi all,
here is the problem,
i hv three date fileds in my form.one is openeddate,second duedate.third one is resolved date.....
opendate will be the currentdate.....
duedate will be three days from the opendate and i have to consider saturday and sunday,and this has to prompt a message saying you have to resolve this by today in the last date.please help me out how to do this one with current date.......resolved date must come after resolving the issue.
my problem is with duedate now..................help needed
0
Comment
Question by:hariprasadere
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
fredvr666 earned 500 total points
ID: 18831471
Something like this:

private void Form1_Load(object sender, EventArgs e)
    {
      //this.textBoxCount.Text = Convert.ToString(3);
      this.textBoxToday.Text = DateTime.Now.ToString("dd-MM-yyyy");
    }
   
    private void button1_Click(object sender, EventArgs e)
    {
      DateTime From;
      DateTime Planned;
      GregorianCalendar Cal = new GregorianCalendar();
      long WorkDays = 0;
      Int32 Days = 0;

      From=Convert.ToDateTime(this.textBoxToday.Text);
      Days = Convert.ToInt32(this.textBoxCount.Text);
      Planned = Cal.AddDays(From, Days);
      WorkDays = WorkingDays(Cal.AddDays(From, 1), Planned);
      Days = Days + (Days - Convert.ToInt32(WorkDays));
      Planned = Cal.AddDays(From, Days);
     
      this.textBoxPlanned.Text = Planned.ToString("dd-MM-yyyy");
    }
   
    long WorkingDays(DateTime beginDate, DateTime endDate)
    {
      TimeSpan span = endDate.Subtract(beginDate);
      long wholeWeeks = ((long)Math.Round(Math.Floor(span.TotalDays))) / 7;
      DateTime dateCount = beginDate.AddDays(wholeWeeks * 7);
      int endDays = 0;

      while (dateCount.Date <= endDate.Date)
      {
        switch (dateCount.DayOfWeek)
        {
          case DayOfWeek.Saturday:
          case DayOfWeek.Sunday:
            break;
          default:
            endDays++;
            break;
        }
        dateCount = dateCount.AddDays(1);
      }
      return wholeWeeks * 5 + endDays;
    }
0
 

Author Comment

by:hariprasadere
ID: 18833954
thanks ....but it seems it only displays the duedate,how abt the alert messages that has to come when the due date is closing....pls help me out that too.
0
 

Author Comment

by:hariprasadere
ID: 18837534
Days = Convert.ToInt32(this.textBoxCount.Text);
what is this textBoxCount.Text?,Can you help me out as Iam unable to locate it in my form.....
0
 
LVL 3

Expert Comment

by:fredvr666
ID: 18838482
hariprasadere thanks for the points.
It's just a textbox with the name textBoxCount which is presented the duedate count.
The example is just a test to work with.
The alert message fired when you do something like planned<=today so fire the message
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question