예제 #1
0
//        protected void ddlVenues_SelectedIndexChanged(object sender, EventArgs e)
//        {
//            try
//            {
//                CurrentVenueID = ddlVenues.SelectedValue == string.Empty ? 0 : Convert.ToInt64(ddlVenues.SelectedValue);
//                if (CurrentVenueID != 0)
//                {
//                    BindRecords(Convert.ToInt32(ddlYear.SelectedValue), Convert.ToInt32(ddlMonth.SelectedValue));
//                    pnlNoData.Visible = false;
//                    pnlReport.Visible = true;
//                }
//                else
//                {
//                    pnlNoData.Visible = true;
//                    pnlReport.Visible = false;
//                }
//        }
//            catch (Exception ex)
//            {
//               // ExceptionHandler.HandleTrainingException(ex, "ddlVenues_SelectedIndexChanged", false);
//            }
//}
        #endregion

        #region Methods
        /// <summary>
        /// <para>Description:
        /// This method will make the chart structure for the Matrix report, will add days of the current
        /// months in the headers and add times in the first cell it will add Times</para>
        /// <para>Created By: Tanweer </para>
        /// <para>Created Date: 9/23/2013 </para>
        /// </summary>
        /// <param name="year">Year as Int</param>
        /// <param name="month">Month as Int</param>
        private void BindRecords(int year, int month)
        {
            try
            {
                DataTable DataSource = new DataTable();
                DataRow   dataRow;

                DataSource.Columns.Add("Time");

                var start      = DateTime.Today;
                var clockQuery = from offset in Enumerable.Range(15, 30)
                                 select start.AddMinutes(30 *offset);

                //adding times in the ist column
                foreach (var time in clockQuery)
                {
                    dataRow         = DataSource.NewRow();
                    dataRow["Time"] = time.ToString("hh:mm tt");
                    DataSource.Rows.Add(dataRow);
                }

                int days = DateTime.DaysInMonth(year, month);
                //adding days in ist row as columns
                for (int i = 1; i <= days; i++)
                {
                    DataSource.Columns.Add(i.ToString());
                }
                //bind
                gvEvents.DataSource = DataSource;
                gvEvents.DataBind();

                //Highlight Friday
                for (int i = 1; i < gvEvents.HeaderRow.Cells.Count; i++)
                {
                    String   header = gvEvents.HeaderRow.Cells[i].Text;
                    DateTime dtDay  = new DateTime(year, month, Convert.ToInt32(header));

                    foreach (GridViewRow row in gvEvents.Rows)
                    {
                        if (dtDay.ToString("ddd").Equals("Fri"))
                        {
                            row.Cells[i].BackColor = ColorTranslator.FromHtml("#DCDCDC");
                        }
                    }
                }

                //load Session details from database and draw on report
                DataTable dtDetails = _PersonBAL.GetDataForVenueMatrix(CurrentVenueID);
                foreach (DataRow dRow in dtDetails.Rows)
                {
                    DateTime dtStart = Convert.ToDateTime(dRow["StartTime"]);
                    DateTime dtEnd   = Convert.ToDateTime(dRow["EndTime"]);
                    string   name    = Convert.ToString(dRow["FullName"]);
                    sessionName = Convert.ToString(dRow["SessionName"]);

                    if (Convert.ToInt64(dRow["ClassID"]) != ClassID)
                    {
                        isNewClass   = true;
                        sessionCount = 0;
                        ClassID      = Convert.ToInt64(dRow["ClassID"]);
                    }
                    sessionCount++;
                    DrawEvents(year, month, dtStart, dtEnd, name);
                    isNewClass = false;
                }

                //bind the colors
                foreach (var item in MyColorList)
                {
                    item.Name = item.Name.Replace("#*#", string.Empty);
                    item.Name = item.Name.Replace("<br>", ", ");
                }

                rptColors.DataSource = MyColorList;
                rptColors.DataBind();
            }
            catch (Exception ex)
            {
                //  ExceptionHandler.HandleTrainingException(ex, "BindRecords", false);
            }
        }