示例#1
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);
     }
 }
示例#2
0
 /// <summary>
 /// Function to delete HolidaySettings by month based on parameters
 /// </summary>
 /// <param name="strMonth"></param>
 /// <param name="strYear"></param>
 public void HolidaySettingsDeleteByMonth(string strMonth, string strYear)
 {
     try
     {
         SPHoliday.HolidaySettingsDeleteByMonth(strMonth, strYear);
     }
     catch (Exception ex)
     {
         MessageBox.Show("HSBll9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        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" }));
        }
        public JsonResult ClearHoliday(string cur_month)
        {
            HolidaySP spHoliday = new HolidaySP();

            try
            {
                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());
            }

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