TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Muhammad Amman Zaheer
NA
1
1.1k
Calendar Schedule issue
Oct 2 2013 4:39 AM
Please resolve my issue which is regarding to calendar
All months worked fine except december. It replicate december dates
For E.g
If 2013 is end on Tuesday 31
Then 2014 is end on Monday 31
It will show dates in the form of
2014:
Monday Tuesday
31 31
Replicate of previous month values only in december i asked many top programmers all are failed to resolved.
public partial class AddWorkPlanner : Form
{
private int click = 0;
private int count = 0;
private int addyrow = 0;
private int day = 0;
private int yearfirstday = 0;
private int january = 1;
private int feb = 1;
private int apr = 1;
private int may = 1;
private int jun = 1;
private int jul = 1;
private int aug = 1;
private int sep = 1;
private int oct = 1;
private int nov = 1;
private int dec = 1;
private int march = 1;
private int febfirstday = 0;
private int marfirstday = 0; private int aprfirstday = 0; private int mayfirstday = 0;
private int junfirstday = 0; private int julfirstday = 0; private int augfirstday = 0;
private int sepfirstday = 0; private int octfirstday = 0; private int novfirstday = 0;
private int decfirstday = 0;
public AddWorkPlanner()
{
InitializeComponent();
}
private void AddWorkPlanner_Load(object sender, EventArgs e)
{
LoadEmployees();
LoadDepartments();
LoadGroups();
LoadWorkPlanner();
}
public void LoadWorkPlanner()
{
datagridyear.Visible = true;
datagridyear.Visible = true;
datagridyear.Location = new Point(9, 20);
datagridyear.Size = new Size(877, 395);
SetWidthYear();
AddRowYear();
SetRowHeightOfYear();
HeadercellOfYear();
DisplayDateYear();
}
private void SetWidthYear()
{
for (int i = 0; i <= 36; i++)
{
datagridyear.Columns[i].Width = 22;
datagridyear.RowHeadersWidth = 25;
}
}
private void AddRowYear()
{
if (addyrow == 0)
{
datagridyear.Rows.Add(12);
addyrow = 1;
}
}
private void SetRowHeightOfYear()
{
for (int j = 0; j <= 11; j++)
{
datagridyear.Rows[j].Height = 31;
// datagridyear.Rows[j].HeaderCell
}
}
private void HeadercellOfYear()
{
datagridyear.RowHeadersWidth = 60;
datagridyear.TopLeftHeaderCell.Value = monthCalendar1.SelectionStart.ToString("yyyy");
datagridyear.Rows[0].HeaderCell.Value = "Jan";
datagridyear.Rows[1].HeaderCell.Value = "Feb";
datagridyear.Rows[2].HeaderCell.Value = "Mar";
datagridyear.Rows[3].HeaderCell.Value = "Apr";
datagridyear.Rows[4].HeaderCell.Value = "May";
datagridyear.Rows[5].HeaderCell.Value = "Jun";
datagridyear.Rows[6].HeaderCell.Value = "Jul";
datagridyear.Rows[7].HeaderCell.Value = "Aug";
datagridyear.Rows[8].HeaderCell.Value = "Sep";
datagridyear.Rows[9].HeaderCell.Value = "Oct";
datagridyear.Rows[10].HeaderCell.Value = "Nov";
datagridyear.Rows[11].HeaderCell.Value = "Dec";
datagridyear.Columns[5].DefaultCellStyle.BackColor = Color.LightSteelBlue;
datagridyear.Columns[6].DefaultCellStyle.BackColor = Color.LightSteelBlue;
datagridyear.Columns[12].DefaultCellStyle.BackColor = Color.LightSteelBlue;
datagridyear.Columns[13].DefaultCellStyle.BackColor = Color.LightSteelBlue;
datagridyear.Columns[19].DefaultCellStyle.BackColor = Color.LightSteelBlue;
datagridyear.Columns[20].DefaultCellStyle.BackColor = Color.LightSteelBlue;
datagridyear.Columns[26].DefaultCellStyle.BackColor = Color.LightSteelBlue;
datagridyear.Columns[27].DefaultCellStyle.BackColor = Color.LightSteelBlue;
datagridyear.Columns[33].DefaultCellStyle.BackColor = Color.LightSteelBlue;
datagridyear.Columns[34].DefaultCellStyle.BackColor = Color.LightSteelBlue;
datagridyear.ClearSelection();
for (int i = 0; i <= 36; i++)
{
if (i == 5 || i == 6 || i == 12 || i == 13 || i == 19 || i == 20 || i == 26 || i == 27 || i == 33 || i == 34)
{
}
else
{
datagridyear.Columns[i].DefaultCellStyle.BackColor = Color.LightGray;
}
}
}
private void DisplayDateYear()
{
// datagridyear[0, 0].Value = monthCalendar1.SelectionStart.DayOfYear;
int currentday = monthCalendar1.SelectionStart.DayOfYear;
int k = 1;
string leap = monthCalendar1.SelectionStart.ToString("yyyy");
int leap1 = Convert.ToInt32(leap);
int leap2 = leap1 % 4;
if (leap2 != 0)
{
for (int r = 0; r <= 11; r++)
{
for (int c = 0; c <= 36; c++)
{
if (k < 366)
{
if (r == 0 && january <= 31)
// if(january<=31)
{
january++;
if (yearfirstday == 0)
{ //////January///////
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 1).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
yearfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 0 && january > 32)
{
datagridyear[c, r].Value = "";
}
if (r == 0 && january == 32)
{
january++;
}
//////february///////
if (r == 1 && feb <= 28)
{
feb++;
if (febfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 32).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
febfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 1 && feb > 29)
{
datagridyear[c, r].Value = "";
}
if (r == 1 && january == 29)
{
feb++;
}
//////March/////////////////
if (r == 2 && march <= 31)
{
march++;
if (marfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 60).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
marfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 2 && march > 32)
{
datagridyear[c, r].Value = "";
}
if (r == 2 && march == 32)
{
march++;
}
//////endMarch//////////////
//////Apr//////////////
if (r == 3 && apr <= 30)
{
apr++;
if (aprfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 91).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
aprfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 3 && apr > 31)
{
datagridyear[c, r].Value = "";
}
if (r == 3 && apr == 31)
{
apr++;
}
//////endApril//////////////
//////May//////////////
if (r == 4 && may <= 31)
{
may++;
if (mayfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 121).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
mayfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 4 && may > 32)
{
datagridyear[c, r].Value = "";
}
if (r == 4 && may == 32)
{
may++;
}
////////////////////
//////jun//////////////
if (r == 5 && jun <= 30)
{
jun++;
if (junfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 152).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
junfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 5 && jun > 31)
{
datagridyear[c, r].Value = "";
}
if (r == 0 && jun == 31)
{
jun++;
}
////////////////////
//////jul/////////////
if (r == 6 && jul <= 31)
{
jul++;
if (julfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 182).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
julfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 6 && jul > 32)
{
datagridyear[c, r].Value = "";
}
if (r == 6 && jul == 32)
{
jul++;
}
//////endApril//////////////
//////Aug//////////////
if (r == 7 && aug <= 31)
{
aug++;
if (augfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 213).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5; datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
augfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 7 && aug > 32)
{
datagridyear[c, r].Value = "";
}
if (r == 7 && aug == 32)
{
aug++;
}
//////endApril//////////////
//////Sept//////////////
if (r == 8 && sep <= 30)
{
sep++;
if (sepfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 244).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5; datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
sepfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 8 && sep > 31)
{
datagridyear[c, r].Value = "";
}
if (r == 8 && sep == 31)
{
sep++;
}
//////endApril//////////////
//////Oct//////////////
if (r == 9 && oct <= 31)
{
oct++;
if (octfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 274).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
octfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 9 && oct > 32)
{
datagridyear[c, r].Value = "";
}
if (r == 9 && oct == 32)
{
oct++;
}
//////endApril//////////////
//////Nov//////////////
if (r == 10 && nov <= 30)
{
nov++;
if (novfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 305).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
novfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 10 && nov > 31)
{
datagridyear[c, r].Value = "";
}
if (r == 10 && nov == 31)
{
nov++;
}
//////endApril//////////////
///////////Dec//////////////////////////////////////////////////
if (r == 11 && dec <= 31)
{
dec++;
if (decfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 335).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5; datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
decfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 11 && dec > 32)
{
datagridyear[c, r].Value = "";
}
if (r == 11 && dec == 32)
{
dec++;
}
/////////////////////////////////////////////////////////////////
// yearfirstday = 0;
}
}
}
}
if (leap2 == 0)
{
for (int r = 0; r <= 11; r++)
{
for (int c = 0; c <= 36; c++)
{
if (k < 367)
{
if (r == 0 && january <= 31)
// if(january<=31)
{
january++;
if (yearfirstday == 0)
{ //////January///////
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 1).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
yearfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 0 && january > 32)
{
datagridyear[c, r].Value = "";
}
if (r == 0 && january == 32)
{
january++;
}
//////february///////
if (r == 1 && feb <= 29)
{
feb++;
if (febfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 32).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
febfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 1 && feb > 30)
{
datagridyear[c, r].Value = "";
}
if (r == 1 && feb == 30)
{
feb++;
}
//////March/////////////////
if (r == 2 && march <= 31)
{
march++;
if (marfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 61).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
marfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 2 && march > 32)
{
datagridyear[c, r].Value = "";
}
if (r == 2 && march == 32)
{
march++;
}
//////endMarch//////////////
//////Apr//////////////
if (r == 3 && apr <= 30)
{
apr++;
if (aprfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 92).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
aprfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 3 && apr > 31)
{
datagridyear[c, r].Value = "";
}
if (r == 3 && apr == 31)
{
apr++;
}
//////endApril//////////////
//////May//////////////
if (r == 4 && may <= 31)
{
may++;
if (mayfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 122).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
mayfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 4 && may > 32)
{
datagridyear[c, r].Value = "";
}
if (r == 4 && may == 32)
{
may++;
}
////////////////////
//////jun//////////////
if (r == 5 && jun <= 30)
{
jun++;
if (junfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 153).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
}
}
junfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 5 && jun > 31)
{
datagridyear[c, r].Value = "";
}
if (r == 5 && jun == 31)
{
jun++;
}
////////////////////
//////jul/////////////
if (r == 6 && jul <= 31)
{
jul++;
if (julfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 183).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
julfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 6 && jul > 32)
{
datagridyear[c, r].Value = "";
}
if (r == 6 && jul == 32)
{
jul++;
}
//////endApril//////////////
//////Aug//////////////
if (r == 7 && aug <= 31)
{
aug++;
if (augfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 214).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
augfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 7 && aug > 32)
{
datagridyear[c, r].Value = "";
}
if (r == 7 && aug == 32)
{
aug++;
}
//////endApril//////////////
//////Sept//////////////
if (r == 8 && sep <= 30)
{
sep++;
if (sepfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 245).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
sepfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 8 && sep > 31)
{
datagridyear[c, r].Value = "";
}
if (r == 8 && sep == 31)
{
sep++;
}
//////endApril//////////////
//////Oct//////////////
if (r == 9 && oct <= 31)
{
oct++;
if (octfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 275).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
octfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 9 && oct > 32)
{
datagridyear[c, r].Value = "";
}
if (r == 9 && oct == 32)
{
oct++;
}
//////endApril//////////////
//////Nov//////////////
if (r == 10 && nov <= 30)
{
nov++;
if (novfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 306).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
novfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 10 && nov > 31)
{
datagridyear[c, r].Value = "";
}
if (r == 10 && nov == 31)
{
nov++;
}
//////endApril//////////////
///////////Dec//////////////////////////////////////////////////
if (r == 11 && dec <= 31)
{
dec++;
if (decfirstday == 0)
{
string checkday = monthCalendar1.SelectionStart.AddDays(-currentday + 336).ToString("dddd");
if (checkday == "Monday")
{
c = 0;
}
if (checkday == "Tuesday")
{
c = 1;
datagridyear[0, r].Value = "";
}
if (checkday == "Wednesday")
{
c = 2;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
}
if (checkday == "Thursday")
{
c = 3;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
}
if (checkday == "Friday")
{
c = 4;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
}
if (checkday == "Saturday")
{
c = 5;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
}
if (checkday == "Sunday")
{
c = 6;
datagridyear[0, r].Value = "";
datagridyear[1, r].Value = "";
datagridyear[2, r].Value = "";
datagridyear[3, r].Value = "";
datagridyear[4, r].Value = "";
datagridyear[5, r].Value = "";
}
}
decfirstday = 1;
datagridyear[c, r].Value = monthCalendar1.SelectionStart.AddDays(-currentday + k).ToString("dd");
k++;
}
if (r == 11 && dec > 32)
{
datagridyear[c, r].Value = "";
}
if (r == 11 && dec == 32)
{
dec++;
}
/////////////////////////////////////////////////////////////////
// yearfirstday = 0;
}
}
}
}
january = 1; yearfirstday = 0;
feb = 1; febfirstday = 0;
march = 1; marfirstday = 0;
apr = 1; aprfirstday = 0;
may = 1; mayfirstday = 0;
jun = 1; junfirstday = 0;
jul = 1; julfirstday = 0;
aug = 1; augfirstday = 0;
sep = 1; sepfirstday = 0;
oct = 1; octfirstday = 0;
nov = 1; novfirstday = 0;
dec = 1; decfirstday = 0;
}
///////////////////////End year's functions and methods/////////////////////////////
public void LoadEmployees()
{
Employeepersonal emp = new Employeepersonal();
DataSet ds = new DataSet();
ds = emp.LoadAll();
dgv_Employees.DataSource = ds.Tables[0];
}
public void LoadGroups()
{
EmployeeGroups empgroup = new EmployeeGroups();
DataSet ds = new DataSet();
ds = empgroup.LoadAll();
dgv_Groups.DataSource = ds.Tables[0];
}
public void LoadDepartments()
{
Department dept = new Department();
DataSet ds = new DataSet();
ds = dept.LoadAll();
dgv_Department.DataSource = ds.Tables[0];
}
private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
{
// DisplayDateYear();
LoadWorkPlanner();
}
private void monthCalendar1_DateSelected(object sender, DateRangeEventArgs e)
{
}
}
Reply
Answers (
0
)
Windows Application Datagridview
how to convert a code of C# form to C# wpf