Exemple #1
0
 /// <summary>
 /// 创建一个hr_pam_employee
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="db">数据库上下文</param>
 /// <param name="entity">一个hr_pam_employee</param>
 /// <returns></returns>
 public bool Create(ref ValidationErrors validationErrors, hr_pam_employee entity)
 {
     try
     {
         repository.Create(entity);
         return(true);
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
     }
     return(false);
 }
Exemple #2
0
        public ActionResult _Delete(int id)
        {
            ///更加id删除某条数据
            _employeeBLL.Delete(ref validationErrors, id);
            hr_pam_employee employeeDAL = _employeeRepository.GetById(id);



            /////找到子表,并删除子表的数据
            //int[] scoreArray = EducationinfoBLL.GetIdByMainId(id);
            //EducationinfoBLL.DeleteCollection(ref validationErrors, scoreArray);

            NameValueCollection           collection = new NameValueCollection(Request.QueryString);
            IEnumerable <hr_pam_employee> employee   = _employeeBLL.Bindemployee(collection);

            return(View(new GridModel(employee)));
        }
Exemple #3
0
        public ActionResult _Insert_Edit(hr_pam_employee item)
        {
            hr_pam_employee employeeDAL = new hr_pam_employee();

            //更新数据
            if (TryUpdateModel(employeeDAL))
            {
                if (item.id == 0)
                {
                    _employeeBLL.Create(ref validationErrors, employeeDAL);
                }
                else
                {
                    _employeeBLL.Edit(ref validationErrors, employeeDAL);
                }
            }

            NameValueCollection           collection = new NameValueCollection(Request.QueryString);
            IEnumerable <hr_pam_employee> employee   = _employeeBLL.Bindemployee(collection);

            return(View(new GridModel(employee)));
        }
Exemple #4
0
        /// <summary>
        /// 绑定dropdownlist
        /// </summary>
        /// <param name="type">绑定类型</param>
        /// <returns>选项</returns>
        public static SelectList bindDpl(string type)
        {
            List <SelectListItem> lista = new List <SelectListItem>();

            switch (type)
            {
            case "职工性别":
                lista.Add(new SelectListItem {
                    Text = "---请选择---", Value = "-1"
                });
                lista.Add(new SelectListItem {
                    Text = "女", Value = "1"
                });
                lista.Add(new SelectListItem {
                    Text = "男", Value = "0"
                });
                break;

            case "出行状态":
                lista.Add(new SelectListItem {
                    Text = "---请选择---", Value = "-1"
                });
                lista.Add(new SelectListItem {
                    Text = "返回", Value = "0"
                });
                lista.Add(new SelectListItem {
                    Text = "出行", Value = "1"
                });
                break;

            case "部门名称":
                using (SysEntities db = new SysEntities())
                {
                    List <hr_pam_department> list = (from o in db.hr_pam_department.AsEnumerable()
                                                     select new hr_pam_department {
                        id = o.id, departmentname = o.departmentname
                    }).ToList();
                    hr_pam_department department = new hr_pam_department();
                    department.id             = -1;
                    department.departmentname = "---请选择---";
                    list.Add(department);
                    var list2 = list.OrderBy(a => a.id);
                    return(new SelectList(list2.ToList(), "id", "departmentname"));
                }

            case "职工姓名":
                using (SysEntities db = new SysEntities())
                {
                    List <hr_pam_employee> list = (from o in db.hr_pam_employee.AsEnumerable()
                                                   select new hr_pam_employee {
                        id = o.id, employeename = o.employeename
                    }).ToList();
                    hr_pam_employee employee = new hr_pam_employee();
                    employee.id           = -1;
                    employee.employeename = "---请选择---";
                    list.Add(employee);
                    var list2 = list.OrderBy(a => a.id);
                    return(new SelectList(list2.ToList(), "id", "employeename"));
                }

            case "职工学历":
                lista.Add(new SelectListItem {
                    Text = "---请选择---", Value = "-1"
                });
                lista.Add(new SelectListItem {
                    Text = "本科", Value = "1"
                });
                lista.Add(new SelectListItem {
                    Text = "大专", Value = "0"
                });
                lista.Add(new SelectListItem {
                    Text = "专科", Value = "2"
                });
                break;
            }
            SelectList items = new SelectList(lista, "Value", "Text");

            return(items);
        }