public static bool DeleteProject(ClsProject project) { bool isTrue = false; StringBuilder strBuilder; List <string> listNames; List <SqlDbType> listDBTypes; List <object> listValues; strBuilder = new StringBuilder("DELETE FROM [项目列表] WHERE [项目ID]=@intProjectID"); listNames = new List <string>(); listDBTypes = new List <SqlDbType>(); listValues = new List <object>(); listNames.Add("@intProjectID"); listDBTypes.Add(SqlDbType.Int); listValues.Add(project.intProjectID); try { object obj = EventUpdateTableUsePara(strBuilder.ToString(), listNames, listDBTypes, listValues); isTrue = true; } catch (Exception ex) { throw new Exception("失败", new Exception(ex.Message)); } return(isTrue); }
public int ModifyProject(ClsProject project) { int _intProjectID = 0; StringBuilder strBuilder; List <string> listNames; List <SqlDbType> listDBTypes; List <object> listValues; strBuilder = new StringBuilder("UPDATE [项目列表] SET [项目名称]=@projectName,[创建人]=@testStuff,[备注]=@description WHERE [项目ID]=@intProjectID"); listNames = new List <string>(); listDBTypes = new List <SqlDbType>(); listValues = new List <object>(); listNames.Add("@intProjectID"); listDBTypes.Add(SqlDbType.VarChar); listValues.Add(project.intProjectID); listNames.Add("@projectName"); listDBTypes.Add(@SqlDbType.VarChar); listValues.Add(project.strProjectName); listNames.Add("@testStuff"); listDBTypes.Add(@SqlDbType.VarChar); listValues.Add(project.strProjectBuilder); listNames.Add("@description"); listDBTypes.Add(@SqlDbType.VarChar); listValues.Add(project.description); if (0 == EventUpdateTableUsePara(strBuilder.ToString(), listNames, listDBTypes, listValues)) { throw new Exception("用户信息修改失败"); } try { object obj = EventUpdateTableUsePara(strBuilder.ToString(), listNames, listDBTypes, listValues); _intProjectID = int.Parse(obj.ToString()); project.intProjectID = _intProjectID; } catch (Exception ex) { throw new Exception(ex.Message); } return(_intProjectID); }
public int AddProject(ClsProject project) { int projectID = 0; StringBuilder strBuilder; List <string> listNames; List <SqlDbType> listDBTypes; List <object> listValues; strBuilder = new StringBuilder("INSERT INTO [项目列表]([项目名称],[测试时间],[创建人],[备注])"); strBuilder.Append(" VALUES(@projectName,@testTime,@testStuff,@description);SELECT SCOPE_IDENTITY()"); listNames = new List <string>(); listDBTypes = new List <SqlDbType>(); listValues = new List <object>(); listNames.Add("@projectName"); listDBTypes.Add(@SqlDbType.VarChar); listValues.Add(project.strProjectName); listNames.Add("@testTime"); listDBTypes.Add(@SqlDbType.VarChar); listValues.Add(project.dtpTime); listNames.Add("@testStuff"); listDBTypes.Add(@SqlDbType.VarChar); listValues.Add(project.strProjectBuilder); listNames.Add("@description"); listDBTypes.Add(@SqlDbType.VarChar); listValues.Add(project.description); try { object obj = EventReturnObjectUserPara(strBuilder.ToString(), listNames, listDBTypes, listValues); projectID = int.Parse(obj.ToString()); project.intProjectID = projectID; } catch (Exception ex) { throw new Exception(ex.Message); } return(projectID); }