示例#1
0
        public int AddProjectInfo(string project, DateTime StartDate, DateTime EndDate, int Priority, int User_ID)
        {
            int newPK = -1;

            using (var context = new ProductDBEntities())
            {
                TblProject Projectinfo = new TblProject()
                {
                    Project   = project,
                    StartDate = StartDate,
                    EndDate   = EndDate,
                    Priority  = Priority,
                };
                context.TblProjects.Add(Projectinfo);
                context.Entry(Projectinfo).State = EntityState.Added;
                context.SaveChanges();
                context.Entry(Projectinfo).GetDatabaseValues();
                //int newPK = Projectinfo.Project_ID;
                newPK = context.TblProjects.Max(p => p.Project_ID);
            }
            UserInfo detailmyuser = GetAllUsersById(User_ID);


            int ret = UpdateUser(User_ID, detailmyuser.FirstName, detailmyuser.LastName, newPK, detailmyuser.Employee_ID, 0);



            return(ret);
        }
示例#2
0
        public int UpdateProjectUserInfo(int ProjectID, string project, DateTime startDate, DateTime endDate, int priority, int userID)
        {
            int Retval = -1;
            ProductDBEntities tstDb    = new ProductDBEntities();
            ProjectInfo       tempProd = new ProjectInfo();;

            tempProd.Project_ID = ProjectID;
            tempProd.Project    = project;
            tempProd.StartDate  = startDate;
            tempProd.EndDate    = endDate;
            tempProd.Project_ID = priority;



            TblProject result = tstDb.TblProjects.SingleOrDefault(b => b.Project_ID == ProjectID);

            if (result != null)
            {
                //result.Project_ID = UserId;
                result.Project            = project;
                result.StartDate          = startDate;
                result.EndDate            = endDate;
                result.Priority           = priority;
                tstDb.Entry(result).State = EntityState.Modified;
                Retval = tstDb.SaveChanges();
            }
            //return Retval;

            TblUser resultuser = tstDb.TblUsers.SingleOrDefault(b => b.User_ID == userID);

            if (resultuser != null)
            {
                resultuser.User_ID = resultuser.User_ID;
                //resultuser.FirstName = resultuser.User_ID;
                //resultuser.LastName = LastName;
                resultuser.Project_ID = ProjectID;
                //resultuser.EmployeeID = Employee_ID;
                //resultuser.Task_ID = TaskID;
                tstDb.Entry(resultuser).State = EntityState.Modified;
                Retval = tstDb.SaveChanges();
            }
            return(Retval);
        }
示例#3
0
        public int DeleteProjectById(int ProjectId)
        {
            int Retval = -1;

            ProductDBEntities tstDb    = new ProductDBEntities();
            TblProject        projInfo = new TblProject();

            projInfo.Project_ID         = ProjectId;
            tstDb.Entry(projInfo).State = EntityState.Deleted;
            Retval = tstDb.SaveChanges();


            TblUser resultuser = tstDb.TblUsers.SingleOrDefault(b => b.Project_ID == ProjectId);

            if (resultuser != null)
            {
                resultuser.User_ID            = resultuser.User_ID;
                resultuser.Project_ID         = 0;
                tstDb.Entry(resultuser).State = EntityState.Modified;
                Retval = tstDb.SaveChanges();
            }
            return(Retval);
        }