public ActionResult TableCellSearch() { SqlConnection conn = new SqlConnection(connection); string query = "SELECT E.Emp_Id, E.EmpName, E.Age, D.Dep_Name, D.Dep_Code, E.Dep_Id FROM Department AS D INNER JOIN Employee AS E ON D.Dep_Id = E.Dep_Id"; SqlCommand cmd = new SqlCommand(query, conn); conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); var viewList = new List <EmpViewModel>(); while (reader.Read()) { int EmpId = Convert.ToInt32(reader["Emp_Id"]); string empName = reader["EmpName"].ToString(); int age = Convert.ToInt32(reader["Age"]); int DepId = Convert.ToInt32(reader["Dep_Id"]); string DepName = reader["Dep_Name"].ToString(); string DepCode = reader["Dep_Code"].ToString(); EmpViewModel vm = new EmpViewModel(EmpId, empName, age, DepId, DepName, DepCode); viewList.Add(vm); } reader.Close(); conn.Close(); return(View(viewList)); }
public ActionResult Darbuotojo_informacijos_langas(int id = 0) { try { Darbuotojas empl = repository.Set <Darbuotojas>().Find(id); var model = new EmpViewModel(); if (empl != null) { model.id = empl.darbuojo_kodas; model.Name = empl.vardas; model.Surname = empl.pavarde; model.Email = empl.el_pastas; model.Phone = empl.telefonas; model.Address = empl.adresas; model.Gender = empl.lytis; model.StartTime = empl.darbo_pradzios_laikas; model.Role = empl.darbuotojo_tipas.name.First().ToString().ToUpper() + empl.darbuotojo_tipas.name.Substring(1); } return(View(model)); } catch (ITPProException ex) { return(RedirectToAction("Sistemos_klientu_langas")); } }
public ActionResult Add() { var viewModel = new EmpViewModel(); viewModel.DeptSelectList = new SelectList(_deptRep.GetAll(), "Id", "DeptName"); return(View(viewModel)); }
/// <summary> /// 新增 /// </summary> /// <returns></returns> public ActionResult Creat() { EmpEntity emp = new EmpEntity(); EmpViewModel empcreat = new EmpViewModel(); empcreat.EmpNumber = emp.EmpPersonal.Select(x => x.EmpNumber).Max(); //找出編號最大,並加1 empcreat.EmpNumber++; return(View(empcreat)); }
public ActionResult Create(EmpViewModel person) { if (ModelState.IsValid) { context.Emps.Add(person.Employee); context.SaveChanges(); } return(RedirectToAction("Index")); }
public EmpView() { InitializeComponent(); EmpViewModel evm = this.Content as EmpViewModel; var data = evm.Data; var models = data.Employees; var model = models[0]; }
public ActionResult Edit(string userId) { var emp = _cadreInfoRep.GetModelByUserId(userId); var viewModel = new EmpViewModel(); Mapper.Map(emp, viewModel); viewModel.DeptSelectList = new SelectList(_deptRep.GetAll(), "Id", "DeptName"); return(View(viewModel)); }
public IHttpActionResult Get() { var ViewModel = new EmpViewModel { ID = Guid.NewGuid(), Name = "Admin", Number = 5000, }; return(Json(ViewModel)); }
private static void ConvertToEmp(EmpViewModel empVM, MEmp emp) { emp.EmpName = empVM.EmpName; emp.EmpPhone = empVM.EmpPhone; emp.EmpAddress = empVM.EmpAddress; emp.EmpWorkSince = empVM.EmpWorkSince; emp.EmpGender = empVM.EmpGender; emp.EmpStatus = empVM.EmpStatus; emp.EmpCommission = empVM.EmpCommission; emp.EmpReligion = empVM.EmpReligion; emp.EmpDepartment = empVM.EmpDepartment; emp.EmpDesc = empVM.EmpDesc; }
public HttpResponseMessage Post(EmpViewModel obj) { if (ModelState.IsValid) { // Do something with the product (not shown). return(new HttpResponseMessage(HttpStatusCode.OK)); } else { var state = ModelState; return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState.ErrorsToJsonResult())); } }
public ActionResult EditSave(EmpViewModel viewModel) { ResultModel result = new ResultModel(); if (_cadreInfoRep.Any(q => q.Id != viewModel.Id && q.UserID == viewModel.UserId)) { result.IsSuccess = false; result.Msg = "身份证号码已存在"; Json(result); } cadre_info cadreInfo = _cadreInfoRep.GetModelByUserId(viewModel.UserId); Mapper.Map(viewModel, cadreInfo); result.IsSuccess = _cadreInfoRep.Update(cadreInfo) > 0; return(Json(result)); }
public ActionResult AddNew(EmpViewModel viewModel) { ResultModel result = new ResultModel(); if (_cadreInfoRep.Any(q => q.UserID == viewModel.UserId)) { result.IsSuccess = false; result.Msg = "身份证号码已存在"; Json(result); } cadre_info adminUser = new cadre_info(); Mapper.Map(viewModel, adminUser); result.IsSuccess = _cadreInfoRep.Add(adminUser) > 0; return(Json(result)); }
public JsonResult Send(EmpViewModel obj) { var Data = ModelState; if (ModelState.IsValid) { var response = ModelState.ErrorsToJsonResult(); return(Json(response.Content, JsonRequestBehavior.AllowGet)); } else { var response = ModelState.ErrorsToJsonResult(); return(Json(response.Content, JsonRequestBehavior.AllowGet)); } }
public ActionResult VueMVC() { ViewBag.Message = "The Progressive JavaScript Framework"; var ViewModel = new EmpViewModel { ID = Guid.NewGuid(), Name = "Admin", Number = 5000, }; //ViewModel.ModelStates = ViewModel.GetModelStates(); ViewBag.Object = ViewModel; return(View()); }
public ActionResult Create() { Emp e = new Emp(); var Cities = context.citys.ToList(); var states = context.Stes.ToList(); var viewModel = new EmpViewModel { Name = e.Name, Email = e.Email, Phone = e.Phone, MaritalStatus = e.MaritalStatus, City = Cities, Ste = states, }; return(View("Create", viewModel)); }
public HttpResponseMessage SaveEmployeeData(EmpViewModel objEmpView) { try { if (objEmpView != null) { return(Request.CreateErrorResponse(HttpStatusCode.OK, _empService.SaveEmployeeData(objEmpView))); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Not Saved")); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public string SaveEmployeeData(EmpViewModel objEmpView) { try { Employee objEmpEntity = new Employee(); if (objEmpView != null) { objEmpEntity.EmpName = objEmpView.EmpName; objEmpEntity.EmpSurname = objEmpView.EmpSurname; objEmpEntity.Address = objEmpView.Address; objEmpEntity.ContactNumber = objEmpView.ContactNumber; objEmpEntity.DeptId = objEmpView.DeptId; objEmpEntity.Qualification = objEmpView.Qualification; if (objEmpView.EmpId == 0) { empDb.Entry(objEmpEntity).State = EntityState.Added; } else { objEmpEntity.EmpId = objEmpView.EmpId; empDb.Entry(objEmpEntity).State = EntityState.Modified; //empDb.Entry(objEnDept).Property(x => x.IsDelete).IsModified = false; } empDb.SaveChanges(); return("SavedSuccessfully"); } else { return("SomethingWrong"); } } catch (Exception ex) { throw ex; } }
public Int32 CreateEmp(EmpViewModel emp) { var empModel = new EmpModel() { empname = emp.Name, addedby = "1", empemail = emp.Email, emphomeadd = emp.HomeAdd, empdep = emp.EmpDep, empphone = emp.EmpPhone, emprepmanager = emp.RepManager, empofficeadd = emp.OfficeAdd, IsDeleted = "false", IsActive = "true", modifiedby = "1", addedon = DateTime.Now, modifiedon = DateTime.Now }; dataobj.AddEmp(empModel); return(1); }
public JsonResult Edit(EmpViewModel datasava) { using (EmpEntity db = new EmpEntity()) { EmpPersonal P = db.EmpPersonal.Where(x => x.EmpNumber == datasava.EmpNumber).FirstOrDefault(); P.EmpName = datasava.EmpName; P.EmpSex = datasava.EmpSex; P.EmpBirthday = datasava.EmpBirthday; P.CreationDate = datasava.CreationDate; P.LastloginDate = datasava.LastloginDate; P.Seniority = datasava.Seniority; EmpUnit U = db.EmpUnit.Where(x => x.EmpNumber == datasava.EmpNumber).FirstOrDefault(); U.UnitName = datasava.UnitName; U.UnitNumber = datasava.UnitNumber; U.JobTitle = datasava.JobTitle; db.SaveChanges(); } return(Json(JsonRequestBehavior.AllowGet)); }
public ActionResult empLogin(EmpViewModel p, string password)//登入員工 { PasswordHasher pw = new PasswordHasher(); if (p.logAccount == "") { return(RedirectToAction("empLogin")); } tEmployee cust = db.tEmployees.First(e => e.fUserName == p.logAccount); var pwtrue = pw.VerifyHashedPassword(cust.fLoginPassword, password); if (pwtrue.ToString() == "Success") { Session[EmpDitctionary.SK_Login_Name] = cust.fName; Session[EmpDitctionary.SK_Login_Deptment] = cust.fDepartmentID; Session[EmpDitctionary.SK_Login_Jobtitel] = cust.fJobTitleID; Session[EmpDitctionary.SK_Login_Username] = cust.fUserName; Session[EmpDitctionary.SK_Login_ID] = cust.fEmployeeID; return(RedirectToAction("FirstView")); } return(RedirectToAction("empLogin")); }
public ActionResult Emps_Create([DataSourceRequest] DataSourceRequest request, EmpViewModel empVM) { if (empVM != null && ModelState.IsValid) { MEmp emp = new MEmp(); emp.SetAssignedIdTo(empVM.EmpID); ConvertToEmp(empVM, emp); emp.CreatedDate = DateTime.Now; emp.CreatedBy = User.Identity.Name; emp.DataStatus = "New"; empTasks.Insert(emp); } return(Json(new[] { empVM }.ToDataSourceResult(request, ModelState))); }
public ActionResult Create(EmpViewModel emp) { return(View()); }
public ActionResult Emps_Destroy([DataSourceRequest] DataSourceRequest request, EmpViewModel empVM) { if (empVM != null) { var emp = empTasks.One(empVM.EmpID); if (emp != null) { //emp.ModifiedDate = DateTime.Now; //emp.ModifiedBy = User.Identity.Name; //emp.DataStatus = "Deleted"; empTasks.Delete(emp); } } return(Json(ModelState.ToDataSourceResult())); }
public ActionResult Emps_Update([DataSourceRequest] DataSourceRequest request, EmpViewModel empVM) { if (empVM != null && ModelState.IsValid) { var emp = empTasks.One(empVM.EmpID); if (emp != null) { ConvertToEmp(empVM, emp); emp.ModifiedDate = DateTime.Now; emp.ModifiedBy = User.Identity.Name; emp.DataStatus = "Updated"; empTasks.Update(emp); } } return(Json(ModelState.ToDataSourceResult())); }