void UpdateMeetingParameters(DatabaseAccess dba, DbCommand cmd, ProjectMeetingSummary meetingSum) { dba.AddInParameter(cmd, "MeetingId", DbType.Guid, meetingSum.MeetingId); dba.AddInParameter(cmd, "StartTime", DbType.DateTime, meetingSum.StartTime); dba.AddInParameter(cmd, "Content", DbType.String, meetingSum.Content); dba.AddInParameter(cmd, "Result", DbType.String, meetingSum.Result); dba.AddInParameter(cmd, "CreateUser", DbType.String, UserContext.CurrentUser.RealName); dba.AddInParameter(cmd, "CreateTime", DbType.DateTime, DateTime.Now); }
public bool updateProjectMeeting(ProjectMeetingSummary meetingSum, Guid ProjectId, List <Guid> empGuids, List <string> empNames, List <string> acces) { using (TeamDBContext context = new TeamDBContext()) { DatabaseAccess dba = context.DatabaseAccess(); DbCommand meetingCmd = dba.CreateCommand("UPDATE ProjectMeetingSummarys SET StartTime =@StartTime, Content=@Content, Result=@Result,CreateUser=@CreateUser,CreateTime=@CreateTime WHERE MeetingId = @MeetingId"); DbCommand empDelCmd = dba.CreateCommand("DELETE FROM ProjectMeetingEmployees WHERE MeetingId =@MeetingId"); DbCommand empCmd = dba.CreateCommand("INSERT INTO ProjectMeetingEmployees VALUES (@MettingEmployeeId, @EmployeeName, @MeetingId, @EmployeeId)"); DbCommand accesCmd = dba.CreateCommand("INSERT INTO MeetingAccessory VALUES (@AccessoryId, @Url, @MeetingId)"); DbCommand accesDelCmd = dba.CreateCommand("DELETE FROM MeetingAccessory WHERE MeetingId =@MeetingId "); int num = 0; int i = 0; using (var tran = dba.BeginTransaction()) { ProjectMeetingEmployee pEmp = null; MeetingAccessory meetingAcces = null; UpdateMeetingParameters(dba, meetingCmd, meetingSum); num += dba.ExecuteNonQuery(meetingCmd); dba.AddInParameter(empDelCmd, "MeetingId", meetingSum.MeetingId); dba.ExecuteNonQuery(empDelCmd); if (empGuids != null && empGuids.Count() > 0) { AddEmployeeParameters(dba, empCmd); for (; i < empGuids.Count(); i++) { pEmp = new ProjectMeetingEmployee(); pEmp.MettingEmployeeId = Guid.NewGuid(); pEmp.EmployeeName = empNames[i]; updateEmployeeParameters(empCmd, pEmp, empGuids[i], meetingSum.MeetingId); num += dba.ExecuteNonQuery(empCmd); } } dba.AddInParameter(accesDelCmd, "MeetingId", meetingSum.MeetingId); dba.ExecuteNonQuery(accesDelCmd); if (acces != null && acces.Count() > 0) { AddAccessoryParameters(dba, accesCmd); for (i = 0; i < acces.Count(); i++) { meetingAcces = new MeetingAccessory(); meetingAcces.AccessoryId = Guid.NewGuid(); meetingAcces.Url = acces[i]; updateAccessoryParameters(accesCmd, meetingAcces, meetingSum.MeetingId); num += dba.ExecuteNonQuery(accesCmd); } } tran.Complete(); } return(num > 0); } }
void AddMeetingParameters(DatabaseAccess dba, DbCommand cmd, ProjectMeetingSummary meetingSum) { dba.AddInParameter(cmd, "MeetingId", DbType.Guid, meetingSum.MeetingId); dba.AddInParameter(cmd, "StartTime", DbType.DateTime, meetingSum.StartTime); dba.AddInParameter(cmd, "Content", DbType.String, meetingSum.Content); // dba.AddInParameter(cmd, "MeetingTypeId", DbType.String, meetingSum.MeetingTypeId); dba.AddInParameter(cmd, "Result", DbType.String, meetingSum.Result); dba.AddInParameter(cmd, "CreateUser", DbType.String, meetingSum.CreateUser); dba.AddInParameter(cmd, "CreateTime", DbType.DateTime, meetingSum.CreateTime); dba.AddInParameter(cmd, "ProjectId", DbType.Guid, meetingSum.Project.ProjectId); // dba.AddInParameter(cmd, "AccessoryId", DbType.String, meetingSum.Accessory); }
public ActionResult SaveProjectMeetingDatas(ProjectMeetingSummary pms, Guid ProjectId, List <Guid> empGuidList, List <string> empNameList, List <string> AccesList) { ProjectLogic logic = new ProjectLogic(); bool result = false; if (pms.MeetingId == null || pms.MeetingId == Guid.Empty) { result = logic.saveProjectMeeting(pms, ProjectId, empGuidList, empNameList, AccesList); } else { result = logic.updateProjectMeeting(pms, ProjectId, empGuidList, empNameList, AccesList); } return(Json(result)); }
public bool saveProjectMeeting(ProjectMeetingSummary meetingSum, Guid ProjectId, List <Guid> empGuids, List <string> empNames, List <string> acces) { using (TeamDBContext context = new TeamDBContext()) { DatabaseAccess dba = context.DatabaseAccess(); DbCommand meetingCmd = dba.CreateCommand("INSERT INTO ProjectMeetingSummarys VALUES (@MeetingId, @StartTime, @Content, null, @Result, @CreateUser, @CreateTime, @ProjectId, null)"); DbCommand empCmd = dba.CreateCommand("INSERT INTO ProjectMeetingEmployees VALUES (@MettingEmployeeId, @EmployeeName, @MeetingId, @EmployeeId)"); DbCommand accesCmd = dba.CreateCommand("INSERT INTO MeetingAccessory VALUES (@AccessoryId, @Url, @MeetingId)"); int num = 0; int i = 0; Project pro = null; if (ProjectId != null && ProjectId != Guid.Empty) { pro = (from p in context.Projects where p.ProjectId == ProjectId select p).Single(); } using (var tran = dba.BeginTransaction()) { ProjectMeetingEmployee pEmp = null; MeetingAccessory meetingAcces = null; meetingSum.Project = pro; meetingSum.CreateTime = DateTime.Now; meetingSum.CreateUser = UserContext.CurrentUser.UserName; if (meetingSum.MeetingId == Guid.Empty) { meetingSum.MeetingId = Guid.NewGuid(); } AddMeetingParameters(dba, meetingCmd, meetingSum); num += dba.ExecuteNonQuery(meetingCmd); if (empGuids != null && empGuids.Count() > 0) { AddEmployeeParameters(dba, empCmd); for (; i < empGuids.Count(); i++) { pEmp = new ProjectMeetingEmployee(); pEmp.MettingEmployeeId = Guid.NewGuid(); pEmp.EmployeeName = empNames[i]; updateEmployeeParameters(empCmd, pEmp, empGuids[i], meetingSum.MeetingId); num += dba.ExecuteNonQuery(empCmd); } } if (acces != null && acces.Count() > 0) { AddAccessoryParameters(dba, accesCmd); for (i = 0; i < acces.Count(); i++) { meetingAcces = new MeetingAccessory(); meetingAcces.AccessoryId = Guid.NewGuid(); meetingAcces.Url = acces[i]; updateAccessoryParameters(accesCmd, meetingAcces, meetingSum.MeetingId); num += dba.ExecuteNonQuery(accesCmd); } } tran.Complete(); } return(num > 0); } }