public JsonResult AddHoliday(string date, string narration)
        {
            HolidaySP spHoliday = new HolidaySP();

            try
            {
                HolidayInfo infoHoliday = new HolidayInfo();
                {
                    DateTime curdate = Convert.ToDateTime(date);
                    infoHoliday.Date = curdate;
                    if (narration != null)
                    {
                        infoHoliday.Narration = narration.Trim();
                    }
                    else
                    {
                        infoHoliday.Narration = string.Empty;
                    }
                    infoHoliday.HolidayName = string.Empty;
                    infoHoliday.Extra1      = string.Empty;
                    infoHoliday.Extra2      = string.Empty;
                    spHoliday.HolidayAddWithIdentity(infoHoliday);
                }
                HolidaySettingsDate(date);
            }

            catch (Exception ex)
            {
                return(Json(new { error = "failed" }));
            }
            return(Json(new { error = "success" }));
        }
Exemple #2
0
 /// <summary>
 /// Function for save
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         spHoliday.HolidaySettingsDeleteByMonth(dtpMonth.Text.ToString(), dtpYear.Text.ToString());
         if (dgvHolidayRegister.Rows.Count > 0)
         {
             foreach (DataGridViewRow dgvRow in dgvHolidayRegister.Rows)
             {
                 infoHoliday.Date = DateTime.Parse(dgvRow.Cells[0].Value.ToString());
                 if (dgvRow.Cells["dgvtxtNarration"].Value != null)
                 {
                     string strNarration = dgvRow.Cells["dgvtxtNarration"].Value.ToString();
                     infoHoliday.Narration = strNarration.Trim();
                 }
                 else
                 {
                     infoHoliday.Narration = string.Empty;
                 }
                 infoHoliday.HolidayName = string.Empty;
                 infoHoliday.Extra1      = string.Empty;
                 infoHoliday.Extra2      = string.Empty;
                 spHoliday.HolidayAddWithIdentity(infoHoliday);
             }
         }
         Messages.SavedMessage();
         Clear();
         CalenderFill();
     }
     catch (Exception ex)
     {
         MessageBox.Show("HO4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #3
0
        /// <summary>
        /// Function to insert values to Holiday table and return Id
        /// </summary>
        /// <param name="holidayinfo"></param>
        /// <returns></returns>
        public bool HolidayAddWithIdentity(HolidayInfo holidayinfo)
        {
            bool isSave = true;

            try
            {
                isSave = SPHoliday.HolidayAddWithIdentity(holidayinfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show("HSBll8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(isSave);
        }
        public bool HolidayAddWithIdentity(HolidayInfo holidayinfo)
        {
            bool isStatus = false;

            try
            {
                isStatus = spHoliday.HolidayAddWithIdentity(holidayinfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show("SB3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(isStatus);
        }
        public JsonResult SaveAllHoliday(string cur_month, string tableData)
        {
            HolidaySP spHoliday = new HolidaySP();

            try
            {
                List <Dictionary <string, object> > items = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(tableData);
                if (cur_month == null)
                {
                    cur_month = Convert.ToString(DateTime.Now);
                }
                DateTime curdate  = Convert.ToDateTime(cur_month);
                string   strMonth = curdate.ToString("MMMMyyyy");
                string   dtpMonth = strMonth.Substring(0, 3);

                string dtpYear = curdate.Year.ToString();
                spHoliday.HolidaySettingsDeleteByMonth(dtpMonth.ToString(), dtpYear.ToString());
                HolidayInfo infoHoliday = new HolidayInfo();
                int         inrowcount  = items.Count;
                for (int i = 0; i < inrowcount; i++)
                {
                    DateTime date = Convert.ToDateTime(items[i]["date"]);
                    infoHoliday.Date = date;
                    if (items[i]["narration"] != null)
                    {
                        string strNarration = Convert.ToString(items[i]["narration"]);
                        infoHoliday.Narration = strNarration.Trim();
                    }
                    else
                    {
                        infoHoliday.Narration = string.Empty;
                    }
                    infoHoliday.HolidayName = string.Empty;
                    infoHoliday.Extra1      = string.Empty;
                    infoHoliday.Extra2      = string.Empty;
                    spHoliday.HolidayAddWithIdentity(infoHoliday);
                }
                HolidaySettingsDate(cur_month);
            }

            catch (Exception ex)
            {
                return(Json(new { error = "failed" }));
            }
            return(Json(new { error = "success" }));
        }