Beispiel #1
0
        public ActionResult CreateEmployee(Employees eEmployees)
        {
            string message = "";

            if (ModelState.IsValid)
            {
                try
                {
                    DataTable dtGender = General.GetGender();
                    ViewData["Gender"] = General.DataTableToSelectList(dtGender, "Value", "Text", "0", TopEmptyItem: new SelectListItem {
                        Value = "0", Text = ""
                    });

                    EmployeesBI.SaveEmployees(ref eEmployees);
                    message = FASM_Msg.SuccessfulSaved;

                    return(Json(new { msg = message, JsonRequestBehavior.AllowGet }));
                }
                catch (Exception ex)
                {
                    ViewBag.CatchedMsg = ex.Message;
                }
            }

            return(View(eEmployees));
        }
Beispiel #2
0
        public ActionResult EditEmployee(Employees eEmployees)
        {
            if (eEmployees.isLoad == false)
            {
                DataTable dtGender = General.GetGender();
                ViewData["Genders"] = General.DataTableToSelectList(dtGender, "Value", "Text", "0", TopEmptyItem: new SelectListItem {
                    Value = "0", Text = ""
                });

                eEmployees.EmployeeId = Convert.ToInt32(Request.Params["EmployeeId"]);
                EmployeesBI.LoadEmployees(ref eEmployees);
                return(PartialView(eEmployees));
            }
            else
            {
                string message = "";
                if (ModelState.IsValid)
                {
                    try
                    {
                        DataTable dtGender = General.GetGender();
                        ViewData["Gender"] = General.DataTableToSelectList(dtGender, "Value", "Text", "0", TopEmptyItem: new SelectListItem {
                            Value = "0", Text = ""
                        });

                        EmployeesBI.SaveEmployees(ref eEmployees);
                        message = FASM_Msg.Updated;

                        return(Json(new { msg = message, JsonRequestBehavior.AllowGet }));
                    }
                    catch (Exception ex)
                    {
                        ViewBag.CatchedMsg = ex.Message;
                    }
                }
            }

            return(View(eEmployees));
        }