Beispiel #1
0
        public ActionResult Edit(FormCollection form)
        {
            EmpService service = new EmpService();
            Employee   emp     = new Employee();
            var        result  = false;

            emp.EmpId    = form["EmpId"];
            emp.EmpName  = form["EmpName"];
            emp.Ext      = form["Ext"];
            emp.DepId    = form["DepId"];
            emp.Birthday = Convert.ToDateTime(form["Birthday"]);
            emp.ID       = string.IsNullOrEmpty(form["ID"]) ? 0 : Convert.ToInt64(form["ID"]);
            try
            {
                if (emp.ID > 0)
                {
                    result = service.EditEmployee(emp);
                }
                else
                {
                    result = service.AddNewEmployee(emp);
                }
            }
            catch (Exception ex)
            {
                //可以處理要給前端的錯誤訊息/紀錄錯誤log
                throw ex;
            }

            return(RedirectToAction("Inquiry", "Emp"));
            //return View();
        }