Exemplo n.º 1
0
 /// <summary>
 /// 添加或编辑
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static JobInfo Create(JobInfo model) {
     if (model.Id == 0)
     {
         int id = JobManage.Insert(model);
         model.Id = id;
     }
     else {
         JobManage.Update(model);
     }
     return model;
 }
Exemplo n.º 2
0
        public ActionResult Create(JobInfo model) {

            bool errors = false;
            bool isAdd = model.Id == 0;

            if(string.IsNullOrEmpty(model.Title)){
                errors = true;
                ModelState.AddModelError("Title","职位名称不能为空");
            }
            if(!errors && ModelState.IsValid){
              
                int id = JobService.Create(model).Id;
                ViewBag.Status = false;
                if(id>0){
                    ViewBag.Status = true;
                }
            }
            return View(model);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static int Update(JobInfo model) {
     string strSQL = "UPDATE Job SET  Title = @Title ,Introduction = @Introduction,WorkingPlace = @WorkingPlace,IsPublished = @IsPublished ,Sort = @Sort,IsHot = @IsHot,Number = @Number WHERE Id = @Id";
     SqlParameter[] param = { 
                             new SqlParameter("Id",SqlDbType.Int),
                             new SqlParameter("Title",SqlDbType.NVarChar),
                             new SqlParameter("Introduction",SqlDbType.NVarChar),
                             new SqlParameter("WorkingPlace",SqlDbType.NVarChar),
                             new SqlParameter("IsPublished",SqlDbType.Int),
                             new SqlParameter("Sort",SqlDbType.Int),
                             new SqlParameter("IsHot",SqlDbType.Int),
                             new SqlParameter("Number",SqlDbType.Int),
                            };
     param[0].Value = model.Id;
     param[1].Value = model.Title ?? string.Empty;
     param[2].Value = model.Introduction ?? string.Empty;
     param[3].Value = model.WorkingPlace ?? string.Empty;
     param[4].Value = model.IsPublished;
     param[5].Value = model.Sort;
     param[6].Value = model.IsHot;
     param[7].Value = model.Number;
     return Goodspeed.Library.Data.SQLPlus.ExecuteNonQuery(CommandType.Text, strSQL, param);
 }
Exemplo n.º 4
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static int Insert(JobInfo model) {
     string strSQL = "INSERT INTO Job(Title,Introduction,WorkingPlace,IsPublished,Sort,IsHot,IsDeleted,CreateDateTime,Number) VALUES(@Title,@Introduction,@WorkingPlace,@IsPublished,@Sort,@IsHot,0,GETDATE(),@Number);SELECT @@IDENTITY;";
     SqlParameter[] param = { 
                             new SqlParameter("Id",SqlDbType.Int),
                             new SqlParameter("Title",SqlDbType.NVarChar),
                             new SqlParameter("Introduction",SqlDbType.NVarChar),
                             new SqlParameter("WorkingPlace",SqlDbType.NVarChar),
                             new SqlParameter("IsPublished",SqlDbType.Int),
                             new SqlParameter("Sort",SqlDbType.Int),
                             new SqlParameter("IsHot",SqlDbType.Int),
                             new SqlParameter("Number",SqlDbType.Int),
                            };
     param[0].Value = model.Id;
     param[1].Value = model.Title ?? string.Empty;
     param[2].Value = model.Introduction ?? string.Empty;
     param[3].Value = model.WorkingPlace ?? string.Empty;
     param[4].Value = model.IsPublished;
     param[5].Value = model.Sort;
     param[6].Value = model.IsHot;
     param[7].Value = model.Number;
     return Convert.ToInt32(Goodspeed.Library.Data.SQLPlus.ExecuteScalar(CommandType.Text,strSQL,param));
 }