Solved

default date alerts

Posted on 2007-03-31
4
192 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

840 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