Example #1
0
        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);
            }
        }
Example #2
0
 void updateAccessoryParameters(DbCommand cmd, MeetingAccessory acces, Guid meetingGuid)
 {
     cmd.Parameters[0].Value = acces.AccessoryId;
     cmd.Parameters[1].Value = acces.Url;
     cmd.Parameters[2].Value = meetingGuid;
 }
Example #3
0
        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);
            }
        }