// GET: VMHome public ActionResult Index(int jobTitle = 1) { ViewBag.jobTitle123 = db.職稱列表.Where(a => a.職稱代碼 == jobTitle).FirstOrDefault().職稱; ViewBag.jobTitleID = jobTitle; EmpTitle Et = new EmpTitle() { Employee = db.員工.Where(a => a.職稱 == jobTitle).ToList(), JobTitle = db.職稱列表.ToList() }; return(View(Et)); }
// GET: VMHome public ActionResult Index(int jobTitle = 1) { ViewBag.jobTitle = db.職稱.Where(m => m.職稱代碼 == jobTitle).FirstOrDefault().職稱1; ViewBag.jobTitleID = jobTitle; EmpTitle et = new EmpTitle() { Employee = db.員工.Where(m => m.職稱 == jobTitle).ToList(), JobTitle = db.職稱.ToList() }; return(View(et)); }
/// <summary> /// 添加 /// </summary> /// <param name="entity">业务实体</param> public void TitileAdd(EmpTitle entity) { //添加对象,并设置排序号 object obj = Gateway.Default.Max <EmpTitle>(EmpTitle._.Title_Tax, EmpTitle._.Title_Tax > -1); int tax = obj is int?(int)obj : 0; entity.Title_Tax = tax + 1; Organization org = Gateway.Default.From <Organization>().Where(Organization._.Org_ID == entity.Org_ID).ToFirst <Organization>(); if (org != null) { entity.Org_Name = org.Org_Name; } Gateway.Default.Save <EmpTitle>(entity); }
public ActionResult Details(int?id, int jobTitleID) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ViewBag.jobTitle = db.職稱.Where(m => m.職稱代碼 == jobTitleID).FirstOrDefault().職稱1; ViewBag.jobTitleID = jobTitleID; EmpTitle et = new EmpTitle() { Employee = db.員工.Where(m => m.員工編號 == id).ToList(), JobTitle = db.職稱.Where(m => m.職稱代碼 == jobTitleID).ToList() }; return(View(et)); }
public ActionResult Details(int?empid, int jobTitle) { if (empid == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ViewBag.jobTitle123 = db.職稱列表.Where(a => a.職稱代碼 == jobTitle).FirstOrDefault().職稱; ViewBag.jobTitleID = jobTitle; EmpTitle Et = new EmpTitle() { Employee = db.員工.Where(a => a.員工編號 == empid).ToList(), JobTitle = db.職稱列表.Where(a => a.職稱代碼 == jobTitle).ToList() }; return(View(Et)); }
/// <summary> /// 当前对象名称是否重名 /// </summary> /// <param name="entity">业务实体</param> /// <returns></returns> public bool TitleIsExist(int orgid, EmpTitle entity) { EmpTitle mm = null; //如果是一个新对象 if (entity.Title_Id == 0) { mm = Gateway.Default.From <EmpTitle>().Where(EmpTitle._.Org_ID == orgid && EmpTitle._.Title_Name == entity.Title_Name).ToFirst <EmpTitle>(); } else { //如果是一个已经存在的对象,则不匹配自己 mm = Gateway.Default.From <EmpTitle>() .Where(EmpTitle._.Org_ID == orgid && EmpTitle._.Title_Name == entity.Title_Name && EmpTitle._.Title_Id != entity.Title_Id) .ToFirst <EmpTitle>(); } return(mm != null); }
/// <summary> /// 修改 /// </summary> /// <param name="entity">业务实体</param> public void TitleSave(EmpTitle entity) { using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <EmpTitle>(entity); tran.Update <EmpAccount>(new Field[] { EmpAccount._.Title_Name }, new object[] { entity.Title_Name }, EmpAccount._.Title_Id == entity.Title_Id); tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Close(); } } }
/// <summary> /// 将当前项目向下移动;仅在当前对象的同层移动,即同一父节点下的对象这前移动; /// </summary> /// <param name="id"></param> /// <returns>如果已经处于顶端,则返回false;移动成功,返回true</returns> public bool TitleRemoveDown(int orgid, int id) { //当前对象 EmpTitle current = Gateway.Default.From <EmpTitle>().Where(EmpTitle._.Title_Id == id).ToFirst <EmpTitle>(); //当前对象排序号 int orderValue = (int)current.Title_Tax; //下一个对象,即弟弟对象; EmpTitle down = Gateway.Default.From <EmpTitle>() .Where(EmpTitle._.Org_ID == orgid && EmpTitle._.Title_Tax > orderValue) .OrderBy(EmpTitle._.Title_Tax.Asc).ToFirst <EmpTitle>(); if (down == null) { return(false); } //交换排序号 current.Title_Tax = down.Title_Tax; down.Title_Tax = orderValue; using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <EmpTitle>(current); tran.Save <EmpTitle>(down); tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Close(); } } return(true); }
/// <summary> /// 删除 /// </summary> /// <param name="entity">业务实体</param> public void TitleDelete(EmpTitle entity) { this.TitleDelete(entity.Title_Id); }