/// <summary> /// 下移 /// </summary> /// <param name="identify"></param> /// <returns></returns> public bool DownloadOSDown(int orgid, int identify) { //当前对象 DownloadOS current = Gateway.Default.From <DownloadOS>().Where(DownloadOS._.Dos_Id == identify).ToFirst <DownloadOS>(); int tax = (int)current.Dos_Tax; //下一个对象,即弟弟对象;弟弟不存则直接返回false; DownloadOS next = Gateway.Default.From <DownloadOS>() .Where(DownloadOS._.Dos_Tax > tax && DownloadOS._.Org_Id == orgid).OrderBy(DownloadOS._.Dos_Tax.Asc).ToFirst <DownloadOS>(); if (next == null) { return(false); } //交换排序号 current.Dos_Tax = next.Dos_Tax; next.Dos_Tax = tax; using (DbTrans tran = Gateway.Default.BeginTrans()) try { tran.Save <DownloadOS>(current); tran.Save <DownloadOS>(next); tran.Commit(); return(true); } catch { tran.Rollback(); throw; } finally { tran.Close(); } }
/// <summary> /// 上移 /// </summary> /// <param name="identify"></param> /// <returns></returns> public bool DownloadTypeUp(int orgid, int identify) { //当前对象 DownloadType current = Gateway.Default.From <DownloadType>().Where(DownloadType._.Dty_Id == identify).ToFirst <DownloadType>(); int tax = (int)current.Dty_Tax; //上一个对象,即兄长对象;兄长不存则直接返回false; DownloadType prev = Gateway.Default.From <DownloadType>() .Where(DownloadType._.Dty_Tax < tax && DownloadType._.Org_Id == orgid).OrderBy(DownloadType._.Dty_Tax.Desc).ToFirst <DownloadType>(); if (prev == null) { return(false); } //交换排序号 current.Dty_Tax = prev.Dty_Tax; prev.Dty_Tax = tax; using (DbTrans tran = Gateway.Default.BeginTrans()) try { tran.Save <DownloadType>(current); tran.Save <DownloadType>(prev); tran.Commit(); return(true); } catch { tran.Rollback(); throw; } finally { tran.Close(); } }
/// <summary> /// 添加回复留言信息 /// </summary> /// <param name="entity"></param> public void AnswerAdd(MessageBoard entity) { // Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent(); if (org != null) { entity.Org_ID = org.Org_ID; entity.Org_Name = org.Org_Name; } Song.Entities.MessageBoard theme = Gateway.Default.From <MessageBoard>().Where(MessageBoard._.Mb_IsTheme == true && MessageBoard._.Mb_UID == entity.Mb_UID).ToFirst <MessageBoard>(); using (DbTrans tran = Gateway.Default.BeginTrans()) { try { theme.Mb_AnsTime = DateTime.Now; theme.Mb_ReplyNumber += 1; tran.Save <MessageBoard>(theme); // entity.Mb_IsTheme = false; entity.Mb_CrtTime = DateTime.Now; entity.Mb_IP = WeiSha.Common.Request.IP.IPAddress; tran.Save <MessageBoard>(entity); tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Close(); } } }
private void addData(Song.Entities.TrPlan theme, List <Song.Entities.ExamGroup> groups) { Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent(); if (org != null) { theme.Org_ID = org.Org_ID; theme.Org_Name = org.Org_Name; } using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <TrPlan>(theme); if (groups != null) { foreach (Song.Entities.ExamGroup g in groups) { tran.Save <ExamGroup>(g); } } tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Close(); } } }
/// <summary> /// 将当前章节升级 /// </summary> /// <param name="id"></param> /// <returns></returns> public bool OutlineToLeft(int couid, int id) { //当前对象 Outline current = Gateway.Default.From <Outline>().Where(Outline._.Ol_ID == id).ToFirst <Outline>(); //当前父对象 Outline parent = Gateway.Default.From <Outline>().Where(Outline._.Ol_ID == current.Ol_PID).ToFirst <Outline>(); //顶级列表 Song.Entities.Outline[] top = Gateway.Default.From <Outline>() .Where(Outline._.Ol_Tax > parent.Ol_Tax && Outline._.Cou_ID == current.Cou_ID && Outline._.Ol_PID == parent.Ol_PID) .OrderBy(Outline._.Ol_Tax.Asc).ToArray <Outline>(); //当前父的同级中,比自己大的子级(即自身后面的) Song.Entities.Outline[] child = Gateway.Default.From <Outline>() .Where(Outline._.Ol_Tax > current.Ol_Tax && Outline._.Cou_ID == current.Cou_ID && Outline._.Ol_PID == current.Ol_PID) .OrderBy(Outline._.Ol_Tax.Asc).ToArray <Outline>(); // using (DbTrans tran = Gateway.Default.BeginTrans()) { try { current.Ol_PID = 0; current.Ol_Level = 0; current.Ol_Tax = parent.Ol_Tax + 1; current.Attach(); tran.Save <Outline>(current); //处理升级后的顶级排序问题 for (int i = 0; i < top.Length; i++) { top[i].Ol_Tax = top[i].Ol_Tax + 1; top[i].Attach(); tran.Save <Outline>(top[i]); } //处理升级后,同级的子级的排序号 for (int i = 0; i < child.Length; i++) { child[i].Ol_Tax = i + 1; child[i].Ol_PID = current.Ol_ID; child[i].Ol_Level = 1; child[i].Attach(); tran.Save <Outline>(child[i]); } tran.Commit(); } catch { tran.Rollback(); throw; } finally { tran.Close(); } } this.OnSave(null, EventArgs.Empty); return(true); }
/// <summary> /// 使用该充值码 /// </summary> /// <param name="entity"></param> public void CouponUseCode(RechargeCode entity) { //是否被禁用 Song.Entities.RechargeSet set = Gateway.Default.From <RechargeSet>().Where(RechargeSet._.Rs_ID == entity.Rs_ID).ToFirst <RechargeSet>(); if (set == null || set.Rs_IsEnable == false) { throw new Exception("该充值码已经被禁用"); } //是否过期 if (!(DateTime.Now > entity.Rc_LimitStart && DateTime.Now < entity.Rc_LimitEnd.Date.AddDays(1))) { throw new Exception("该充值码已经过期"); } //标注已经使用 entity.Rc_IsUsed = true; entity.Rc_UsedTime = DateTime.Now; //产生流水 CouponAccount ca = new CouponAccount(); ca.Ca_Value = entity.Rc_Price; ca.Ac_ID = entity.Ac_ID; ca.Ca_From = 2; ca.Rc_Code = entity.Rc_Code + "-" + entity.Rc_Pw; ca.Ca_Source = "充值码充值"; using (DbTrans tran = Gateway.Default.BeginTrans()) { try { Business.Do <IAccounts>().CouponAdd(ca); tran.Save <RechargeCode>(entity); RechargeSet setEnity = tran.From <RechargeSet>().Where(RechargeSet._.Rs_ID == entity.Rs_ID).ToFirst <RechargeSet>(); if (setEnity != null) { setEnity.Rs_UsedCount++; tran.Save <RechargeSet>(setEnity); } tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Close(); } } }
public void Save(Song.Entities.Columns entity) { using (DbTrans trans = Gateway.Default.BeginTrans()) { try { trans.Save <Columns>(entity); //新闻,产品,图片,视频,下载 trans.Update <Article>(new Field[] { Article._.Col_Name }, new object[] { entity.Col_Name }, Article._.Col_Id == entity.Col_ID); trans.Update <Product>(new Field[] { Product._.Col_Name }, new object[] { entity.Col_Name }, Product._.Col_Id == entity.Col_ID); trans.Update <Picture>(new Field[] { Picture._.Col_Name }, new object[] { entity.Col_Name }, Picture._.Col_Id == entity.Col_ID); trans.Update <Video>(new Field[] { Video._.Col_Name }, new object[] { entity.Col_Name }, Video._.Col_Id == entity.Col_ID); trans.Update <Download>(new Field[] { Download._.Col_Name }, new object[] { entity.Col_Name }, Download._.Col_Id == entity.Col_ID); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw ex; } finally { trans.Close(); } } }
/// <summary> /// 修改 /// </summary> /// <param name="entity">业务实体</param> public void Save(Depart entity) { using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <Depart>(entity); tran.Update <EmpAccount>(new Field[] { EmpAccount._.Dep_CnName }, new object[] { entity.Dep_CnName }, EmpAccount._.Dep_Id == entity.Dep_Id); tran.Update <Subject>(new Field[] { Subject._.Dep_CnName }, new object[] { entity.Dep_CnName }, Subject._.Dep_Id == entity.Dep_Id); tran.Update <Course>(new Field[] { Course._.Dep_CnName }, new object[] { entity.Dep_CnName }, Course._.Dep_Id == entity.Dep_Id); //tran.Update<Teacher>(new Field[] { Teacher._.Dep_CnName }, new object[] { entity.Dep_CnName }, Teacher._.Dep_Id == entity.Dep_Id); tran.Update <StudentSort>(new Field[] { StudentSort._.Dep_CnName }, new object[] { entity.Dep_CnName }, StudentSort._.Dep_Id == entity.Dep_Id); tran.Commit(); } catch { tran.Rollback(); throw; } finally { tran.Close(); } } }
/// <summary> /// 修改 /// </summary> /// <param name="entity">业务实体</param> public int RootSave(ManageMenu entity) { int id = entity.MM_Id; using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <ManageMenu>(entity); tran.Update <ManageMenu>(new Field[] { ManageMenu._.MM_IsUse, ManageMenu._.MM_IsShow }, new object[] { entity.MM_IsUse, entity.MM_IsShow }, ManageMenu._.MM_Root == entity.MM_Id); tran.Commit(); } catch { tran.Rollback(); throw; } finally { tran.Close(); } } return(id); }
public void ProductSave(Product entity) { Song.Entities.Columns nc = Business.Do <IColumns>().Single((int)entity.Col_Id); if (nc != null) { entity.Col_Name = nc.Col_Name; } using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <Product>(entity); //当更改产品信息时,同步更改产品留言的产品名称 tran.Update <ProductMessage>(new Field[] { ProductMessage._.Pd_Name }, new object[] { entity.Pd_Name }, ProductMessage._.Pd_Id == entity.Pd_Id); tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Close(); } } }
/// <summary> /// 修改学习卡设置项 /// </summary> /// <param name="entity">业务实体</param> public void SetSave(LearningCardSet entity) { using (DbTrans tran = Gateway.Default.BeginTrans()) { try { Song.Entities.LearningCardSet rs = tran.From <LearningCardSet>().Where(LearningCardSet._.Lcs_ID == entity.Lcs_ID).ToFirst <LearningCardSet>(); LearningCard[] cards = CardGenerate(entity, tran); if (cards != null) { foreach (LearningCard c in cards) { Gateway.Default.Save <LearningCard>(c); } } tran.Update <LearningCard>(new Field[] { LearningCard._.Lc_Price, LearningCard._.Lc_LimitStart, LearningCard._.Lc_LimitEnd }, new object[] { entity.Lcs_Price, entity.Lcs_LimitStart, entity.Lcs_LimitEnd }, LearningCard._.Lcs_ID == entity.Lcs_ID && LearningCard._.Lc_IsUsed == false); tran.Save <LearningCardSet>(entity); tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Close(); } } }
/// <summary> /// 修改 /// </summary> /// <param name="entity">业务实体</param> public void ColumnsSave(GuideColumns entity) { Song.Entities.GuideColumns old = this.ColumnsSingle(entity.Gc_ID); if (old.Gc_PID != entity.Gc_PID) { object obj = Gateway.Default.Max <GuideColumns>(GuideColumns._.Gc_Tax, GuideColumns._.Cou_ID == entity.Cou_ID && GuideColumns._.Gc_PID == entity.Gc_PID); entity.Gc_Tax = obj is int?(int)obj + 1 : 0; } using (DbTrans trans = Gateway.Default.BeginTrans()) { try { trans.Save <GuideColumns>(entity); trans.Update <GuideColumns>(new Field[] { Guide._.Gc_Title }, new object[] { entity.Gc_Title, }, GuideColumns._.Gc_ID == entity.Gc_ID); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw ex; } finally { trans.Close(); } } }
public void SortSave(TeacherSort entity) { using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <TeacherSort>(entity); tran.Update <Teacher>(new Field[] { Teacher._.Ths_Name }, new object[] { entity.Ths_Name }, Teacher._.Ths_ID == entity.Ths_ID); if (entity.Ths_IsDefault) { tran.Update <TeacherSort>(new Field[] { TeacherSort._.Ths_IsDefault }, new object[] { false }, TeacherSort._.Ths_ID != entity.Ths_ID && TeacherSort._.Org_ID == entity.Org_ID); tran.Update <TeacherSort>(new Field[] { TeacherSort._.Ths_IsDefault }, new object[] { true }, TeacherSort._.Ths_ID == entity.Ths_ID && TeacherSort._.Org_ID == entity.Org_ID); } tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Close(); } } }
public void TeamSave(Team entity) { // Song.Entities.Depart dep = Gateway.Default.From <Depart>().Where(Depart._.Dep_Id == entity.Dep_ID).ToFirst <Depart>(); if (dep != null) { entity.Dep_Name = dep.Dep_CnName; } using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <Team>(entity); tran.Update <EmpAccount>(new Field[] { EmpAccount._.Team_Name }, new object[] { entity.Team_Name }, EmpAccount._.Team_ID == entity.Team_ID); tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Close(); } } }
/// <summary> /// 删除回复信息 /// </summary> /// <param name="identify"></param> public void AnswerDelete(int identify) { MessageBoard mb = Gateway.Default.From <MessageBoard>().Where(MessageBoard._.Mb_Id == identify).ToFirst <MessageBoard>(); if (mb.Mb_IsTheme) { this.ThemeDelete(mb); } else { Song.Entities.MessageBoard theme = Gateway.Default.From <MessageBoard>().Where(MessageBoard._.Mb_IsTheme == true && MessageBoard._.Mb_UID == mb.Mb_UID).ToFirst <MessageBoard>(); using (DbTrans tran = Gateway.Default.BeginTrans()) try { theme.Mb_AnsTime = DateTime.Now; theme.Mb_ReplyNumber -= 1; tran.Save <MessageBoard>(theme); // tran.Delete <MessageBoard>(MessageBoard._.Mb_Id == identify); tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Close(); } } }
public void TeacherSave(Teacher entity) { //如果密码不为空 //if (string.IsNullOrWhiteSpace(entity.Th_Pw)) // entity.Th_Pw = new WeiSha.Common.Param.Method.ConvertToAnyValue(entity.Th_Pw).MD5; using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <Teacher>(entity); //同步课程表中的教师名称 tran.Update <Course>(new Field[] { Course._.Th_Name }, new object[] { entity.Th_Name }, Course._.Th_ID == entity.Th_ID); //同步教师评价中的名称 tran.Update <TeacherComment>(new Field[] { TeacherComment._.Th_Name }, new object[] { entity.Th_Name }, TeacherComment._.Th_ID == entity.Th_ID); tran.Update <Accounts>(new Field[] { Accounts._.Ac_Sex, Accounts._.Ac_Birthday, Accounts._.Ac_IDCardNumber, Accounts._.Ac_Nation, Accounts._.Ac_Native }, new object[] { entity.Th_Sex, entity.Th_Birthday, entity.Th_IDCardNumber, entity.Th_Nation, entity.Th_Native }, Accounts._.Ac_ID == entity.Ac_ID); tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Close(); } } }
public void PagerSave(TestPaper entity) { entity.Tp_Lasttime = DateTime.Now; //相关联的课程名称 Course cou = Gateway.Default.From <Course>().Where(Course._.Cou_ID == entity.Cou_ID).ToFirst <Course>(); if (cou != null) { entity.Cou_Name = cou.Cou_Name; } using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <TestPaper>(entity); tran.Update <Examination>(new Field[] { Examination._.Exam_PassScore, Examination._.Exam_Total }, new object[] { entity.Tp_PassScore, entity.Tp_Total }, Examination._.Tp_Id == entity.Tp_Id); tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Close(); } } }
public bool LinksRemoveDown(int id) { //当前对象 Links current = Gateway.Default.From <Links>().Where(Links._.Lk_Id == id).ToFirst <Links>(); //当前对象父节点id; int lsId = (int)current.Ls_Id; //当前对象排序号 int orderValue = (int)current.Lk_Tax; //下一个对象,即弟弟对象;弟弟不存则直接返回false; Links next = Gateway.Default.From <Links>() .Where(Links._.Lk_Tax > orderValue && Links._.Org_ID == current.Org_ID && Links._.Ls_Id == lsId) .OrderBy(Links._.Lk_Tax.Asc).ToFirst <Links>(); if (next == null) { //如果弟对象不存在,则表示当前节点在兄弟中是老幺;即是最底端; return(false); } //交换排序号 current.Lk_Tax = next.Lk_Tax; next.Lk_Tax = orderValue; using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <Links>(current); tran.Save <Links>(next); tran.Commit(); } catch { tran.Rollback(); throw; } finally { tran.Close(); } } return(true); }
/// <summary> /// 将当前栏目向上移动;仅在当前对象的同层移动,即同一父节点下的对象之间移动; /// </summary> /// <param name="id"></param> /// <returns>如果已经处于顶端,则返回false;移动成功,返回true</returns> public bool RemoveUp(int id) { //当前对象 ManageMenu current = Gateway.Default.From <ManageMenu>().Where(ManageMenu._.MM_Id == id).ToFirst <ManageMenu>(); //当前对象父节点id; string parentId = (string)current.MM_PatId; //当前对象排序号 int orderValue = (int)current.MM_Tax; //上一个对象,即兄长对象; ManageMenu up = Gateway.Default.From <ManageMenu>().Where(ManageMenu._.MM_PatId == parentId && ManageMenu._.MM_Tax < orderValue).OrderBy(ManageMenu._.MM_Tax.Desc).ToFirst <ManageMenu>(); if (up == null) { //如果兄长对象不存在,则表示当前节点在兄弟中是老大;即是最顶点; return(false); } //交换排序号 current.MM_Tax = up.MM_Tax; up.MM_Tax = orderValue; using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <ManageMenu>(current); tran.Save <ManageMenu>(up); tran.Commit(); } catch { tran.Rollback(); throw; } finally { tran.Close(); } } return(true); }
/// <summary> /// 将当前栏目向下移动;仅在当前对象的同层移动,即同一父节点下的对象之间移动; /// </summary> /// <param name="id"></param> /// <returns>如果已经处于最底端,则返回false;移动成功,返回true</returns> public bool RemoveDown(int id) { //当前对象 ManageMenu current = Gateway.Default.From <ManageMenu>().Where(ManageMenu._.MM_Id == id).ToFirst <ManageMenu>(); //当前对象父节点id; string parentId = (string)current.MM_PatId; //当前对象排序号 int orderValue = (int)current.MM_Tax; //下一个对象,即弟弟对象; ManageMenu down = Gateway.Default.From <ManageMenu>().Where(ManageMenu._.MM_PatId == parentId && ManageMenu._.MM_Tax > orderValue).OrderBy(ManageMenu._.MM_Tax.Asc).ToFirst <ManageMenu>(); if (down == null) { //如果弟对象不存在,则表示当前节点在兄弟中是老幺;即是最底端; return(false); } //交换排序号 current.MM_Tax = down.MM_Tax; down.MM_Tax = orderValue; using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <ManageMenu>(current); tran.Save <ManageMenu>(down); tran.Commit(); } catch { tran.Rollback(); throw; } finally { tran.Close(); } } return(true); }
public bool LinksRemoveUp(int id) { //当前对象 Links current = Gateway.Default.From <Links>().Where(Links._.Lk_Id == id).ToFirst <Links>(); //当前对象父节点id; int lsId = (int)current.Ls_Id; //当前对象排序号 int orderValue = (int)current.Lk_Tax; //上一个对象,即兄长对象; Links up = Gateway.Default.From <Links>().Where(Links._.Org_ID == current.Org_ID && Links._.Ls_Id == lsId && Links._.Lk_Tax < orderValue).OrderBy(Links._.Lk_Tax.Desc).ToFirst <Links>(); if (up == null) { //如果兄长对象不存在,则表示当前节点在兄弟中是老大;即是最顶点; return(false); } //交换排序号 current.Lk_Tax = up.Lk_Tax; up.Lk_Tax = orderValue; using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <Links>(current); tran.Save <Links>(up); tran.Commit(); } catch { tran.Rollback(); throw; } finally { tran.Close(); } } return(true); }
/// <summary> /// 修改 /// </summary> /// <param name="entity">业务实体</param> public void Save(EmpAccount entity) { try { //解析身份证信息,取年龄、性别等 IDCardNumber card = IDCardNumber.Get(entity.Acc_IDCardNumber); entity.Acc_Age = card.Birthday.Year; entity.Acc_Sex = card.Sex; entity.Acc_Birthday = card.Birthday; } catch { } //员所在院系,与所处岗位 Song.Entities.Depart dep = Gateway.Default.From <Depart>().Where(Depart._.Dep_Id == entity.Dep_Id).ToFirst <Depart>(); if (dep != null) { entity.Dep_CnName = dep.Dep_CnName; } Song.Entities.Position pos = Gateway.Default.From <Position>().Where(Position._.Posi_Id == entity.Posi_Id).ToFirst <Position>(); if (pos != null) { entity.Posi_Name = pos.Posi_Name; } using (DbTrans tran = Gateway.Default.BeginTrans()) { try { //当修改员工帐号时 tran.Save <EmpAccount>(entity); //tran.Update<Picture>(new Field[] { Picture._.Acc_Name }, new object[] { entity.Acc_Name }, Picture._.Acc_Id == entity.Acc_Id,tran); //Gateway.Default.Update<Product>(new Field[] { Product._.Acc_Name }, new object[] { entity.Acc_Name }, Product._.Acc_Id == entity.Acc_Id,tran); tran.Update <Article>(new Field[] { Article._.Acc_Name }, new object[] { entity.Acc_Name }, Article._.Acc_Id == entity.Acc_Id); //Gateway.Default.Update<Video>(new Field[] { Video._.Acc_Name }, new object[] { entity.Acc_Name }, Video._.Acc_Id == entity.Acc_Id); //Gateway.Default.Update<Download>(new Field[] { Download._.Acc_Name }, new object[] { entity.Acc_Name }, Download._.Acc_Id == entity.Acc_Id); //工作日志的信息 tran.Update <DailyLog>(new Field[] { DailyLog._.Acc_Name }, new object[] { entity.Acc_Name }, DailyLog._.Acc_Id == entity.Acc_Id); //任务管理 tran.Update <Task>(new Field[] { Task._.Acc_Name }, new object[] { entity.Acc_Name }, Task._.Acc_Id == entity.Acc_Id); tran.Update <Task>(new Field[] { Task._.Task_WorkerName }, new object[] { entity.Acc_Name }, Task._.Task_WorkerId == entity.Acc_Id); tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Close(); } } }
public bool SortRemoveDown(int orgid, int id) { //当前对象 TeacherSort current = Gateway.Default.From <TeacherSort>().Where(TeacherSort._.Ths_ID == id).ToFirst <TeacherSort>(); //当前对象排序号 int orderValue = (int)current.Ths_Tax; //下一个对象,即弟弟对象; TeacherSort down = Gateway.Default.From <TeacherSort>() .Where(TeacherSort._.Org_ID == orgid && TeacherSort._.Ths_Tax > orderValue) .OrderBy(TeacherSort._.Ths_Tax.Asc).ToFirst <TeacherSort>(); if (down == null) { return(false); } //交换排序号 current.Ths_Tax = down.Ths_Tax; down.Ths_Tax = orderValue; using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <TeacherSort>(current); tran.Save <TeacherSort>(down); tran.Commit(); } catch { tran.Rollback(); throw; } finally { tran.Close(); } } return(true); }
public bool RemoveDown(int id) { //当前对象 Song.Entities.Task current = this.GetSingle(id); //当前对象排序号 int orderValue = (int)current.Task_Tax; //下一个对象,即弟弟对象; Song.Entities.Task down = Gateway.Default.From<Task>().Where(Task._.Task_Tax <orderValue && Task._.Task_Level == current.Task_Level).OrderBy(Task._.Task_Tax.Desc).ToFirst<Task>(); if (down == null) { //如果弟对象不存在,则表示当前节点在兄弟中是老幺;即是最底端; return false; } //交换排序号 current.Task_Tax = down.Task_Tax; down.Task_Tax = orderValue; using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save<Task>(current); tran.Save<Task>(down); tran.Commit(); return true; } catch { tran.Rollback(); throw; } finally { tran.Close(); } } }
public bool RemoveUp(int id) { //当前对象 Depart current = Gateway.Default.From <Depart>().Where(Depart._.Dep_Id == id).ToFirst <Depart>(); //当前对象排序号 int orderValue = (int)current.Dep_Tax; //上一个对象,即兄长对象; Depart up = Gateway.Default.From <Depart>() .Where(Depart._.Dep_Tax < orderValue && Depart._.Org_ID == current.Org_ID && Depart._.Dep_PatId == current.Dep_PatId) .OrderBy(Depart._.Dep_Tax.Desc).ToFirst <Depart>(); if (up == null) { return(false); } //交换排序号 current.Dep_Tax = up.Dep_Tax; up.Dep_Tax = orderValue; using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <Depart>(current); tran.Save <Depart>(up); tran.Commit(); return(true); } catch { tran.Rollback(); throw; } 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); }
public bool RemoveDown(int id) { //当前对象 Subject current = Gateway.Default.From <Subject>().Where(Subject._.Sbj_ID == id).ToFirst <Subject>(); //当前对象排序号 int orderValue = (int)current.Sbj_Tax; //下一个对象,即弟弟对象; Subject down = Gateway.Default.From <Subject>() .Where(Subject._.Sbj_Tax > orderValue && Subject._.Org_ID == current.Org_ID && Subject._.Sbj_PID == current.Sbj_PID) .OrderBy(Subject._.Sbj_Tax.Asc).ToFirst <Subject>(); if (down == null) { return(false); } //交换排序号 current.Sbj_Tax = down.Sbj_Tax; down.Sbj_Tax = orderValue; using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <Subject>(current); tran.Save <Subject>(down); tran.Commit(); return(true); } catch { tran.Rollback(); throw; } finally { tran.Close(); } } }
/// <summary> /// 将当前项目向下移动; /// </summary> /// <param name="id"></param> /// <returns>如果已经处于顶端,则返回false;移动成功,返回true</returns> public bool ProfitRemoveDown(int id) { //当前对象 ProfitSharing current = Gateway.Default.From <ProfitSharing>().Where(ProfitSharing._.Ps_ID == id).ToFirst <ProfitSharing>(); //当前对象排序号 int orderValue = (int)current.Ps_Level; //下一个对象,即弟弟对象; ProfitSharing down = Gateway.Default.From <ProfitSharing>().Where(ProfitSharing._.Ps_PID == current.Ps_PID && ProfitSharing._.Ps_Level > orderValue) .OrderBy(ProfitSharing._.Ps_Level.Asc).ToFirst <ProfitSharing>(); //如果弟对象不存在,则表示当前节点在兄弟中是老幺;即是最底端; if (down == null) { return(false); } //交换排序号 current.Ps_Level = down.Ps_Level; down.Ps_Level = orderValue; using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <ProfitSharing>(current); tran.Save <ProfitSharing>(down); tran.Commit(); return(true); } catch { tran.Rollback(); throw; } finally { tran.Close(); } } }
/// <summary> /// 将当前项目向上移动; /// </summary> /// <param name="id"></param> /// <returns>如果已经处于顶端,则返回false;移动成功,返回true</returns> public bool ProfitRemoveUp(int id) { //当前对象 ProfitSharing current = Gateway.Default.From <ProfitSharing>().Where(ProfitSharing._.Ps_ID == id).ToFirst <ProfitSharing>(); //当前对象排序号 int orderValue = (int)current.Ps_Level; //上一个对象,即兄长对象; ProfitSharing up = Gateway.Default.From <ProfitSharing>().Where(ProfitSharing._.Ps_PID == current.Ps_PID && ProfitSharing._.Ps_Level < orderValue) .OrderBy(ProfitSharing._.Ps_Level.Desc).ToFirst <ProfitSharing>(); //如果兄长对象不存在,则表示当前节点在兄弟中是老大;即是最顶点; if (up == null) { return(false); } //交换排序号 current.Ps_Level = up.Ps_Level; up.Ps_Level = orderValue; using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <ProfitSharing>(current); tran.Save <ProfitSharing>(up); tran.Commit(); return(true); } catch { tran.Rollback(); throw; } finally { tran.Close(); } } }
/// <summary> /// 将当前栏目向上移动;仅在当前对象的同层移动,即同一父节点下的对象之间移动; /// </summary> /// <param name="id"></param> /// <returns>如果已经处于顶端,则返回false;移动成功,返回true</returns> public bool NaviRemoveUp(int id) { //当前对象 Navigation current = Gateway.Default.From <Navigation>().Where(Navigation._.Nav_ID == id).ToFirst <Navigation>(); int tax = (int)current.Nav_Tax; //上一个对象,即兄长对象;兄长不存则直接返回false; Navigation prev = Gateway.Default.From <Navigation>().Where(Navigation._.Nav_Tax < tax && Navigation._.Org_ID == current.Org_ID && Navigation._.Nav_Site == current.Nav_Site && Navigation._.Nav_Type == current.Nav_Type && Navigation._.Nav_PID == current.Nav_PID) .OrderBy(Navigation._.Nav_Tax.Desc).ToFirst <Navigation>(); if (prev == null) { return(false); } //交换排序号 current.Nav_Tax = prev.Nav_Tax; prev.Nav_Tax = tax; using (DbTrans tran = Gateway.Default.BeginTrans()) { try { tran.Save <Navigation>(current); tran.Save <Navigation>(prev); tran.Commit(); return(true); } catch { tran.Rollback(); throw; } finally { tran.Close(); } } }