private bool ControlAccompanist() { string sSql; if (NewId.Text != "-1") { if (Convert.ToInt32(DatabaseConnection.SqlScalar("SELECT COUNT(*) FROM BASE_CALENDAR WHERE SENCONDIDOWNER=" + int.Parse(NewId.Text) + " AND UID=" + int.Parse(TxtAccomplistID.Text))) > 0) { return(true); } else { sSql = "SELECT ID,RECURRID,STARTDATE,ENDDATE FROM BASE_CALENDAR WHERE ID<>" + NewId.Text + " AND UID=" + TxtAccomplistID.Text + " AND (("; } } else { sSql = "SELECT ID,RECURRID,STARTDATE,ENDDATE FROM BASE_CALENDAR WHERE UID=" + TxtAccomplistID.Text + " AND (("; } DateTime start = UC.LTZ.ToUniversalTime(Convert.ToDateTime(TxtStartDate.Text + " " + TxtStartHour.Text, UC.myDTFI)); DateTime endDate = UC.LTZ.ToUniversalTime(Convert.ToDateTime(TxtStartDate.Text + " " + TxtEndDate.Text, UC.myDTFI)); sSql += "(STARTDATE>'" + start.ToString(@"yyyyMMdd HH:mm", G.InvariantCultureForDB) + "' AND STARTDATE<'" + endDate.ToString(@"yyyyMMdd HH:mm", G.InvariantCultureForDB) + "') OR "; sSql += "(STARTDATE<='" + start.ToString(@"yyyyMMdd HH:mm", G.InvariantCultureForDB) + "' aND ENDDATE>='" + endDate.ToString(@"yyyyMMdd HH:mm", G.InvariantCultureForDB) + "') OR "; sSql += "(ENDDATE>'" + start.ToString(@"yyyyMMdd HH:mm", G.InvariantCultureForDB) + "' AND ENDDATE<='" + endDate.ToString(@"yyyyMMdd HH:mm", G.InvariantCultureForDB) + "') OR "; sSql += "(STARTDATE>'" + start.ToString(@"yyyyMMdd HH:mm", G.InvariantCultureForDB) + "' AND ENDDATE<'" + endDate.ToString(@"yyyyMMdd HH:mm", G.InvariantCultureForDB) + "'))"; sSql += " OR (RECURRID>0))"; DataSet checkTimeLine = DatabaseConnection.CreateDataset(sSql); if (checkTimeLine.Tables[0].Rows.Count > 0) { bool free = true; DataRow[] drInUse = checkTimeLine.Tables[0].Select("RECURRID>0"); if (drInUse.Length > 0) { foreach (DataRow dr in drInUse) { Recurrence recurrence = new Recurrence(UC); ArrayList AL = recurrence.Remind((int)dr["recurrid"], Convert.ToDateTime(TxtStartDate.Text + " 00:00:00", UC.myDTFI), Convert.ToDateTime(TxtStartDate.Text + " 23:59:59", UC.myDTFI)); if (AL.Count > 0) { DateTime drStart = ((DateTime)AL[0]).AddHours(((DateTime)dr["startdate"]).Hour); DateTime drEnd = ((DateTime)AL[0]).AddHours(((DateTime)dr["enddate"]).Hour); if ((drStart > start && drStart < endDate) || (drStart <= start && drEnd >= endDate) || (drEnd > start && drEnd <= endDate) || (drStart > start && drEnd < endDate)) { free = false; } else { free = true; } } else { free = true; } } } else { free = false; } return(free); } return(true); }
public void Submit_Click(Object sender, EventArgs e) { bool dateValid; bool dateValid2 = true; try { dateValid = true; try { if (TxtEndHour.Text.Length > 0) { Convert.ToDateTime(TxtEndHour.Text, UC.myDTFI); } dateValid2 = true; } catch { dateValid2 = false; } } catch { dateValid = false; try { if (TxtEndHour.Text.Length > 0) { Convert.ToDateTime(TxtEndHour.Text, UC.myDTFI); } dateValid2 = true; } catch { dateValid2 = false; } } if (dateValid && dateValid2) { string sSql; int newID = int.Parse(NewId.Text); if (newID != -1) { if (UC.ImpersonateUser == 0) { sSql = "SELECT ID,RECURRID,STARTDATE,ENDDATE FROM BASE_CALENDAR WHERE ID<>" + newID + " AND UID=" + UC.UserId + " AND (("; } else { sSql = "SELECT ID,RECURRID,STARTDATE,ENDDATE FROM BASE_CALENDAR WHERE ID<>" + newID + " AND UID=" + UC.ImpersonateUser + " AND (("; } } else { if (UC.ImpersonateUser == 0) { sSql = "SELECT ID,RECURRID,STARTDATE,ENDDATE FROM BASE_CALENDAR WHERE UID=" + UC.UserId.ToString() + " AND (("; } else { sSql = "SELECT ID,RECURRID,STARTDATE,ENDDATE FROM BASE_CALENDAR WHERE UID=" + UC.ImpersonateUser + " AND (("; } } DateTime beginTime = UC.LTZ.ToUniversalTime(Convert.ToDateTime(TxtStartDate.Text + " " + TxtStartHour.Text, UC.myDTFI)); DateTime endTime = UC.LTZ.ToUniversalTime(Convert.ToDateTime(TxtEndDate.Text + " " + TxtEndHour.Text, UC.myDTFI)); sSql += "(STARTDATE>'" + beginTime.ToString(@"yyyyMMdd HH:mm", G.InvariantCultureForDB) + "' AND STARTDATE<'" + endTime.ToString(@"yyyyMMdd HH:mm", G.InvariantCultureForDB) + "') OR "; sSql += "(STARTDATE<='" + beginTime.ToString(@"yyyyMMdd HH:mm", G.InvariantCultureForDB) + "' AND ENDDATE>='" + endTime.ToString(@"yyyyMMdd HH:mm", G.InvariantCultureForDB) + "') OR "; sSql += "(ENDDATE>'" + beginTime.ToString(@"yyyyMMdd HH:mm", G.InvariantCultureForDB) + "' AND ENDDATE<='" + endTime.ToString(@"yyyyMMdd HH:mm", G.InvariantCultureForDB) + "') OR "; sSql += "(STARTDATE>'" + beginTime.ToString(@"yyyyMMdd HH:mm", G.InvariantCultureForDB) + "' AND ENDDATE<'" + endTime.ToString(@"yyyyMMdd HH:mm", G.InvariantCultureForDB) + "'))"; sSql += " OR (RECURRID>0))"; DataSet checkTimeLine = DatabaseConnection.CreateDataset(sSql); if (checkTimeLine.Tables[0].Rows.Count > 0) { bool free = true; DataRow[] drInUse = checkTimeLine.Tables[0].Select("RECURRID>0"); if (drInUse.Length > 0) { foreach (DataRow dr in drInUse) { Recurrence recurrence = new Recurrence(UC); ArrayList AL = recurrence.Remind((int)dr["recurrid"], Convert.ToDateTime(TxtStartDate.Text + " 00:00:00", UC.myDTFI), Convert.ToDateTime(TxtStartDate.Text + " 23:59:59", UC.myDTFI)); if (AL.Count > 0) { DateTime drStart = ((DateTime)AL[0]).AddHours(((DateTime)dr["startdate"]).Hour); DateTime drEnd = ((DateTime)AL[0]).AddHours(((DateTime)dr["enddate"]).Hour); if ((drStart > beginTime && drStart < endTime) || (drStart <= beginTime && drEnd >= endTime) || (drEnd > beginTime && drEnd <= endTime) || (drStart > beginTime && drEnd < endTime)) { free = false; } else { free = true; } } else { free = true; } } } else { free = false; } if (free) { if (TxtAccomplistID.Text.Length > 0) { if (ControlAccompanist()) { string newId; newId = SaveAppointment(DDDLser.SelectedItem.Value, NewId.Text, NewId.Text); string crossid = SaveAppointment(TxtAccomplistID.Text, "-1", newId); DatabaseConnection.DoCommand("uPDATE BASE_CALENDAR SET SENCONDIDOWNER=" + crossid + " WHERE ID=" + newId); G.Message(int.Parse(TxtAccomplistID.Text), Root.rm.GetString("Evnttxt1"), TxtStartDate.Text + " " + TxtStartHour.Text + "-" + TxtEndDate.Text + "<br>" + TxtContact.Text + "<br>" + F_note.Text, TxtStartDate.Text + " " + TxtStartHour.Text + "-" + TxtEndDate.Text + "<br>" + TxtContact.Text + "<br>" + F_note.Text); onSaveAppointment(true); } else { Info.Text = "<center><span style=\"font-family: verdana;font-size: 12px;color: red;\">" + Root.rm.GetString("Evnttxt68") + "</span>"; } } else { SaveAppointment(DDDLser.SelectedItem.Value, NewId.Text, NewId.Text); onSaveAppointment(true); } } else { Info.Text = "<center><span style=\"font-family: verdana;font-size: 12px;color: red;\">" + Root.rm.GetString("Evnttxt72") + "</span>"; } } else { if (TxtAccomplistID.Text.Length > 0) { if (ControlAccompanist()) { string newId; newId = SaveAppointment(DDDLser.SelectedItem.Value, NewId.Text, NewId.Text); string crossid = SaveAppointment(TxtAccomplistID.Text, "-1", newId); DatabaseConnection.DoCommand("UPDATE BASE_CALENDAR SET SENCONDIDOWNER=" + crossid + " WHERE ID=" + newId); G.Message(int.Parse(TxtAccomplistID.Text), Root.rm.GetString("Evnttxt1"), TxtStartDate.Text + " " + TxtStartHour.Text + "-" + TxtEndDate.Text + "<br>" + TxtContact.Text + "<br>" + F_note.Text, TxtStartDate.Text + " " + TxtStartHour.Text + "-" + TxtEndDate.Text + "<br>" + TxtContact.Text + "<br>" + F_note.Text); onSaveAppointment(true); } else { Info.Text = "<center><span style=\"font-family: verdana;font-size: 12px;color: red;\">Attenzione, Companion occupato.</span>"; } } else { SaveAppointment(DDDLser.SelectedItem.Value, NewId.Text, NewId.Text); onSaveAppointment(true); } } } else { if (!dateValid) { DateEr1.Text += "<span style=\"color:red;\">*</span>"; } if (!dateValid2) { DateEr2.Text += "<span style=\"color:red;\">*</span>"; } } }
public void Submit_Click(Object sender, EventArgs e) { bool datevalid; bool datevalid2 = true; try { datevalid = true; try { if (F_EndDate.Text.Length > 0) { Convert.ToDateTime(F_EndDate.Text, UC.myDTFI); } datevalid2 = true; } catch { datevalid2 = false; } } catch { datevalid = false; try { if (F_EndDate.Text.Length > 0) { Convert.ToDateTime(F_EndDate.Text, UC.myDTFI); } datevalid2 = true; } catch { datevalid2 = false; } } if (datevalid && datevalid2 && F_EndDate.Text.Length > 0) { DateTime firstdate = Convert.ToDateTime(F_StartDate.Text, UC.myDTFI); DateTime seconddate = Convert.ToDateTime(F_EndDate.Text, UC.myDTFI); if (seconddate < firstdate) { DateEr2.Text += "<span style=\"color:red;\">*</span>"; Info.Text = "<center><span style=\"font-family: verdana;font-size: 12px;color: red;\">" + Root.rm.GetString("Evnttxt73") + "</span>"; return; } } if (datevalid && datevalid2) { string sSql; int newID = int.Parse(NewId.Text); if (newID != -1) { if (UC.ImpersonateUser == 0) { sSql = "SELECT ID,RECURRID,STARTDATE,ENDDATE FROM BASE_CALENDAR WHERE ID<>" + newID + " AND UID=" + UC.UserId + " AND (("; } else { sSql = "SELECT ID,RECURRID,STARTDATE,ENDDATE FROM BASE_CALENDAR WHERE ID<>" + newID + " AND UID=" + UC.ImpersonateUser + " AND (("; } } else { if (UC.ImpersonateUser == 0) { sSql = "SELECT ID,RECURRID,STARTDATE,ENDDATE FROM BASE_CALENDAR WHERE UID=" + UC.UserId.ToString() + " AND (("; } else { sSql = "SELECT ID,RECURRID,STARTDATE,ENDDATE FROM BASE_CALENDAR WHERE UID=" + UC.ImpersonateUser + " AND (("; } } DateTime start = UC.LTZ.ToUniversalTime(Convert.ToDateTime(F_StartDate.Text + " " + F_StartHour.Text, UC.myDTFI)); DateTime endDate = UC.LTZ.ToUniversalTime(Convert.ToDateTime(F_StartDate.Text + " " + F_EndHour.Text, UC.myDTFI)); sSql += "(STARTDATE>'" + start.ToString(@"yyyyMMdd HH:mm", InvariantCultureForDB) + "' AND STARTDATE<'" + endDate.ToString(@"yyyyMMdd HH:mm", InvariantCultureForDB) + "') OR "; sSql += "(STARTDATE<='" + start.ToString(@"yyyyMMdd HH:mm", InvariantCultureForDB) + "' AND ENDDATE>='" + endDate.ToString(@"yyyyMMdd HH:mm", InvariantCultureForDB) + "') OR "; sSql += "(ENDDATE>'" + start.ToString(@"yyyyMMdd HH:mm", InvariantCultureForDB) + "' AND ENDDATE<='" + endDate.ToString(@"yyyyMMdd HH:mm", InvariantCultureForDB) + "') OR "; sSql += "(STARTDATE>'" + start.ToString(@"yyyyMMdd HH:mm", InvariantCultureForDB) + "' AND ENDDATE<'" + endDate.ToString(@"yyyyMMdd HH:mm", InvariantCultureForDB) + "'))"; sSql += " OR (RECURRID>0))"; DataSet testCoverage = DatabaseConnection.CreateDataset(sSql); if (testCoverage.Tables[0].Rows.Count > 0) { bool free = true; DataRow[] drBusyreal = testCoverage.Tables[0].Select("RECURRID=0"); if (drBusyreal.Length > 0) { free = false; } else { DataRow[] drBusy = testCoverage.Tables[0].Select("RECURRID>0"); if (drBusy.Length > 0) { foreach (DataRow dr in drBusy) { Recurrence recurrence = new Recurrence(UC); ArrayList AL = recurrence.Remind((int)dr["recurrid"], Convert.ToDateTime(F_StartDate.Text + " 00:00:00", UC.myDTFI), Convert.ToDateTime(F_StartDate.Text + " 23:59:59", UC.myDTFI)); if (AL.Count > 0) { DateTime drStart = ((DateTime)AL[0]).AddHours(((DateTime)dr["startdate"]).Hour); DateTime drEnd = ((DateTime)AL[0]).AddHours(((DateTime)dr["enddate"]).Hour); if ((drStart > start && drStart < endDate) || (drStart <= start && drEnd >= endDate) || (drEnd > start && drEnd <= endDate) || (drStart > start && drEnd < endDate)) { free = false; } else { free = true; } } else { free = true; } } } } if (free) { if (IdCompanion.Text.Length > 0) { if (ControllaCompanion()) { string newId; newId = ModifyDataSet(UserApp.SelectedItem.Value, NewId.Text, NewId.Text); string crossId = ModifyDataSet(IdCompanion.Text, "-1", newId); DatabaseConnection.DoCommand("UPDATE BASE_CALENDAR SET SENCONDIDOWNER=" + crossId + " WHERE ID=" + newId); Message(int.Parse(IdCompanion.Text), Root.rm.GetString("Evnttxt1"), F_StartDate.Text + " " + F_StartHour.Text + "-" + F_EndHour.Text + "<br>" + F_Title.Text + "<br>" + F_note.Text, F_StartDate.Text + " " + F_StartHour.Text + "-" + F_EndHour.Text + "<br>" + F_Title.Text + "<br>" + F_note.Text); Response.Redirect("agenda.aspx?m=25&si=2&date=" + F_StartDate.Text); } else { Info.Text = "<center><span style=\"font-family: verdana;font-size: 12px;color: red;\">" + Root.rm.GetString("Evnttxt68") + "</span>"; } } else { ModifyDataSet(UserApp.SelectedItem.Value, NewId.Text, NewId.Text); Response.Redirect("agenda.aspx?m=25&si=2&date=" + F_StartDate.Text); } } else { Info.Text = "<center><span style=\"font-family: verdana;font-size: 12px;color: red;\">" + Root.rm.GetString("Evnttxt72") + "</span>"; } } else { if (IdCompanion.Text.Length > 0) { if (ControllaCompanion()) { string newId; newId = ModifyDataSet(UserApp.SelectedItem.Value, NewId.Text, NewId.Text); string crossId = ModifyDataSet(IdCompanion.Text, "-1", newId); DatabaseConnection.DoCommand("UPDATE BASE_CALENDAR SET SENCONDIDOWNER=" + crossId + " WHERE ID=" + newId); Message(int.Parse(IdCompanion.Text), Root.rm.GetString("Evnttxt1"), F_StartDate.Text + " " + F_StartHour.Text + "-" + F_EndHour.Text + "<br>" + F_Title.Text + "<br>" + F_note.Text, F_StartDate.Text + " " + F_StartHour.Text + "-" + F_EndHour.Text + "<br>" + F_Title.Text + "<br>" + F_note.Text); Response.Redirect("agenda.aspx?m=25&si=2&date=" + F_StartDate.Text); } else { Info.Text = "<center><span style=\"font-family: verdana;font-size: 12px;color: red;\">Attenzione, Companion occupato.</span>"; } } else { ModifyDataSet(UserApp.SelectedItem.Value, NewId.Text, NewId.Text); Response.Redirect("agenda.aspx?m=25&si=2&date=" + F_StartDate.Text); } } } else { if (!datevalid) { DateEr1.Text += "<span style=\"color:red;\">*</span>"; } if (!datevalid2) { DateEr2.Text += "<span style=\"color:red;\">*</span>"; } } }
public void Submit_Click(Object sender, EventArgs e) { if (Validator()) { string sSql; string SqlString2; bool all = true; DataSet testCoverage; DateTime startDate = UC.LTZ.ToUniversalTime(Convert.ToDateTime(F_StartDate.Text + " " + F_StartHour.Text, UC.myDTFI)); DateTime endDate = UC.LTZ.ToUniversalTime(Convert.ToDateTime(F_StartDate.Text + " " + F_EndHour.Text, UC.myDTFI)); sSql = "(STARTDATE>'" + startDate.ToString(@"yyyyMMdd HH:mm", InvariantCultureForDB) + "' AND STARTDATE<'" + endDate.ToString(@"yyyyMMdd HH:mm", InvariantCultureForDB) + "') OR "; sSql += "(STARTDATE<='" + startDate.ToString(@"yyyyMMdd HH:mm", InvariantCultureForDB) + "' AND ENDDATE>='" + endDate.ToString(@"yyyyMMdd HH:mm", InvariantCultureForDB) + "') OR "; sSql += "(ENDDATE>'" + startDate.ToString(@"yyyyMMdd HH:mm", InvariantCultureForDB) + "' AND ENDDATE<='" + endDate.ToString(@"yyyyMMdd HH:mm", InvariantCultureForDB) + "') OR "; sSql += "(STARTDATE>'" + startDate.ToString(@"yyyyMMdd HH:mm", InvariantCultureForDB) + "' AND ENDDATE<'" + endDate.ToString(@"yyyyMMdd HH:mm", InvariantCultureForDB) + "'))"; sSql += " OR (RECURRID>0))"; foreach (string li in SelectOffice.GetValueArray) { if (li.Length > 0) { SqlString2 = "SELECT * FROM BASE_CALENDAR WHERE UID=" + int.Parse(li) + " AND ((" + sSql; testCoverage = DatabaseConnection.CreateDataset(SqlString2); if (testCoverage.Tables[0].Rows.Count > 0) { bool free = true; DataRow[] drBusy = testCoverage.Tables[0].Select("RECURRID=0"); if (drBusy.Length > 0) { free = false; } else { foreach (DataRow dr in drBusy) { Recurrence recurrence = new Recurrence(UC); ArrayList AL = recurrence.Remind((int)dr["recurrid"], Convert.ToDateTime(F_StartDate.Text + " 00:00:00", UC.myDTFI), Convert.ToDateTime(F_StartDate.Text + " 23:59:59", UC.myDTFI)); if (AL.Count > 0) { DateTime drStart = ((DateTime)AL[0]).AddHours(((DateTime)dr["startdate"]).Hour); DateTime drEnd = ((DateTime)AL[0]).AddHours(((DateTime)dr["enddate"]).Hour); if ((drStart > startDate && drStart < endDate) || (drStart <= startDate && drEnd >= endDate) || (drEnd > startDate && drEnd <= endDate) || (drStart > startDate && drEnd < endDate)) { free = false; } else { free = true; } } else { free = true; } } } if (!free) { all = false; SelectOffice.SetSelected(li); } } } } if (!all) { Trace.Warn("bloccato"); Info.Text = "<center><span style=\"font-family: verdana;font-size: 12px;color: red;\">" + Root.rm.GetString("Meettxt54") + "</span>"; } else { Trace.Warn("passato"); ModifyDataSet(); Response.Redirect("agenda.aspx?m=25&si=2"); } } else { Info.Text = "<center><span style=\"font-family: verdana;font-size: 12px;color: red;\">" + Root.rm.GetString("Meettxt55") + "</span>"; } }
private string FillDay(DateTime data, int uIDATTUALE) { string sqlCalendar = "SELECT ID,RECURRID,CONVERT(VARCHAR(10),STARTDATE,112) AS ISOSTARTDATE, DATEPART(HH, STARTDATE) AS STARTHOUR, DATEPART(HH, ENDDATE) AS ENDHOUR,CONTACT,COMPANY,STARTDATE,ENDDATE FROM BASE_CALENDAR WHERE (CONVERT(VARCHAR(10),STARTDATE,112)='" + data.ToString(@"yyyyMMdd") + "' OR RECURRID>0) AND UID=@UID"; Trace.Warn("SQL", sqlCalendar); DataSet dsCalendar = DatabaseConnection.SecureCreateDataset(sqlCalendar, new DbSqlParameter("@UID", uIDATTUALE)); DataTable CalendarDataTable = dsCalendar.Tables[0]; StringBuilder gg = new StringBuilder(); StringBuilder descTable = new StringBuilder(); DateTime Utctime = UC.LTZ.ToUniversalTime(data); TimeSpan mindiffstart = new TimeSpan(data.Ticks - Utctime.Ticks); int hTimeZone = Convert.ToInt32(mindiffstart.TotalHours); DataColumn dcDynColumn = new DataColumn(); dcDynColumn.ColumnName = "isRec"; dcDynColumn.DataType = Type.GetType("System.Byte"); dcDynColumn.DefaultValue = 0; CalendarDataTable.Columns.Add(dcDynColumn); int rowsToCicleCal = CalendarDataTable.Rows.Count; if (CalendarDataTable.Select("RecurrID>0").Length > 0) { DateTime MDT = data; DateTime MDT2 = MDT.AddSeconds(86399); Trace.Warn("MDT", MDT.ToString()); Trace.Warn("MDT2", MDT2.ToString()); for (int i = 0; i < rowsToCicleCal; i++) { Recurrence recurrence = new Recurrence(UC); ArrayList AL = recurrence.Remind((int)CalendarDataTable.Rows[i]["recurrid"], MDT, MDT2); if (AL.Count > 0) { foreach (DateTime ALT in AL) { DataRow row = CalendarDataTable.NewRow(); for (int i2 = 0; i2 < CalendarDataTable.Columns.Count - 1; i2++) { row[i2] = CalendarDataTable.Rows[i][i2]; } row["isRec"] = 1; row["startdate"] = ALT.Date.Add(((DateTime)row["startdate"]).TimeOfDay); row["enddate"] = ALT.Date.Add(((DateTime)row["enddate"]).TimeOfDay); row["ISOSTARTDATE"] = ALT.ToString(@"yyyyMMdd"); CalendarDataTable.Rows.Add(row); } if (Convert.ToInt32(((string)CalendarDataTable.Rows[i]["ISOSTARTDATE"]).Substring(4, 2)) != data.Month) { CalendarDataTable.Rows[i]["ISOSTARTDATE"] = "19800101"; } } } } DataRow[] drAppExists = CalendarDataTable.Select("ISOSTARTDATE='" + data.ToString(@"yyyyMMdd") + "'"); long idNumber = 0; gg.AppendFormat("<table><tr><td colspan=6 class=normal>{0}</td></tr><tr>", DatabaseConnection.SqlScalar("SELECT ISNULL(NAME,'')+' '+ISNULL(SURNAME,'') FROM ACCOUNT WHERE UID=" + uIDATTUALE)); for (int xx = 0; xx <= 23; xx++) { if (xx % 2 == 0) { gg.Append("<td valign=\"top\" class=\"Grid "); } else { gg.Append("<td valign=\"top\" class=\"GridAltern "); } if (drAppExists.Length > 0) { bool exists = false; string appString = String.Empty; foreach (DataRow drSelApp in drAppExists) { if (((int)drSelApp["starthour"] + hTimeZone) == xx && idNumber != Convert.ToInt32(drSelApp["id"])) { exists = true; appString = "GridApp\">"; } else { if (((int)drSelApp["starthour"] + hTimeZone) < xx && ((int)drSelApp["endhour"] + hTimeZone) >= xx && idNumber != Convert.ToInt32(drSelApp["id"])) { exists = true; appString = "GridApp\">"; } } } gg.Append(appString.ToString()); if (!exists) { gg.AppendFormat("\">{0}:00</td>", xx.ToString()); } else { gg.AppendFormat("{0}:00</td>", xx.ToString()); } } else { gg.AppendFormat("\">{0}:00</td>", xx.ToString()); } if (xx == 5 || xx == 11 || xx == 17 || xx == 23) { gg.Append("</tr><tr>"); } } gg.Append("</table>"); int clnumber = 1; foreach (DataRow drSelApp in drAppExists) { string cl = ((clnumber % 2) == 0) ? "GridItem" : "GridItemAltern"; clnumber++; descTable.AppendFormat("<tr><td width=\"1%\" nowrap class={2}>{0}</td><td width=\"1%\" nowrap class={2}>{1}</td>", ((DateTime)drSelApp["startdate"]).AddHours(hTimeZone).ToShortTimeString(), ((DateTime)drSelApp["enddate"]).AddHours(hTimeZone).ToShortTimeString(), cl); descTable.AppendFormat("<td width=\"98%\" nowrap class={2}>{0} {1}</td></tr>", drSelApp["contact"].ToString(), drSelApp["company"].ToString(), cl); } if (descTable.Length > 0) { gg.AppendFormat("<table class=\"normal\" cellspacing=0 cellpadding=3 width=\"100%\" style=\"border-top:2px solid black;\">{0}</table>", descTable.ToString()); } return(gg.ToString()); }