public List <T_Search_Event> SearchMyTask(int searchid, int userLevel, string title, string start) { string wtitel = ""; string wstart = ""; if (title != "") { wtitel = " and Name like'%" + title + "%'"; } if (start != "") { wstart = " and convert(varchar(10),StartTime,120) = '" + start + "'"; } string where = "StuId = " + searchid + wtitel + wstart; DALT_Event_MyTask dal = new DALT_Event_MyTask(); List <T_Event_MyTask> lst = dal.GetAllList(where); List <T_Search_Event> list = new List <T_Search_Event>(); #region 转换成现实格式 foreach (T_Event_MyTask item in lst) { T_Search_Event now = new T_Search_Event(); now.Name = item.Name; now.StartTime = (DateTime)item.StartTime; now.EndTime = (DateTime)item.EndTime; now.Description = item.Description; if (item.IsAlert == 1) { now.AlertTime = (int)item.AlertTime; } else { now.AlertTime = 0; } now.Type = item.Type; list.Add(now); } #endregion return(list); }
public T_Search_Event DataRowToSearch(DataRow row) { T_Search_Event model = new T_Search_Event(); if (row != null) { DateTime st = (DateTime)row["StartWeek"]; string ym = st.ToString("yyyy-MM-dd"); if (row["StartTime"] != null) { string strSt = row["StartTime"].ToString(); string res = ym + " " + strSt; DateTime newSt = Convert.ToDateTime(strSt); model.StartTime = newSt; } if (row["EndTime"] != null) { string strEn = row["EndTime"].ToString(); string res = ym + " " + strEn; DateTime newEn = Convert.ToDateTime(strEn); model.EndTime = newEn; } if (row["Name"] != null && row["Name"].ToString() != "") { model.Name = row["Name"].ToString(); } if (row["Type"] != null && row["Type"].ToString() != "") { model.Type = int.Parse(row["Type"].ToString()); } if (row["Description"] != null) { model.Description = row["Description"].ToString(); } if (row["IsAlert"] != null && row["IsAlert"].ToString() != "") { model.IsAlert = int.Parse(row["IsAlert"].ToString()); } } return(model); }