private void loading_page_RightDate_Checkeer(string kl) { dataBase db = new dataBase(); string dat = string.Format("{0:yyyy-MM-dd}", dateTimePicker1.Value); kl=string.Format("{0:yyyy-MM-dd}", kl); if (obj.search_date_of_left_day(kl, 0) == true) { // MessageBox.Show(kl +" Date is Found"); clear_right_date(); for (int num = 0; num < 12 ; num++) { read_secondDay_from_DB(kl, num); } } else { // MessageBox.Show(kl + " Date Not Found"); for (int i = 0; i < tableLayoutPanel1.RowCount; i++) { //for (int j = 0; j < tableLayoutPanel1.ColumnCount / 2; j++) for (int j = tableLayoutPanel1.ColumnCount/2; j < tableLayoutPanel1.ColumnCount; j++) { if (i == 0 || j == tableLayoutPanel1.ColumnCount/2 ) { #region #region -----------------------add name for previous or next date available names---------------------------------------------------- if (i == 0 && j==tableLayoutPanel1.ColumnCount / 2) { string nowdt = string.Format("{0:yyyy-MM-dd}", DateTime.Now); //this code for get future date to insert name only if selected date is less than now date if (Convert.ToDateTime(dat) < Convert.ToDateTime(nowdt)) { string ds = db.GetMinFutureDate(dat); if (ds != "") { for (int jj = tableLayoutPanel1.ColumnCount / 2; jj < tableLayoutPanel1.ColumnCount; jj++) { tableLayoutPanel1.Controls.Remove(tableLayoutPanel1.GetControlFromPosition(jj, i)); } read_secondDay_from_DB1(ds, 0); } } //this code for get past date to insert name only in selected date is greater than now date else if ((Convert.ToDateTime(dat) > Convert.ToDateTime(nowdt))) { string ds = db.GetMinPastDate(dat); if (ds != "") { for (int jj = tableLayoutPanel1.ColumnCount / 2; jj < tableLayoutPanel1.ColumnCount; jj++) { tableLayoutPanel1.Controls.Remove(tableLayoutPanel1.GetControlFromPosition(jj, i)); } read_secondDay_from_DB1(ds, 0); } } } #endregion trial and error2 } else { // MessageBox.Show("Cleaning "+i+" = row and column = "+j); tableLayoutPanel1.Controls.Remove(tableLayoutPanel1.GetControlFromPosition(j, i)); } } } } }
private void loading_page_Date_Checker(string kj) { //check whether data is available for date if yes //kj = string.Format("{0:yyyy-MM-dd}", kj); dataBase db = new dataBase(); string dat = string.Format("{0:yyyy-MM-dd}", dateTimePicker1.Value); if (obj.search_date_of_left_day(kj, 0) == true) { // MessageBox.Show(kj + " Date is Found"); clear_left_date(); for (int num = 0; num < tableLayoutPanel1.ColumnCount / 2; num++) { read_firstDay_from_DB(kj, num); } } else//if data is not avialable for date { // MessageBox.Show(kj + " Date Not Found"); for (int i = 0; i < tableLayoutPanel1.RowCount; i++) { for (int j = 0; j < tableLayoutPanel1.ColumnCount / 2; j++) { if (i == 0 || j == 0) { #region -----------------------add name for previous or next date available names---------------------------------------------------- if (i==0 && j==0) { string nowdt = string.Format("{0:yyyy-MM-dd}", DateTime.Now); //this code for get future date to insert name only if selected date is less than now date if (Convert.ToDateTime(dat) < Convert.ToDateTime(nowdt)) { string ds = db.GetMinFutureDate(dat); if (ds != "") { for (int jj = 0; jj < tableLayoutPanel1.ColumnCount / 2; jj++) { tableLayoutPanel1.Controls.Remove(tableLayoutPanel1.GetControlFromPosition(jj, i)); } read_firstDay_from_DB1(ds, 0); } } //this code for get past date to insert name only in selected date is greater than now date else if ((Convert.ToDateTime(dat) > Convert.ToDateTime(nowdt))) { string ds = db.GetMinPastDate(dat); if (ds != "") { for (int jj = 0; jj < tableLayoutPanel1.ColumnCount / 2; jj++) { tableLayoutPanel1.Controls.Remove(tableLayoutPanel1.GetControlFromPosition(jj, i)); } read_firstDay_from_DB1(ds, 0); } } } #endregion end tiral and error } else { tableLayoutPanel1.Controls.Remove(tableLayoutPanel1.GetControlFromPosition(j, i)); //MessageBox.Show("Deleting"); } } } } }