public List <DataTable> HoildaySettingsViewAllLimited(string strMonth, string strYear)
 {
     try
     {
         return(spHoliday.HoildaySettingsViewAllLimited(strMonth, strYear));
     }
     catch (Exception)
     {
         throw;
     }
 }
        public DataTable GetHolidays(string date)
        {
            DateTime  cur_date            = Convert.ToDateTime(date);
            string    strMonth            = cur_date.ToString("MMMMyyyy");
            string    dtpMonth            = strMonth.Substring(0, 3);
            string    dtpYear             = cur_date.Year.ToString();
            HolidaySP spHoliday           = new HolidaySP();
            DataTable dtblHolidaySettings = new DataTable();

            dtblHolidaySettings = spHoliday.HoildaySettingsViewAllLimited(dtpMonth.ToString(), dtpYear.ToString());
            return(dtblHolidaySettings);
        }
예제 #3
0
        /// <summary>
        /// Function to view HoildaySettings based on parameters
        /// </summary>
        /// <param name="strMonth"></param>
        /// <param name="strYear"></param>
        /// <returns></returns>
        public List <DataTable> HoildaySettingsViewAllLimited(string strMonth, string strYear)
        {
            List <DataTable> listObj = new List <DataTable>();

            try
            {
                listObj = SPHoliday.HoildaySettingsViewAllLimited(strMonth, strYear);
            }
            catch (Exception ex)
            {
                MessageBox.Show("HSBll7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(listObj);
        }
예제 #4
0
        /// <summary>
        /// Function to fill Datagridview
        /// </summary>
        public void CalenderFill()
        {
            try
            {
                dgvCalender.Rows.Clear();
                dgvCalender.Rows.Add(7);
                DataGridViewTextBoxCell c0 = new DataGridViewTextBoxCell();
                DataGridViewTextBoxCell c1 = new DataGridViewTextBoxCell();
                DataGridViewTextBoxCell c2 = new DataGridViewTextBoxCell();
                DataGridViewTextBoxCell c3 = new DataGridViewTextBoxCell();
                DataGridViewTextBoxCell c4 = new DataGridViewTextBoxCell();
                DataGridViewTextBoxCell c5 = new DataGridViewTextBoxCell();
                DataGridViewTextBoxCell c6 = new DataGridViewTextBoxCell();
                dgvCalender[0, 0]       = c0;
                dgvCalender[1, 0]       = c1;
                dgvCalender[2, 0]       = c2;
                dgvCalender[3, 0]       = c3;
                dgvCalender[4, 0]       = c4;
                dgvCalender[5, 0]       = c5;
                dgvCalender[6, 0]       = c6;
                dgvCalender[0, 0].Value = "Sun";
                dgvCalender[1, 0].Value = "Mon";
                dgvCalender[2, 0].Value = "Tue";
                dgvCalender[3, 0].Value = "Wed";
                dgvCalender[4, 0].Value = "Thu";
                dgvCalender[5, 0].Value = "Fri";
                dgvCalender[6, 0].Value = "Sat";
                dgvCalender.Rows[0].DefaultCellStyle.BackColor = Color.Green;
                dgvCalender.Rows[0].DefaultCellStyle.ForeColor = Color.White;
                int      inNoOfDays = 0;
                string   strDay;
                int      inColumnNumber = 0, inRowNumber = 1;
                DateTime dtDate = new DateTime(dtpYear.Value.Year, dtpMonth.Value.Month, 1);
                strDay = dtDate.DayOfWeek.ToString();
                switch (strDay)
                {
                case "Sunday": inColumnNumber = 0;
                    break;

                case "Monday": inColumnNumber = 1;
                    break;

                case "Tuesday": inColumnNumber = 2;
                    break;

                case "Wednesday": inColumnNumber = 3;
                    break;

                case "Thursday": inColumnNumber = 4;
                    break;

                case "Friday": inColumnNumber = 5;
                    break;

                case "Saturday": inColumnNumber = 6;
                    break;
                }
                inNoOfDays = DateTime.DaysInMonth(dtpYear.Value.Year, dtpMonth.Value.Month);
                for (int i = 1; i <= inNoOfDays; i++)
                {
                    if (inColumnNumber > 6)
                    {
                        inColumnNumber = 0;
                        inRowNumber++;
                    }
                    dgvCalender[inColumnNumber, inRowNumber].Value = i;
                    dtDate = new DateTime(dtpYear.Value.Year, dtpMonth.Value.Month, i);
                    int inDay = int.Parse(dtDate.Month.ToString());
                    if (dtDate <= PublicVariables._dtFromDate || dtDate >= PublicVariables._dtToDate)
                    {
                        dgvCalender[inColumnNumber, inRowNumber].Style.BackColor = Color.DarkRed;
                    }
                    else
                    {
                        dgvCalender[inColumnNumber, inRowNumber].Style.BackColor = Color.FromArgb(209, 238, 218);
                    }
                    inColumnNumber++;
                }
                DataTable dtblHolidaySettings = new DataTable();
                dtblHolidaySettings = spHoliday.HoildaySettingsViewAllLimited(dtpMonth.Text.ToString(), dtpYear.Text.ToString());
                if (dtblHolidaySettings.Rows.Count > 0)
                {
                    for (int i = 0; i < dtblHolidaySettings.Rows.Count; i++)
                    {
                        string strHoliday = DateTime.Parse(dtblHolidaySettings.Rows[i]["date"].ToString()).Day.ToString();
                        foreach (DataGridViewRow dgvRow in dgvCalender.Rows)
                        {
                            if (dgvRow.Index != 0)
                            {
                                for (int j = 0; j <= dgvCalender.ColumnCount - 1; j++)
                                {
                                    if (dgvRow.Cells[j].Value != null && dgvRow.Cells[j].Value.ToString() != "")
                                    {
                                        if (dgvRow.Cells[j].Value.ToString() == strHoliday)
                                        {
                                            dgvRow.Cells[j].Style.BackColor = Color.DeepPink;
                                            dgvRow.Cells[j].ToolTipText     = dtblHolidaySettings.Rows[i]["narration"].ToString();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                dgvCalender.ClearSelection();
            }
            catch (Exception ex)
            {
                MessageBox.Show("HO1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }