Esempio n. 1
0
 public ActionResult SemesterAdd(string Title,DateTime SignDate,DateTime StartDate,DateTime SignEndDate,DateTime EndDate)
 {
     Training_Plan model = new Training_Plan();
     model.Title = Title;
     model.PartitionId = Code.SiteCache.Instance.LoginInfo.PartitionId;
     model.Sort = int.Parse(DateTime.Now.ToString("HHmmssfff"));
     model.IsOpen = false;
     model.Display = true;
     model.Delflag = false;
     model.CreateDate = DateTime.Now;
     model.SignUpStartTime = SignDate;
     model.SignUpEndTime = SignEndDate;
     model.OpenClassFrom = StartDate;
     model.OpenClassTo = EndDate;
     if (bll.YzPlanName(model.Title,0))
     {
         return Content("no:学期名重复!!!");
     }
     int i = bll.Add(model);
     if (i > 0)
     {
         return Content("yes:添加成功!!!");
     }
     else
     {
         return Content("no:添加失败!!!");
     }
 }
Esempio n. 2
0
        private void ConvertToModel(IDataReader reader, Training_Plan model)
        {
            if (reader["Id"] != DBNull.Value)
                model.Id = Convert.ToInt32(reader["Id"]);

            if (reader["Title"] != DBNull.Value)
                model.Title = reader["Title"].ToString();

            if (reader["PartitionId"] != DBNull.Value)
                model.PartitionId = Convert.ToInt32(reader["PartitionId"]);

            if (reader["IsOpen"] != DBNull.Value)
                model.IsOpen = Convert.ToBoolean(reader["IsOpen"]);

            if (reader["Sort"] != DBNull.Value)
                model.Sort = Convert.ToInt32(reader["Sort"]);

            if (reader["Display"] != DBNull.Value)
                model.Display = Convert.ToBoolean(reader["Display"]);

            if (reader["Delflag"] != DBNull.Value)
                model.Delflag = Convert.ToBoolean(reader["Delflag"]);

            if (reader["CreateDate"] != DBNull.Value)
                model.CreateDate = Convert.ToDateTime(reader["CreateDate"]);

            if (reader["SignUpStartTime"] != DBNull.Value)
                model.SignUpStartTime = Convert.ToDateTime(reader["SignUpStartTime"]);

            if (reader["SignUpEndTime"] != DBNull.Value)
                model.SignUpEndTime = Convert.ToDateTime(reader["SignUpEndTime"]);

            if (reader["OpenClassFrom"] != DBNull.Value)
                model.OpenClassFrom = Convert.ToDateTime(reader["OpenClassFrom"]);

            if (reader["OpenClassTo"] != DBNull.Value)
                model.OpenClassTo = Convert.ToDateTime(reader["OpenClassTo"]);
        }
Esempio n. 3
0
 public bool SemesterUpd(Training_Plan model)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append(" update Training_Plan Set Title=@Title,Display=@Display, ");
     sql.Append(" SignUpStartTime=@SignUpStartTime,SignUpEndTime=@SignUpEndTime,OpenClassFrom=@OpenClassFrom,OpenClassTo=@OpenClassTo ");
     sql.Append(" where id=@id ");
     SqlParameter[] para ={
                             new SqlParameter("@Title",SqlDbType.VarChar),
                             new SqlParameter("@Display",SqlDbType.Bit),
                             new SqlParameter("@id",SqlDbType.Int),
                             new SqlParameter("@SignUpStartTime",SqlDbType.DateTime),
                             new SqlParameter("@SignUpEndTime",SqlDbType.DateTime),
                             new SqlParameter("@OpenClassFrom",SqlDbType.DateTime),
                             new SqlParameter("@OpenClassTo",SqlDbType.Date)
                          };
     para[0].Value = model.Title;
     para[1].Value = model.Display;
     para[2].Value = model.Id;
     para[3].Value = model.SignUpStartTime;
     para[4].Value = model.SignUpEndTime;
     para[5].Value = model.OpenClassFrom;
     para[6].Value = model.OpenClassTo;
     int i = MSEntLibSqlHelper.ExecuteNonQueryBySql(sql.ToString(), para);
     if (i > 0)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Esempio n. 4
0
 public List<Training_Plan> GetList(int pageSize, int pageIndex, string where, string orderBy, out int recordCount)
 {
     if (string.IsNullOrEmpty(orderBy))
         throw new ArgumentNullException();
     StringBuilder sb = new StringBuilder();
     sb.Append("select count(1) from dbo.Training_Plan where Delflag = 0 and DisPlay = 1 ");
     if (!string.IsNullOrEmpty(where))
         sb.Append(where);
     recordCount = Convert.ToInt32(MSEntLibSqlHelper.ExecuteScalarBySql(sb.ToString()));
     int start = (pageIndex - 1) * pageSize + 1;
     int end = pageIndex * pageSize;
     StringBuilder sql = new StringBuilder();
     sql.Append("select * from (select *,ROW_NUMBER() over (order by " + orderBy + ") as RowNum from dbo.Training_Plan  where Delflag = 0 and DisPlay = 1 ");
     if (!string.IsNullOrEmpty(where))
         sql.Append(where);
     sql.Append(")as T where RowNum between @start and @end");
     SqlParameter[] para ={
                             new SqlParameter("@start",start),
                             new SqlParameter("@end",end)
                          };
     List<Training_Plan> list = new List<Training_Plan>();
     using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql.ToString(),para))
     {
         while (reader.Read())
         {
             Training_Plan model = new Training_Plan();
             ConvertToModel(reader, model);
             list.Add(model);
         }
     }
     return list;
 }
Esempio n. 5
0
 public bool SemesterUpd(Training_Plan model)
 {
     return dal.SemesterUpd(model);
 }
Esempio n. 6
0
 public ActionResult SemesterEdit(int id,string Title, DateTime SignDate, DateTime StartDate, DateTime SignEndDate, DateTime EndDate)
 {
     Training_Plan model = new Training_Plan();
     model.Id = id;
     model.Title = Title;
     model.Display = true;
     model.SignUpStartTime = SignDate;
     model.SignUpEndTime = SignEndDate;
     model.OpenClassFrom = StartDate;
     model.OpenClassTo = EndDate;
     if (bll.YzPlanName(model.Title,model.Id))
     {
         return Content("no:学期名重复!!!");
     }
     if (bll.SemesterUpd(model))
     {
         return Content("yes:修改成功!!!");
     }
     else
     {
         return Content("no:修改失败!!!");
     }
 }