public string EditStatus(int?prjDetailId, string fStatus) /*tProjectDetail target*/
        {
            int id = Convert.ToInt32(prjDetailId);
            //int id = target.fProjectDetailId;
            var prjDetail = db.tProjectDetails.Where(p => p.fProjectDetailId == id).FirstOrDefault();

            prjDetail.fStatus = fStatus;
            //prjDetail.fStatus = target.fStatus;
            db.SaveChanges();

            //任務名稱
            var taskName = db.tProjectDetails.Where(p => p.fProjectDetailId == id).FirstOrDefault().fTaskName;
            //案名
            var prjName = db.tProjectDetails.Where(p => p.fProjectDetailId == id).FirstOrDefault().tProject.fProjectName;
            //主管
            var pmId = db.tProjectDetails.Where(p => p.fProjectDetailId == id).FirstOrDefault().tProject.fEmployeeId;
            //訊息
            var content = taskName + "任務已已完成,待請主管驗收";

            //發訊息給主管
            if (prjDetail.fStatus == "待驗收")
            {
                tNotify notify = new tNotify();
                notify.fEmployeeId = pmId;
                notify.fTitle      = prjName;
                notify.fContent    = content;
                notify.fType       = 0;
                notify.fTime       = DateTime.Now;
                db.tNotifies.Add(notify);
                db.SaveChanges();
            }
            return("success");
        }
Esempio n. 2
0
        public string InsertBell(string title, string content)
        {
            HttpCookie cookie = Request.Cookies["id"];
            int        fid    = Convert.ToInt32(cookie.Value);
            tNotify    tn     = new tNotify();

            tn.fContent    = content;
            tn.fTitle      = title;
            tn.fType       = 0;
            tn.fEmployeeId = 100;
            EIP_DBEntities db = new EIP_DBEntities();

            db.tNotifies.Add(tn);
            db.SaveChanges();
            var list = from n in db.tNotifies
                       where n.fEmployeeId == fid
                       select new
            {
                n.fTitle,
                n.fContent,
                n.fType
            };
            string json = JsonConvert.SerializeObject(list);

            return(json);
        }
        //審核工時紀錄
        public ActionResult Edit(int recordId, int approve, string reason)
        {
            var record = db.tTimeRecords.Where(p => p.fTimeRecordId == recordId).FirstOrDefault();
            var task   = db.tProjectDetails.Where(p => p.fProjectDetailId == record.fProjectDetailId).FirstOrDefault();
            var level  = db.tLevels.Where(p => p.fLevelId == task.fLevelId).FirstOrDefault();

            if (approve == 1)
            {
                record.fApprove = "同意";
                //時數存入tProjectDetail
                task.fTimes += record.fTime;
                //人事成本存入tlevel
                level.fSpendCost += record.fTime * 200;
            }

            if (approve == 0)
            {
                record.fApprove = "不同意";
                record.fRemarks = reason;

                //發小鈴鐺訊息給員工
                tNotify notify = new tNotify();
                notify.fEmployeeId = record.fEmployeeId;
                notify.fTitle      = "工時紀錄審查不通過";
                notify.fContent    = "請盡快修正紀錄";
                notify.fType       = 0;
                notify.fTime       = DateTime.Now;
                db.tNotifies.Add(notify);
                db.SaveChanges();
            }

            db.SaveChanges();

            return(Json("success", JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        public string InsertBell(string title, string content, string id)
        {
            int     fid = Convert.ToInt32(id);
            tNotify tn  = new tNotify();

            tn.fContent    = content;
            tn.fTitle      = title;
            tn.fType       = 0;
            tn.fTime       = DateTime.Now;
            tn.fEmployeeId = fid;
            EIP_DBEntities db = new EIP_DBEntities();

            db.tNotifies.Add(tn);
            db.SaveChanges();
            var list = from n in db.tNotifies
                       where n.fEmployeeId == fid
                       select new
            {
                n.fTime,
                n.fTitle,
                n.fContent,
                n.fType
            };
            string json = JsonConvert.SerializeObject(list);

            return(json);
        }
        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");
        }
Esempio n. 6
0
        public void createNotifies(int empId, string title, string content)
        {
            tNotify notify = new tNotify();

            notify.fEmployeeId = empId;
            notify.fTitle      = title;
            notify.fContent    = content;
            notify.fType       = 0;
            notify.fTime       = DateTime.Now;
            db.tNotifies.Add(notify);
            db.SaveChanges();
        }
        public string seal(int[] empid, string reson, string content)
        {
            var b = empid.Distinct();

            foreach (var a in b)
            {
                tNotify notify = new tNotify();
                notify.fEmployeeId = a;
                notify.fTitle      = reson;
                notify.fContent    = content + "請準時出席";
                notify.fType       = 0;
                notify.fTime       = DateTime.Now;
                db.tNotifies.Add(notify);
                db.SaveChanges();
            }
            return("source");
        }
        public ActionResult Acceptance(int prjDetailId, int approve)
        {
            var task = db.tProjectDetails.Where(p => p.fProjectDetailId == prjDetailId).FirstOrDefault();

            if (approve == 1)
            {
                task.fStatus = "驗收完成";

                //發小鈴鐺訊息給負責人
                tNotify notify = new tNotify();
                notify.fEmployeeId = Convert.ToInt32(task.fEmployeeId);
                notify.fTitle      = task.tProject.fProjectName;
                notify.fContent    = task.fTaskName + "任務驗收完成";
                notify.fType       = 0;
                notify.fTime       = DateTime.Now;
                db.tNotifies.Add(notify);
                db.SaveChanges();
            }

            if (approve == 0)
            {
                task.fStatus = "進行中";

                //發小鈴鐺訊息給負責人
                tNotify notify = new tNotify();
                notify.fEmployeeId = Convert.ToInt32(task.fEmployeeId);
                notify.fTitle      = task.tProject.fProjectName;
                notify.fContent    = task.fTaskName + "任務驗收未通過";
                notify.fType       = 0;
                notify.fTime       = DateTime.Now;
                db.tNotifies.Add(notify);
                db.SaveChanges();
            }

            db.SaveChanges();

            int id = task.tProject.fProjectId;

            updateProgress(id);

            return(Json("success", JsonRequestBehavior.AllowGet));
        }