Example #1
0
        public IActionResult Edit(CInterviewEditViewModel I)
        {
            if (I != null)
            {
                TInterView table = myHR.TInterViews.Where(n => n.CInterVieweeId == I.CInterVieweeId).FirstOrDefault();
                if (table != null)
                {
                    table.CInterVieweeName   = I.CInterVieweeName;
                    table.CInterViewStatusId = int.Parse(I.CStatus);
                    myHR.SaveChanges();
                }
            }

            // 如果狀態為待報到 跳至新增帳號頁面
            if (int.Parse(I.CStatus) == 3)
            {
                var interviewer = myHR.TInterViews.Where(n => n.CInterVieweeId == I.CInterVieweeId).FirstOrDefault();
                //HttpContext.Session.SetObject<TInterView>(CDictionary.Register_User, interviewer);
                TempData.Put("Register", interviewer);
                AddNoti(1, "新人報到通知", $"貴部門 {interviewer.CInterVieweeName} 確認報到,已發送報到通知。");
                return(RedirectToAction("register", "employee"));
            }

            TempData["Id"] = I.CInterVieweeId;

            return(RedirectToAction("List"));
        }
Example #2
0
 public IActionResult Delete(int?Id)
 {
     if (Id != null)
     {
         TInterView I = myHR.TInterViews.FirstOrDefault(n => n.CInterVieweeId == Id);
         if (I != null)
         {
             myHR.TInterViews.Remove(I);
             myHR.SaveChanges();
         }
     }
     return(RedirectToAction("List"));
 }
Example #3
0
 public IActionResult Edit(int?Id)
 {
     if (Id != null)
     {
         List <TInterViewStatus> status = GetStatus();  //從資料庫抓下拉式選單
         ViewBag.Status = status;
         TInterView I = myHR.TInterViews.FirstOrDefault(n => n.CInterVieweeId == Id);
         if (I != null)
         {
             ViewBag.CurrentStatus = I.CInterViewStatusId;
             return(PartialView("Edit", new CInterviewListViewModel(I)));
         }
     }
     return(RedirectToAction("List"));
 }
Example #4
0
 public CInterviewListViewModel()
 {
     iv_interview = new TInterView();
 }
Example #5
0
 public CInterviewListViewModel(TInterView i)
 {
     iv_interview = i;
 }
        public IActionResult register(TUserViewModel _user)
        {
            ViewBag.CDepartmentId = db.TUserDepartments.ToList();
            ViewBag.CJobTitleId   = db.TUserJobTitles.ToList();

            //新增員工
            db.TUsers.Add(_user.tuserVM);
            db.SaveChanges();

            //給面試要報到的人employeeId
            int        id    = db.TUsers.Where(n => n.CEmployeeName == _user.CEmployeeName).Select(n => n.CEmployeeId).FirstOrDefault();
            TInterView table = db.TInterViews.Where(n => n.CEmployeeEnglishName == _user.CEmployeeEnglishName).FirstOrDefault();

            if (table != null)
            {
                table.CInterViewerEmployeeId = id;
                db.SaveChanges();
            }

            //開始寄信
            int    userid   = db.TUsers.OrderByDescending(n => n.CEmployeeId).Select(c => c.CEmployeeId).FirstOrDefault();        //撈取新註冊的員工ID
            string name     = db.TUsers.Where(n => n.CEmployeeId == userid).Select(c => c.CEmployeeName).FirstOrDefault();        //撈取新註冊的員工NAME
            string email    = db.TUsers.Where(n => n.CEmployeeId == userid).Select(c => c.CEmail).FirstOrDefault();               //撈取新註冊的員工EMAIL
            string password = db.TUsers.Where(n => n.CEmployeeId == userid).Select(c => c.CPassWord).FirstOrDefault();            //撈取新註冊的員工PASSWORD
            string english  = db.TUsers.Where(n => n.CEmployeeId == userid).Select(c => c.CEmployeeEnglishName).FirstOrDefault(); //撈取新註冊的員工PASSWORD

            try
            {
                System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();


                msg.To.Add(email);

                msg.From = new MailAddress("*****@*****.**", "HELLOWORK公司", System.Text.Encoding.UTF8);
                /* 上面3個參數分別是發件人地址,發件人姓名,編碼*/
                msg.Subject         = "錄取報到通知";                  //郵件標題
                msg.SubjectEncoding = System.Text.Encoding.UTF8; //郵件標題編碼
                                                                 //郵件內容
                msg.Body  = name + "  您好," + Environment.NewLine;
                msg.Body += "您已錄取本公司,請至公司官網報到啟用帳號。" + Environment.NewLine;
                msg.Body += "登入帳號:" + userid + Environment.NewLine;
                msg.Body += "英文姓名:" + english + Environment.NewLine;
                msg.Body += "密碼:" + password + Environment.NewLine;
                //郵件內容
                msg.BodyEncoding = System.Text.Encoding.UTF8;                    //郵件內容編碼
                /*     msg.Attachments.Add(new Attachment(@"D:\test2.docx")); */ //附件
                msg.IsBodyHtml = true;                                           //是否是HTML郵件
                                                                                 //msg.Priority = MailPriority.High;//郵件優先級

                SmtpClient client = new SmtpClient();
                client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "izougqdehrjrufoh"); //這裡要填正確的帳號跟密碼
                client.Host        = "smtp.gmail.com";                                                                   //設定smtp Server
                client.Port        = 25;                                                                                 //設定Port
                client.EnableSsl   = true;                                                                               //gmail預設開啟驗證
                client.Send(msg);                                                                                        //寄出信件
                client.Dispose();
                msg.Dispose();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }


            return(RedirectToAction("employeeList"));
        }