public ActionResult OperateEvent()
        {

            string star = Convert.ToDateTime(CommonFunction.GetNetTime(Convert.ToInt64(Request["startTime"]))).ToString("yyyy-MM-dd") + " 00:00:00";
            string end = Convert.ToDateTime(CommonFunction.GetNetTime(Convert.ToInt64(Request["endTime"]))).ToString("yyyy-MM-dd") + " 00:00:00";
            DateTime dtStar = Convert.ToDateTime(star);
            DateTime dtEnd = Convert.ToDateTime(end).AddHours(24).AddSeconds(-1);
            Calendar c = new Calendar();
            string type = Request["paraType"];
            c.StartDateStr = CommonFunction.GetPHPTime(dtStar.ToString()).ToString();
            c.EndDateStr = CommonFunction.GetPHPTime(dtEnd.ToString()).ToString();
            c.id = Convert.ToUInt32(Request["id"]);
            c.Title = Request["title"];
            c.Notes = Request["notes"];
            c.CalendarId = Convert.ToInt32(Request["calendarId"]);

            ///開始時間和結束時間都不是當天零點的時間,將開始和結束時間轉換為當天零點時間
            switch(type)
            {
                case "eventadd":
                    return Json(_calendarMgr.Save(c));
                case "delete":
                    return Json(_calendarMgr.Delete(c));
                case "eventupdate":
                    return Json(_calendarMgr.Update(c));
                default:
                    return Json(false);
            }
        }
Пример #2
0
 public List<Calendar> GetCalendarInfo(Calendar c)
 {
     try
     {
         return clDao.GetCalendarInfo(c);
     }
     catch (Exception ex)
     {
         throw new Exception("CalendarMgr-->GetCalendarInfo" + ex.Message,ex);
     }
 }
Пример #3
0
 public bool Delete(Calendar c)
 {
     try
     {
         return clDao.Delete(c) > 0;
     }
     catch (Exception ex)
     {
         throw new Exception("CalendarMgr-->Delete" + ex.Message, ex);
     }
 }
Пример #4
0
 public int Delete(Calendar c)
 {
     StringBuilder sb = new StringBuilder();
     try
     {
         sb.AppendFormat(@"DELETE FROM `event` WHERE id = {0} order by id desc", c.id);
         return _access.execCommand(sb.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("CalendarDao---->Delete" + ex.Message, ex);
     }
 }
Пример #5
0
 public int Update(Calendar c)
 {
     StringBuilder sb = new StringBuilder();
     try
     {
         sb.AppendFormat(@"UPDATE `event` SET calendarId = {0},title ='{1}', startDate = '{2}', endDate = '{3}',notes = '{4}' WHERE id = {5};", c.CalendarId, c.Title, c.StartDateStr, c.EndDateStr, c.Notes, c.id);
         return _access.execCommand(sb.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("CalendarDao-->Update" + ex.Message, ex);
     }
 }
Пример #6
0
 public int Save(Calendar c)
 {
     StringBuilder sb = new StringBuilder();
     try
     {
         sb.AppendFormat(@"INSERT INTO event(`calendarId`,`title`,`startDate`,`endDate`,`notes`)VALUES({0},'{1}','{2}','{3}','{4}');", c.CalendarId, c.Title, c.StartDateStr, c.EndDateStr, c.Notes);
         return _access.execCommand(sb.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("CalendarDao-->Save" + ex.Message, ex);
     }       
 }
Пример #7
0
 //add by wwei0216w 2015/5/22
 public List<Calendar> GetCalendarInfo(Calendar c)
 {
     ///根據條件查詢行事歷控件信息,可在if后添加條件 edit by wwei0216w 2015/5/22
     StringBuilder sb = new StringBuilder();
     try
     {
         sb.Append(@"SELECT id,calendarId AS CalendarId,title AS Title,startDate AS StartDateStr,endDate AS EndDateStr,notes AS Notes
                         FROM event 
                     WHERE 1=1");
         if (c.EndDateStr != string.Empty)
         {
             sb.AppendFormat(" AND calendarId = 2 AND '{0}' < endDate", c.EndDateStr);
         }
         else
         {
             return new List<Calendar>();
         }
         return _access.getDataTableForObj<Calendar>(sb.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("CalendarDao-->GetCalendarInfo" + ex.Message,ex) ;
     }
 }