/// <summary> /// 根据ID查询 /// </summary> /// <param name="projectId">projectId</param> /// Author : Napoleon /// Created : 2015-01-24 10:06:30 public SystemProject GetProjectById(string projectId) { SystemProject project = new SystemProject(); try { string sql = "SELECT * FROM dbo.System_Project WHERE ProjectId=@ProjectId"; project = DbHelper.GetEnumerable<SystemProject>(sql, new { @ProjectId = projectId }); } catch (Exception exception) { Log4Dao.InsertLog4(exception.Message); } return project; }
/// <summary> /// 新增系统 /// </summary> /// Author : Napoleon /// Created : 2015-01-24 09:29:42 public ActionResult SaveAdd(string projectId, string projectName, string remark) { SystemProject project = new SystemProject(); project.ProjectId = projectId; project.ProjectName = projectName; project.Remark = remark; project.Operator = PublicFields.UserCookie.ReadCookie<SystemUser>().UserName; int count = _projectService.InsertProject(project); string status = "failue", msg, json; if (count > 0) { status = "success"; msg = "添加成功!"; } else if (count == 0) { msg = "添加失败!"; } else { msg = "添加失败,该系统代码已经存在,请不要重复添加!"; } json = PublicFunc.ModelToJson(status, msg); return Content(json); }
/// <summary> /// 更新 /// </summary> /// <param name="projectId">The project identifier.</param> /// <param name="projectName">Name of the project.</param> /// <param name="remark">The remark.</param> /// Author : Napoleon /// Created : 2015-01-24 10:37:25 public ActionResult UpdateProject(string projectId, string projectName, string remark) { SystemProject project = new SystemProject(); project.ProjectId = projectId; project.ProjectName = projectName; project.Remark = remark; int count = _projectService.UpdateProject(project); string status = "failue", msg = "更新失败!", json; if (count > 0) { status = "success"; msg = "更新成功!"; } json = PublicFunc.ModelToJson(status, msg); return Content(json); }
/// <summary> /// 新增系统 /// </summary> /// <param name="project">The project.</param> /// Author : Napoleon /// Created : 2015-01-24 09:42:13 public int UpdateProject(SystemProject project) { return _projectDao.UpdateProject(project); }
/// <summary> /// 新增系统 /// </summary> /// <param name="project">The project.</param> /// Author : Napoleon /// Created : 2015-01-24 09:42:13 public int InsertProject(SystemProject project) { return _projectDao.InsertProject(project); }
/// <summary> /// 新增系统 /// </summary> /// <param name="project">The project.</param> /// Author : Napoleon /// Created : 2015-01-24 09:42:13 public int UpdateProject(SystemProject project) { int i; try { string sql = "UPDATE dbo.System_Project SET ProjectName=@projectName,Remark=@remark where ProjectId=@projectId"; i = DbHelper.ExecuteSql(sql, project); } catch (Exception exception) { i = 0; Log4Dao.InsertLog4(exception.Message); } return i; }
/// <summary> /// 新增系统 /// </summary> /// <param name="project">The project.</param> /// Author : Napoleon /// Created : 2015-01-24 09:42:13 public int InsertProject(SystemProject project) { int count; try { string sql = "SELECT * FROM dbo.System_Project WHERE ProjectId=@ProjectId"; SqlParameter[] parameters = { new SqlParameter("@ProjectId", project.ProjectId) }; DataTable dt = DbHelper.GetDataTable(sql, parameters); if (dt.Rows.Count > 0) { count = -1; } else { sql = "INSERT INTO dbo.System_Project ( ProjectId ,ProjectName ,Remark ,Operator) VALUES (@ProjectId,@ProjectName,@Remark,@Operator)"; count = DbHelper.ExecuteSql(sql, project); } } catch (Exception exception) { count = 0; Log4Dao.InsertLog4(exception.Message); } return count; }