Ejemplo n.º 1
0
        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"));
            }
        }
Ejemplo n.º 3
0
        public ActionResult Add()
        {
            var viewModel = new EmpViewModel();

            viewModel.DeptSelectList = new SelectList(_deptRep.GetAll(), "Id", "DeptName");
            return(View(viewModel));
        }
Ejemplo n.º 4
0
        /// <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));
        }
Ejemplo n.º 5
0
 public ActionResult Create(EmpViewModel person)
 {
     if (ModelState.IsValid)
     {
         context.Emps.Add(person.Employee);
         context.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 6
0
        public EmpView()
        {
            InitializeComponent();

            EmpViewModel evm    = this.Content as EmpViewModel;
            var          data   = evm.Data;
            var          models = data.Employees;
            var          model  = models[0];
        }
Ejemplo n.º 7
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));
        }
Ejemplo n.º 8
0
        public IHttpActionResult Get()
        {
            var ViewModel = new EmpViewModel
            {
                ID     = Guid.NewGuid(),
                Name   = "Admin",
                Number = 5000,
            };

            return(Json(ViewModel));
        }
Ejemplo n.º 9
0
 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;
 }
Ejemplo n.º 10
0
        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()));
            }
        }
Ejemplo n.º 11
0
        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));
        }
Ejemplo n.º 12
0
        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));
        }
Ejemplo n.º 13
0
        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));
            }
        }
Ejemplo n.º 14
0
        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());
        }
Ejemplo n.º 15
0
        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));
        }
Ejemplo n.º 16
0
 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));
     }
 }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 19
0
        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));
        }
Ejemplo n.º 20
0
        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"));
        }
Ejemplo n.º 21
0
        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());
 }
Ejemplo n.º 23
0
 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()));
 }
Ejemplo n.º 24
0
        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()));
        }