private void dtgv_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { DataGridViewRow row = dtgv.Rows[e.RowIndex]; DateTime date = PublicDate.IsPublicDate(row.Cells[1].Value.ToString(), dtpk.Value.Year); if ((date.Day == 1) && (date.Month == 1) && (date.Year == 1)) { return; } for (int i = 0; i < Cons.DayOfColumn; i++) { for (int j = 0; j < Cons.DayOfWeek; j++) { if (Matrix[i][j].TextColor != Color.DarkGray) { if (Convert.ToInt32(Matrix[i][j].ButtonText) == date.Day) { if (Matrix[i][j].BackgroundColor != Color.Pink) { Matrix[i][j].BackgroundColor = Color.Pink; return; } else { Matrix[i][j].BackgroundColor = Color.FromArgb(255, 255, 255); return; } } } } } } }
private int IsPublicDay(DateTime date) { int[] arrint = PublicDate.IsPublic(date); if (arrint[0] == -1) { if (date.DayOfWeek == DayOfWeek.Sunday) { return(-1); } else { return(-2); } } else { int k = 0; for (int i = 0; i < arrint.Length; i++) { if (k < arrint[i]) { k = arrint[i]; } } if (k == 1) { return(1); } else { return(0); } } }
void DisplayEvent() { TextboxEvent.Clear(); string[] arr = PublicDate.IsPublicString(dtpk.Value); if (arr[0] == "") { TextboxEvent.Text = ""; } else { for (int i = 0; i < arr.Length; i++) { if (i == arr.Length - 1) { TextboxEvent.Text += arr[i]; } else { TextboxEvent.Text += arr[i] + "\r\n"; } TextboxEvent.Lines[i] = arr[i]; } } }
private void IsPublicDate(DateTime date) { string[] arrstring = PublicDate.IsPublicString(date); if (arrstring[0] == "") { return; } else { for (int i = 0; i < arrstring.Length; i++) { dtgv.Rows.Add(arrstring[i]); } } }
private void IsPublicDate(DateTime date) { string[] arrstring = PublicDate.IsPublicString(date); if (arrstring[0] == "") { return; } else { for (int i = 0; i < arrstring.Length; i++) { DateTime datecount = PublicDate.IsPublicDate(arrstring[i], date.Year); int count = datecount.Day - dtpk.Value.Day; dtgv.Rows.Add(string.Format("{0}{1}", count > 0 ? "+" : "", count), arrstring[i]); } } }
private void ColorEvent() { int[] arrint = PublicDate.IsPublic(dtpk.Value); if (arrint[0] == -1) { if (dtpk.Value.DayOfWeek == DayOfWeek.Sunday) { ColorSolar = Color.OrangeRed; ColorLunnar = Color.OrangeRed; } else { ColorSolar = Color.Black; ColorLunnar = Color.Black; } } else { int k = 0; for (int i = 0; i < arrint.Length; i++) { if (k < arrint[i]) { k = arrint[i]; } } if (k == 1) { ColorSolar = Color.Red; ColorLunnar = Color.Red; TextboxEvent.ForeColor = Color.Red; } else { ColorSolar = Color.Blue; ColorLunnar = Color.Blue; TextboxEvent.ForeColor = Color.Blue; } } }
private void IsPublicDate(DateTime date) { string[] arrstring = PublicDate.IsPublicString(date); if (arrstring[0] == "") { return; } else { for (int i = 0; i < arrstring.Length; i++) { DateTime dateEvent = PublicDate.IsPublicDate(arrstring[i], date.Year); DateTime datecount = new DateTime(date.Year, dateEvent.Month, dateEvent.Day); TimeSpan ts = datecount - DateTime.Now; double count = Math.Round(ts.TotalDays, 0); dtgv.Rows.Add(string.Format("{0}{1}", count > 0 ? "+" : "", count), arrstring[i]); } } }
private void dtgv_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { DataGridViewRow row = dtgv.Rows[e.RowIndex]; DateTime date = PublicDate.IsPublicDate(row.Cells[1].Value.ToString(), DateTime.Now.Year); if ((date.Day == 1) && (date.Month == 1) && (date.Year == 1)) { return; } if (date.Day == 1 && date.Month == 1) { if (date.Day == DateTime.Now.Day && date.Month == DateTime.Now.Month && date.Year == DateTime.Now.Year) { date = DateTime.Now; } else { TimeSpan ts = DateTime.Now - date; double count = Math.Round(ts.TotalDays, 0); if (count > 0) { date = new DateTime(DateTime.Now.Year + 1, 1, 1); } } } else { date = new DateTime(DateTime.Now.Year, date.Month, date.Day); } PanelDetailEvent.Visible = true; PanelDetailEvent.BringToFront(); ButtonName.Text = string.Format("{0}" + "\r\n" + "NGÀY {1} THÁNG {2} NĂM {3}", row.Cells[1].Value.ToString().ToUpper(), date.Day, date.Month, date.Year); SetTime(date); } }
private Color[] ColorPublicDate(DateTime date) { int[] arrint = PublicDate.IsPublic(date); if (arrint[0] == -1) { return(null); } else { Color[] colors = new Color[arrint.Length]; for (int i = 0; i < arrint.Length; i++) { if (arrint[i] == 1) { colors[i] = Color.Red; } else { colors[i] = Color.Blue; } } return(colors); } }