Пример #1
0
 public IActionResult Edit(int id, [Bind("VendorID, VendorCode, VendorName")] Vendor vendor)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _context.Entry(vendor).State = EntityState.Modified;
             _context.SaveChanges();
             ViewBag.Message = "Vendor " + vendor.VendorName + " successfully updated.";
             return(RedirectToAction("Index", "Users"));
         }
         catch (Exception e)
         {
             _logger.LogError("LineItemsController.Edit Error:" + e.GetBaseException());
             Log.Error("LineItemsController.Edit  Error:" + e.GetBaseException() + "\n" + e.StackTrace);
             ViewBag.Message = "No Vendor updated.";
             return(RedirectToAction("Index", "Users"));
         }
     }
     else
     {
         ViewBag.Message = "No Vendor updated.";
         return(RedirectToAction("Index", "Users"));
     }
 }
Пример #2
0
        public ActionResult Edit(vFUNC_Manage VFM)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();

            SL.UId           = Session["UserID"].ToString();
            SL.Controller    = "Fun";
            SL.Action        = "Edit";
            SL.TotalCount    = 1;
            SL.StartDateTime = DateTime.Now;

            string        MailServer     = Configer.MailServer;
            int           MailServerPort = Configer.MailServerPort;
            string        MailSender     = Configer.MailSender;
            List <string> MailReceiver   = Configer.MailReceiver;

            try
            {
                FUNC F = context.FUNCS.Find(VFM.SN);
                F.FuncName      = VFM.FuncName;
                F.Controller    = VFM.Controller;
                F.Action        = VFM.Action;
                F.Url           = VFM.Url;
                F.PId           = VFM.PId;
                F.ShowOrder     = VFM.ShowOrder;
                F.IsEnable      = VFM.IsEnable;
                F.UpadteAccount = Session["UserID"].ToString().Trim();
                F.UpdateTime    = DateTime.Now;

                context.Entry(F).State = EntityState.Modified;
                context.SaveChanges();

                SL.EndDateTime  = DateTime.Now;
                SL.SuccessCount = 1;
                SL.FailCount    = 0;
                SL.Result       = true;
                SL.Msg          = "編輯功能作業成功,FId:[" + VFM.FId.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return(RedirectToAction("Index", "Fun"));
            }
            catch (Exception ex)
            {
                SL.EndDateTime  = DateTime.Now;
                SL.TotalCount   = 1;
                SL.SuccessCount = 0;
                SL.FailCount    = 1;
                SL.Result       = false;
                SL.Msg          = "編輯功能作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                TempData["EditMsg"] = "<script>alert('發生異常');</script>";

                return(RedirectToAction("Edit", "Fun", new { SN = VFM.SN }));
            }
        }
Пример #3
0
 public ActionResult Edit([Bind(Include = "MSAlias,WSAlias,ChineseName,EnglishName,DateofBirth,Major,OnBoardDate,OM,Group,Lob,Product")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(employee));
 }
Пример #4
0
 public ActionResult Edit([Bind(Include = "ID,Name,Type,Level,ParentID")] Skill skill)
 {
     if (ModelState.IsValid)
     {
         db.Entry(skill).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(skill));
 }
Пример #5
0
        public ActionResult Edit(vEPSUSER_Manage VUM)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();

            SL.UId           = Session["UserID"].ToString();
            SL.Controller    = "Account";
            SL.Action        = "Create";
            SL.TotalCount    = 1;
            SL.StartDateTime = DateTime.Now;

            string        MailServer     = Configer.MailServer;
            int           MailServerPort = Configer.MailServerPort;
            string        MailSender     = Configer.MailSender;
            List <string> MailReceiver   = Configer.MailReceiver;

            try
            {
                if (ModelState.IsValid)
                {
                    EPSUSER U = context.EPSUSERS.Find(VUM.UId);
                    U.UserPwd              = VUM.UserPwd;
                    U.UserEmail            = VUM.UserEmail;
                    U.RId                  = VUM.RId;
                    U.UpadteAccount        = Session["UserID"].ToString().Trim();
                    U.UpdateTime           = DateTime.Now;
                    context.Entry(U).State = EntityState.Modified;
                    context.SaveChanges();

                    SL.EndDateTime  = DateTime.Now;
                    SL.TotalCount   = 1;
                    SL.SuccessCount = 1;
                    SL.FailCount    = 0;
                    SL.Result       = true;
                    SL.Msg          = "編輯使用者資料作業成功,UId:[" + VUM.UId + "]";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    //TempData["EditMsg"] = "<script>alert('編輯成功');</script>";

                    return(RedirectToAction("Index", "Account"));
                }
                else
                {
                    TempData["EditMsg"] = "<script>alert('編輯失敗');</script>";

                    return(RedirectToAction("Edit", "Account", new { UId = VUM.UId }));
                }
            }
            catch (Exception ex)
            {
                SL.EndDateTime  = DateTime.Now;
                SL.TotalCount   = 1;
                SL.SuccessCount = 0;
                SL.FailCount    = 1;
                SL.Result       = false;
                SL.Msg          = "編輯使用者作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                TempData["EditMsg"] = "<script>alert('發生異常');</script>";

                return(RedirectToAction("Edit", "Account", new { UId = VUM.UId }));
            }
        }
Пример #6
0
        public ActionResult Edit(vEPSROLE_Manage VRM)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();

            SL.UId           = Session["UserID"].ToString();
            SL.Controller    = "Role";
            SL.Action        = "Edit";
            SL.TotalCount    = 1;
            SL.StartDateTime = DateTime.Now;

            string        MailServer     = Configer.MailServer;
            int           MailServerPort = Configer.MailServerPort;
            string        MailSender     = Configer.MailSender;
            List <string> MailReceiver   = Configer.MailReceiver;

            try
            {
                EPSROLE R = context.EPSROLES.Find(VRM.RId);
                R.RoleName      = VRM.RoleName;
                R.UpadteAccount = Session["UserID"].ToString().Trim();
                R.UpdateTime    = DateTime.Now;
                //取得目前角色擁有的權限
                var query1 = from rm in context.ROLEFUNCMAPPINGS
                             where rm.RId == VRM.RId
                             select new
                {
                    rm.FId
                };
                List <int> TmpList = new List <int>();
                foreach (var item in query1)
                {
                    TmpList.Add(item.FId);
                }

                //取得新增清單
                var addResultList = VRM.FuncList.Except(TmpList);
                //取得移除清單
                var delResultList = TmpList.Except(VRM.FuncList);

                //新增權限作業
                if (addResultList != null)
                {
                    foreach (var item in addResultList)
                    {
                        ROLEFUNCMAPPING RM = new ROLEFUNCMAPPING();
                        RM.RId           = VRM.RId;
                        RM.FId           = item;
                        RM.CreateAccount = Session["UserID"].ToString().Trim();
                        RM.CreateTime    = DateTime.Now;
                        RM.UpadteAccount = Session["UserID"].ToString().Trim();
                        RM.UpdateTime    = DateTime.Now;

                        context.ROLEFUNCMAPPINGS.Add(RM);
                        context.SaveChanges();
                    }
                }

                //移除權限作業
                if (delResultList != null)
                {
                    foreach (var item in delResultList)
                    {
                        ROLEFUNCMAPPING RM = context.ROLEFUNCMAPPINGS.Where(b => b.RId == VRM.RId)
                                             .Where(b => b.FId == item)
                                             .First();
                        context.Entry(RM).State = EntityState.Deleted;
                        context.SaveChanges();
                    }
                }

                context.Entry(R).State = EntityState.Modified;
                context.SaveChanges();

                SL.EndDateTime  = DateTime.Now;
                SL.SuccessCount = 1;
                SL.FailCount    = 0;
                SL.Result       = true;
                SL.Msg          = "編輯角色作業成功,RId:[" + VRM.RId.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return(RedirectToAction("Index", "Role"));
            }
            catch (Exception ex)
            {
                SL.EndDateTime  = DateTime.Now;
                SL.TotalCount   = 1;
                SL.SuccessCount = 0;
                SL.FailCount    = 1;
                SL.Result       = false;
                SL.Msg          = "編輯角色作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                TempData["EditMsg"] = "<script>alert('發生異常');</script>";

                return(RedirectToAction("Edit", "Role", new { RId = VRM.RId }));
            }
        }
Пример #7
0
        /// <summary>
        /// 項目檢核
        /// </summary>
        /// <param name="CheckSN">日常檢核件編號</param>
        /// <param name="CheckID">機房檢核項目ID</param>
        /// <param name="ListID">檢核項目ID</param>
        /// <param name="CheckResult">檢核結果</param>
        /// <param name="CheckDate">檢核日期</param>
        /// <param name="ShiftID">班別</param>
        /// <returns></returns>
        public string Check(string CheckSN, int CheckID,
                            int ListID, string CheckResult,
                            string CheckDate, string Shift)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();

            SL.UId           = Session["UserID"].ToString();
            SL.Controller    = "Process";
            SL.Action        = "GetProcess";
            SL.StartDateTime = DateTime.Now;

            string        MailServer     = Configer.MailServer;
            int           MailServerPort = Configer.MailServerPort;
            string        MailSender     = Configer.MailSender;
            List <string> MailReceiver   = Configer.MailReceiver;

            try
            {
                string Title     = context.CHECKTITLES.Find(CheckID).Title;
                string CheckName = context.CHECKLISTS.Find(ListID).Definition;

                CHECKLIST CL = context.CHECKLISTS.Find(ListID);

                if (CL.ShiftID == "00")
                {
                    Shift = "00";
                }

                //檢查CHECKPROCESS有沒有資料
                var query = context.CHECKPROCESSDETAILS.Where(b => b.ListID == ListID)
                            .Where(b => b.CheckSN == CheckSN)
                            .Where(b => b.CheckID == CheckID)
                            .Where(b => b.CheckDate == CheckDate)
                            .Where(b => b.ShiftID == Shift);

                if (query.Count() > 0)
                {
                    //update CHECKPROCESSDETAILS
                    CHECKPROCESSDETAIL CPD = context.CHECKPROCESSDETAILS.Where(b => b.ListID == ListID)
                                             .Where(b => b.CheckSN == CheckSN)
                                             .Where(b => b.CheckID == CheckID)
                                             .Where(b => b.CheckDate == CheckDate)
                                             .Where(b => b.ShiftID == Shift).First();

                    CPD.CheckResult          = CheckResult;
                    CPD.UpadteAccount        = Session["UserID"].ToString().Trim();
                    CPD.UpdateTime           = DateTime.Now;
                    context.Entry(CPD).State = EntityState.Modified;
                    context.SaveChanges();

                    SL.EndDateTime  = DateTime.Now;
                    SL.TotalCount   = 1;
                    SL.SuccessCount = 1;
                    SL.FailCount    = 0;
                    SL.Result       = false;
                    SL.Msg          = "[" + CheckSN + "]檢核[" + Title + "][" + CheckName + "]作業成功";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    return("檢核成功");
                }
                else
                {
                    //insert CHECKPROCESSDETAILS
                    CHECKPROCESSDETAIL newCPD = new CHECKPROCESSDETAIL();
                    newCPD.CheckSN       = CheckSN;
                    newCPD.CheckID       = CheckID;
                    newCPD.ListID        = ListID;
                    newCPD.ShiftID       = Shift;
                    newCPD.CheckDate     = CheckDate;
                    newCPD.CheckResult   = CheckResult;
                    newCPD.CreateAccount = Session["UserID"].ToString().Trim();
                    newCPD.CreateTime    = DateTime.Now;
                    newCPD.UpadteAccount = Session["UserID"].ToString().Trim();
                    newCPD.UpdateTime    = DateTime.Now;

                    context.CHECKPROCESSDETAILS.Add(newCPD);
                    context.SaveChanges();

                    SL.EndDateTime  = DateTime.Now;
                    SL.TotalCount   = 1;
                    SL.SuccessCount = 1;
                    SL.FailCount    = 0;
                    SL.Result       = false;
                    SL.Msg          = "[" + CheckSN + "]檢核[" + Title + "][" + CheckName + "]作業成功";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    return("檢核成功");
                }
            }
            catch (Exception ex)
            {
                SL.EndDateTime  = DateTime.Now;
                SL.TotalCount   = 0;
                SL.SuccessCount = 0;
                SL.FailCount    = 0;
                SL.Result       = false;
                SL.Msg          = "[" + CheckSN + "]檢核流程作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return("檢核失敗");
            }
        }
Пример #8
0
        /// <summary>
        /// 簽核
        /// </summary>
        /// <param name="CheckSNs"></param>
        /// <param name="CheckDates"></param>
        /// <param name="SignedData"></param>
        /// <returns></returns>
        public string Confirm(List <string> CheckSNs, List <string> CheckDates, string SignedData)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();

            SL.UId           = Session["UserID"].ToString();
            SL.Controller    = "Review";
            SL.Action        = "Confirm";
            SL.StartDateTime = DateTime.Now;

            string UId = Session["UserID"].ToString();

            string        MailServer     = Configer.MailServer;
            int           MailServerPort = Configer.MailServerPort;
            string        MailSender     = Configer.MailSender;
            List <string> MailReceiver   = Configer.MailReceiver;

            int  TotalCount   = 0;
            int  SuccessCount = 0;
            int  FailCount    = 0;
            bool ReviewOK     = true;

            try
            {
                string CloseStutus = "";
                TotalCount = CheckSNs.Count();
                foreach (var item in CheckSNs)
                {
                    CHECKPROCESS CP = context.CHECKPROCESSES.Find(item);

                    if (CP != null)
                    {
                        //update CHECKPROCESSES
                        EPSUSER U    = context.EPSUSERS.Find(UId);
                        int     Role = U.RId;// int.Parse(UId);

                        switch (Role)
                        {
                        //機房領班
                        case 3:
                            CP.ShiftTop     = U.UserName;
                            CP.ShiftTopSign = SignedData;
                            CP.CloseStutus  = "領班覆核完畢";
                            CloseStutus     = "領班覆核完畢";
                            break;

                        //主管
                        case 4:
                            CP.ManageOne     = U.UserName;
                            CP.ManageOneSign = SignedData;
                            CP.CloseStutus   = "主管覆核完畢";
                            CloseStutus      = "主管覆核完畢";
                            break;

                        //系統部主管
                        case 5:
                            CP.ManageTop     = U.UserName;
                            CP.ManageTopSign = SignedData;
                            CP.CloseStutus   = "已結案";
                            CloseStutus      = "已結案";
                            break;
                        }

                        CP.UpadteAccount        = UId;
                        CP.UpdateTime           = DateTime.Now;
                        context.Entry(CP).State = EntityState.Modified;
                        context.SaveChanges();
                        SuccessCount += 1;

                        SL.EndDateTime  = DateTime.Now;
                        SL.TotalCount   = 1;
                        SL.SuccessCount = 1;
                        SL.FailCount    = 0;
                        SL.Result       = false;
                        SL.Msg          = "覆核[" + item + "]作業成功";
                        SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                    }
                    else
                    {
                        FailCount      += 1;
                        ReviewOK        = false;
                        SL.EndDateTime  = DateTime.Now;
                        SL.TotalCount   = 1;
                        SL.SuccessCount = 0;
                        SL.FailCount    = 1;
                        SL.Result       = false;
                        SL.Msg          = "覆核[" + item + "]作業失敗,查無檢核流程資料";
                        SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);
                    }
                }

                if (ReviewOK)
                {
                    //通知下一位負責人,已結案則通知機房領班、機房主管、系統部主管
                    if (CloseStutus == "已結案")
                    {
                        SF.emailNotify2ClosebyDate(CloseStutus, UId,
                                                   CheckDates[0].ToString(), CloseStutus);
                    }
                    else
                    {
                        SF.emailNotify2ReviewbyDate(CloseStutus, UId,
                                                    CheckDates[0].ToString(), "覆核");
                    }
                    SL.EndDateTime  = DateTime.Now;
                    SL.TotalCount   = TotalCount;
                    SL.SuccessCount = SuccessCount;
                    SL.FailCount    = 0;
                    SL.Result       = false;
                    SL.Msg          = "[" + CheckDates[0].ToString() + "]覆核作業成功";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    return("全部覆核成功");
                }
                else
                {
                    SL.EndDateTime  = DateTime.Now;
                    SL.TotalCount   = TotalCount;
                    SL.SuccessCount = SuccessCount;
                    SL.FailCount    = 0;
                    SL.Result       = false;
                    SL.Msg          = "[" + CheckDates[0].ToString() + "]覆核作業失敗";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    return("有" + FailCount.ToString() + "筆資料覆核失敗");
                }
            }
            catch (Exception ex)
            {
                ReviewOK        = false;
                SL.EndDateTime  = DateTime.Now;
                SL.TotalCount   = CheckSNs.Count();
                SL.SuccessCount = 0;
                SL.FailCount    = CheckSNs.Count();
                SL.Result       = false;
                SL.Msg          = "覆核作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return("覆核發生異常");
            }
        }
Пример #9
0
        public ActionResult EditItem(vCHECKLIST_Manage VCLM)
        {
            //初始化系統參數
            Configer.Init();

            //Log記錄用
            SYSTEMLOG SL = new SYSTEMLOG();

            SL.UId           = Session["UserID"].ToString();
            SL.Controller    = "Document";
            SL.Action        = "EditItem";
            SL.StartDateTime = DateTime.Now;

            string        MailServer     = Configer.MailServer;
            int           MailServerPort = Configer.MailServerPort;
            string        MailSender     = Configer.MailSender;
            List <string> MailReceiver   = Configer.MailReceiver;

            try
            {
                if (ModelState.IsValid)
                {
                    CHECKLIST nowCL = context.CHECKLISTS.Find(VCLM.ListID);
                    //nowCL.ListID = CL.ListID;
                    nowCL.CheckID       = VCLM.CheckID;
                    nowCL.ListName      = VCLM.ListName;
                    nowCL.Definition    = VCLM.Definition;
                    nowCL.StartTime     = VCLM.StartTime;
                    nowCL.EndTime       = VCLM.EndTime;
                    nowCL.ShiftID       = VCLM.ShiftID;
                    nowCL.ClassID       = VCLM.ClassID;
                    nowCL.CheckType     = VCLM.CheckType;
                    nowCL.AlwaysShow    = VCLM.AlwaysShow;
                    nowCL.ChargerID     = VCLM.ChargerID;
                    nowCL.ShowOrder     = VCLM.ShowOrder;
                    nowCL.UpadteAccount = Session["UserID"].ToString().Trim();;
                    nowCL.UpdateTime    = DateTime.Now;

                    context.Entry(nowCL).State = EntityState.Modified;
                    context.SaveChanges();

                    SL.EndDateTime  = DateTime.Now;
                    SL.TotalCount   = 1;
                    SL.SuccessCount = 1;
                    SL.FailCount    = 0;
                    SL.Result       = true;
                    SL.Msg          = "編輯檢核項目作業成功,ListID:[" + VCLM.ListID + "]";
                    SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                    //string Title = context.CHECKTITLES.Find(VCLM.CheckID).Title;

                    return(RedirectToAction("ListItem", "Document", new { CheckID = VCLM.CheckID, Title = VCLM.CheckTitle }));
                }
                else
                {
                    TempData["EditMsg"] = "<script>alert('編輯失敗');</script>";

                    return(RedirectToAction("EditItem", "Document", new { ListID = VCLM.ListID }));
                }
            }
            catch (Exception ex)
            {
                SL.EndDateTime  = DateTime.Now;
                SL.TotalCount   = 1;
                SL.SuccessCount = 0;
                SL.FailCount    = 1;
                SL.Result       = false;
                SL.Msg          = "編輯檢核項目作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                TempData["EditMsg"] = "<script>alert('發生異常');</script>";

                return(RedirectToAction("EditItem", "Document", new { ListID = VCLM.ListID }));
            }
        }