Camilo Lozano III
Visual C#: Detect Conflict Schedule

Screenshot
It seems a lot of people are searching about solving conflict schedule. So I decided to create a sample. Below is the core code of checking conflict schedule…
// sample conflict detection (defined) [start]
DateTime d = new DateTime(2010, 1, 13);
richTextBox1.Text = DateTime.Now.ToLongDateString() + ” = ” + d.ToLongDateString() + “\n”;
if (DateTime.Now.CompareTo(d) > 0)
{
richTextBox1.Text += “true\n” + DateTime.Now.CompareTo(d).ToString();
}
else
{
richTextBox1.Text += “false\n” + DateTime.Now.CompareTo(d).ToString();
}
richTextBox1.Text += “\n\n”;
DateTime dx = DateTime.Now;
//MessageBox.Show(dx.Hour.ToString());
DateTime[] dt = new DateTime[4];
// enrolled schedule
dt[0] = new DateTime(int.Parse(dx.Year.ToString()), int.Parse(dx.Month.ToString()), int.Parse(dx.Day.ToString()), 8, 0, 0);
dt[1] = new DateTime(int.Parse(dx.Year.ToString()), int.Parse(dx.Month.ToString()), int.Parse(dx.Day.ToString()), 9, 0, 0);
// adding new schedule
dt[2] = new DateTime(int.Parse(dx.Year.ToString()), int.Parse(dx.Month.ToString()), int.Parse(dx.Day.ToString()), 9, 0, 0);
dt[3] = new DateTime(int.Parse(dx.Year.ToString()), int.Parse(dx.Month.ToString()), int.Parse(dx.Day.ToString()), 10, 0, 0);
// checking schedule conflict
if (((dt[0].CompareTo(dt[2]) < 0) && (dt[1].CompareTo(dt[2]) > 0)) || (dt[0].ToShortTimeString() == dt[2].ToShortTimeString()))
{
richTextBox1.Text += dt[0].ToShortTimeString() + ” – ” + dt[1].ToShortTimeString() + ” against ” + dt[2].ToShortTimeString() + ” – ” + dt[3].ToShortTimeString() + “\nResult: CONFLICT”;
}
else
{
richTextBox1.Text += dt[0].ToShortTimeString() + ” – ” + dt[1].ToShortTimeString() + ” against ” + dt[2].ToShortTimeString() + ” – ” + dt[3].ToShortTimeString() + “\nResult: NO CONFLICT”;
}
// sample conflict detection (defined) [end]
If you want to download the whole code, link below and enjoy… Do not practice the copy and paste!
Download: Detect Conflict Schedule (14)
| Print article | This entry was posted by Camilo III on January 18, 2010 at 4:55 pm, and is filed under Info.Tech, Software Development, Visual C#. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
about 6 months ago
how about in vb.net?…
about 6 months ago
sorry can’t help about VB.. i don’t like VB programming structure..
i’m more in C family programming…
about 6 months ago
I surely have to come along your great idea just about this post in time of the research papers or just america essay paper performing. Therefore, thank you for your contribution.
about 2 months ago
how about in vb.net?…