Exemplo n.º 1
0
        public ActionResult Edit(string UId)
        {
            //初始化系統參數
            Configer.Init();

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

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

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

            try
            {
                vEPSUSER_Manage VUM = new vEPSUSER_Manage();
                EPSUSER         U   = context.EPSUSERS.Find(UId);

                VUM.UId       = UId;
                VUM.UserName  = U.UserName;
                VUM.UserPwd   = U.UserPwd;
                VUM.UserEmail = U.UserEmail;
                VUM.RId       = U.RId;

                var query = from r in context.EPSROLES
                            select new
                {
                    r.RId,
                    r.RoleName
                };
                VUM.Role        = new SelectList(query, "RId", "RoleName");
                SL.EndDateTime  = DateTime.Now;
                SL.TotalCount   = 1;
                SL.SuccessCount = 1;
                SL.FailCount    = 0;
                SL.Result       = true;
                SL.Msg          = "取得使用者資料作業成功,UId:[" + UId + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return(View(VUM));
            }
            catch (Exception ex)
            {
                SL.EndDateTime  = DateTime.Now;
                SL.TotalCount   = 0;
                SL.SuccessCount = 0;
                SL.FailCount    = 0;
                SL.Result       = false;
                SL.Msg          = "取得使用者資料作業失敗," + "錯誤訊息[" + ex.ToString() + "]";
                SF.log2DB(SL, MailServer, MailServerPort, MailSender, MailReceiver);

                return(RedirectToAction("Create", "Account"));
            }
        }
Exemplo n.º 2
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 }));
            }
        }