//===============新增多筆 ===============================//

        public string demoInsert(int prjId)
        {
            string[] taskName = { "流程圖", "資料庫建置", "介面設計", "訂單系統", "介面整合" };
            int[]    empId    = { 117, 118, 118, 119, 119 };
            int[]    levelId  =
            {
                db.tLevels.Where(p => p.fProjectId == prjId).FirstOrDefault().fLevelId,
                db.tLevels.Where(p => p.fProjectId == prjId).FirstOrDefault().fLevelId,
                db.tLevels.Where(p => p.fProjectId == prjId).OrderBy(P => P.fLevelId).Skip(1).FirstOrDefault().fLevelId,
                db.tLevels.Where(p => p.fProjectId == prjId).OrderBy(P => P.fLevelId).Skip(1).FirstOrDefault().fLevelId,
                db.tLevels.Where(p => p.fProjectId == prjId).OrderBy(P => P.fLevelId).Skip(2).FirstOrDefault().fLevelId
            };

            //DateTime[] startTime = { };
            //DateTime[] deadline = { };

            for (int i = 0; i < 5; i++)
            {
                tProjectDetail prjDetail = new tProjectDetail();
                prjDetail.fProjectId  = prjId;
                prjDetail.fLevelId    = levelId[i];
                prjDetail.fTaskName   = taskName[i];
                prjDetail.fEmployeeId = empId[i];
                prjDetail.fStatus     = "未開始";
                //prjDetail.fStartTime = startTime[i];
                //prjDetail.fDeadline = deadline[i];
                prjDetail.fTimes = 0;
                db.tProjectDetails.Add(prjDetail);
                db.SaveChanges();

                updateProgress(prjId);
            }
            return("success");
        }
        public string Create(tProjectDetail target)
        {
            TempData.Keep();
            var prjId = TempData["prjId"] as int?;

            if (target.fTaskName == null || target.fEmployeeId == null)
            {
                //任務名稱不為空
                return("error");
            }

            tProjectDetail prjDetail = new tProjectDetail();

            prjDetail.fProjectId  = target.fProjectId;
            prjDetail.fLevelId    = target.fLevelId;
            prjDetail.fTaskName   = target.fTaskName;
            prjDetail.fEmployeeId = target.fEmployeeId;
            prjDetail.fStatus     = target.fStatus;
            prjDetail.fStartTime  = target.fStartTime;
            prjDetail.fDeadline   = target.fDeadline;
            prjDetail.fRemarks    = target.fRemarks;
            prjDetail.fTimes      = 0;
            db.tProjectDetails.Add(prjDetail);
            db.SaveChanges();

            updateProgress(prjDetail.fProjectId);

            var startTime = prjDetail.fStartTime;
            var deadline  = prjDetail.fDeadline;

            //發通知給任務負責人
            tNotify notify = new tNotify();

            notify.fEmployeeId = Convert.ToInt32(prjDetail.fEmployeeId);
            notify.fTitle      = prjDetail.tProject.fProjectName;
            notify.fContent    = "請到我的任務查看新任務";
            notify.fType       = 0;
            notify.fTime       = DateTime.Now;
            db.tNotifies.Add(notify);
            db.SaveChanges();

            //存到行事曆上
            tCalendar task = new tCalendar();

            task.fEmployeeId = prjDetail.fEmployeeId;
            task.fStart      = Convert.ToDateTime(startTime).ToString("yyyy-MM-dd");
            task.fEnd        = Convert.ToDateTime(deadline).ToString("yyyy-MM-dd");
            task.fTitle      = db.tProjects.Where(p => p.fProjectId == prjDetail.fProjectId).FirstOrDefault().fProjectName;
            task.fContent    = prjDetail.fTaskName;
            task.fSort       = "1";
            db.tCalendars.Add(task);
            db.SaveChanges();

            return("success");
        }
예제 #3
0
        public string Edit(tProjectDetail target)
        {
            int id        = target.fProjectDetailId;
            var prjDetail = db.tProjectDetails.Where(p => p.fProjectDetailId == id).FirstOrDefault();

            prjDetail.fLevelId    = target.fLevelId;
            prjDetail.fTaskName   = target.fTaskName;
            prjDetail.fEmployeeId = 100;                              //todo:改下拉式選單的員工(tmember)
            prjDetail.fStatus     = target.fStatus;
            prjDetail.fStartTime  = target.fStartTime;
            prjDetail.fDeadline   = target.fDeadline;
            prjDetail.fRemarks    = target.fRemarks;

            db.SaveChanges();
            return("success");
        }
        public string Edit(tProjectDetail target)
        {
            int id        = target.fProjectDetailId;
            var prjDetail = db.tProjectDetails.Where(p => p.fProjectDetailId == id).FirstOrDefault();

            prjDetail.fLevelId    = target.fLevelId;
            prjDetail.fTaskName   = target.fTaskName;
            prjDetail.fEmployeeId = target.fEmployeeId;
            prjDetail.fStatus     = target.fStatus;
            prjDetail.fStartTime  = target.fStartTime;
            prjDetail.fDeadline   = target.fDeadline;
            prjDetail.fRemarks    = target.fRemarks;

            updateProgress(prjDetail.fProjectId);

            db.SaveChanges();
            return("success");
        }
예제 #5
0
        public string Create(tProjectDetail target)
        {
            TempData.Keep();
            var prjId = TempData["prjId"] as int?;

            tProjectDetail prjDetail = new tProjectDetail();

            prjDetail.fProjectId  = target.fProjectId;                //todo:改當前案號
            prjDetail.fLevelId    = target.fLevelId;
            prjDetail.fTaskName   = target.fTaskName;
            prjDetail.fEmployeeId = 100;                              //todo:改下拉式選單的員工(tmember)
            prjDetail.fStatus     = target.fStatus;
            prjDetail.fStartTime  = target.fStartTime;
            prjDetail.fDeadline   = target.fDeadline;
            prjDetail.fRemarks    = target.fRemarks;
            db.tProjectDetails.Add(prjDetail);
            db.SaveChanges();

            updateProgress(prjDetail.fProjectId);

            return("success");
        }