예제 #1
0
 public void ArticleDelete(Article entity, DbTrans tran)
 {
     if (tran == null)
     {
         tran = Gateway.Default.BeginTrans();
     }
     try
     {
         //删除附件
         Business.Do <IAccessory>().Delete(entity.Art_Uid);
         tran.Delete <Article>(Article._.Art_Id == entity.Art_Id);
         //删除图片文件
         string img = WeiSha.Common.Upload.Get[_artUppath].Physics + entity.Art_Logo;
         if (System.IO.File.Exists(img))
         {
             System.IO.File.Delete(img);
         }
         //删除文章
         tran.Delete <Article>(Article._.Art_Id == entity.Art_Id);
         tran.Commit();
     }
     catch (Exception ex)
     {
         tran.Rollback();
         throw ex;
     }
     finally
     {
         tran.Close();
     }
 }
예제 #2
0
        /// <summary>
        /// 删除章节
        /// </summary>
        /// <param name="entity">业务实体</param>
        public void OutlineDelete(Outline entity)
        {
            if (entity == null)
            {
                return;
            }
            List <Song.Entities.Accessory> acs = Business.Do <IAccessory>().GetAll(entity.Ol_UID);

            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    //删除附件
                    foreach (Song.Entities.Accessory ac in acs)
                    {
                        Business.Do <IAccessory>().Delete(ac.As_Id);
                    }
                    //先清理试题
                    tran.Delete <Questions>(Questions._.Ol_ID == entity.Ol_ID);
                    tran.Delete <Outline>(Outline._.Ol_ID == entity.Ol_ID);
                    tran.Commit();
                    this.OnDelete(entity, null);
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    throw ex;
                }
                finally
                {
                    tran.Close();
                }
            }
        }
예제 #3
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="entity">业务实体</param>
 public void Delete(Position entity)
 {
     if (entity.Posi_IsAdmin)
     {
         return;
     }
     //删除权限关联
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Delete <Purview>(Purview._.Posi_Id == entity.Posi_Id);
             //修改员工信息中的岗位名称
             tran.Update <EmpAccount>(new Field[] { EmpAccount._.Posi_Name }, new object[] { "" }, EmpAccount._.Posi_Id == entity.Posi_Id);
             tran.Delete <Position>(entity);
             tran.Commit();
         }
         catch
         {
             tran.Rollback();
             throw;
         }
         finally
         {
             tran.Close();
         }
     }
 }
예제 #4
0
        /// <suPsary>
        /// 删除,按栏目名称
        /// </suPsary>
        /// <param name="name">栏目名称</param>
        public void SortDelete(string name)
        {
            LinksSort entity = Gateway.Default.From <LinksSort>().Where(LinksSort._.Ls_Name == name).ToFirst <LinksSort>();

            if (entity == null)
            {
                return;
            }
            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    tran.Delete <LinksSort>(LinksSort._.Ls_Id == entity.Ls_Id);
                    tran.Delete <Links>(Links._.Ls_Id == entity.Ls_Id);
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
                finally
                {
                    tran.Close();
                }
            }
        }
예제 #5
0
 /// <summary>
 /// 删除,按主键ID;
 /// </summary>
 /// <param name="identify">实体的主键</param>
 public void SortDelete(int identify)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             object obj = Gateway.Default.Count <AddressList>(AddressList._.Ads_Id == identify);
             if ((int)obj > 0)
             {
                 throw new Exception("当前分类含有下属信息,请勿删除");
             }
             //
             tran.Delete <AddressSort>(AddressSort._.Ads_Id);
             tran.Delete <AddressList>(AddressList._.Ads_Id);
             tran.Commit();
         }
         catch
         {
             tran.Rollback();
             throw;
         }
         finally
         {
             tran.Close();
         }
     }
 }
예제 #6
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="entity">业务实体</param>
        public void Delete(EmpGroup entity)
        {
            if (entity == null)
            {
                return;
            }
            //如果是系统组,则不允许删除
            if (entity.EGrp_IsSystem)
            {
                return;
            }

            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    tran.Delete <EmpAcc_Group>(EmpAcc_Group._.EGrp_Id == entity.EGrp_Id);
                    tran.Delete <Purview>(Purview._.EGrp_Id == entity.EGrp_Id);
                    tran.Delete <EmpGroup>(entity);
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
                finally
                {
                    tran.Close();
                }
            }
        }
예제 #7
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="entity">业务实体</param>
        public void Delete(EmpAccount entity)
        {
            if (entity == null)
            {
                return;
            }
            //如果用户属于超管角色,则不允许删除
            Position p = Gateway.Default.From <Position>().Where(Position._.Posi_Id == entity.Posi_Id).ToFirst <Position>();

            if (p != null && p.Posi_IsAdmin == true)
            {
                throw new Exception("管理员不可以删除!");
            }
            //删除与用户组的关联
            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    tran.Delete <EmpAcc_Group>(EmpAcc_Group._.Acc_Id == entity.Acc_Id);
                    tran.Delete <EmpAccount>(entity);
                    WeiSha.WebControl.FileUpload.Delete("Employee", entity.Acc_Photo);
                    tran.Commit();
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    throw ex;
                }
                finally
                {
                    tran.Close();
                }
            }
        }
예제 #8
0
 public void PagerDelete(int identify)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             Examination exam = Gateway.Default.From <Examination>().Where(Examination._.Tp_Id == identify).ToFirst <Examination>();
             if (exam != null)
             {
                 throw new WeiSha.Common.ExceptionForPrompt("该试卷已被考试采用,不能删除");
             }
             tran.Delete <TestPaper>(TestPaper._.Tp_Id == identify);
             tran.Delete <TestResults>(TestResults._.Tp_Id == identify);
             tran.Commit();
         }
         catch
         {
             tran.Rollback();
             throw;
         }
         finally
         {
             tran.Close();
         }
     }
 }
예제 #9
0
 private void _Delete(int id, DbTrans tran)
 {
     ManageMenu[] ws = tran.From <ManageMenu>().Where(ManageMenu._.MM_PatId == id).ToArray <ManageMenu>();
     //删除子级
     foreach (ManageMenu w in ws)
     {
         _Delete(w.MM_Id, tran);
     }
     //删除菜单与权限的关联
     tran.Delete <Purview>(Purview._.MM_Id == id);
     //删除自身
     tran.Delete <ManageMenu>(ManageMenu._.MM_Id == id);
 }
예제 #10
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="entity">业务实体</param>
 public void GuideDelete(Guide entity)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             if (!string.IsNullOrWhiteSpace(entity.Gu_Uid))
             {
                 //删除附件
                 Business.Do <IAccessory>().Delete(entity.Gu_Uid);
                 //删除图片文件
                 string img = WeiSha.Common.Upload.Get[_artUppath].Physics + entity.Gu_Logo;
                 if (System.IO.File.Exists(img))
                 {
                     System.IO.File.Delete(img);
                 }
             }
             tran.Delete <Guide>(Guide._.Gu_Id == entity.Gu_Id);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
예제 #11
0
 /// <summary>
 /// 私有对象,用于删除对象的子级,以及相关信息
 /// </summary>
 /// <param name="id"></param>
 private void _Delete(int id, DbTrans tran)
 {
     Depart[] ws = Gateway.Default.From <Depart>().Where(Depart._.Dep_PatId == id).ToArray <Depart>();
     if (ws != null)
     {
         foreach (Depart w in ws)
         {
             //删除子级
             _Delete(w.Dep_Id, tran);
         }
     }
     //删除自身
     tran.Delete <Depart>(Depart._.Dep_Id == id);
     tran.Delete <Purview>(Purview._.Dep_Id == id);
     tran.Update <EmpAccount>(new Field[] { EmpAccount._.Dep_CnName }, new object[] { "" }, EmpAccount._.Dep_Id == id);
 }
예제 #12
0
        /// <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();
                }
            }
        }
예제 #13
0
 /// <suPsary>
 /// 删除
 /// </suPsary>
 /// <param name="entity">业务实体</param>
 public void SortDelete(LinksSort entity)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Delete <LinksSort>(LinksSort._.Ls_Id == entity.Ls_Id);
             tran.Delete <Links>(Links._.Ls_Id == entity.Ls_Id);
             tran.Commit();
         }
         catch
         {
             tran.Rollback();
             throw;
         }
         finally
         {
             tran.Close();
         }
     }
 }
예제 #14
0
 public void SpecialDelete(int identify)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Delete <Special>(Special._.Sp_Id == identify);
             tran.Delete <Special_Article>(Special_Article._.Sp_Id == identify);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
예제 #15
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="entity">业务实体</param>
        private void _ProductDelete(Product entity, DbTrans tran)
        {
            //删除产品的留言
            tran.Delete <ProductMessage>(ProductMessage._.Pd_Id == entity.Pd_Id);
            // 删除产品图片
            //Song.Entities.ProductPicture[] pps = this.PictureAll(entity.Pd_Id, null);
            //foreach (ProductPicture p in pps)
            //{
            //    this._PictureDelete(p);
            //}
            //删除产品主信息
            string resPath = WeiSha.Common.Upload.Get["Product"].Physics;

            WeiSha.WebControl.FileUpload.Delete("Product", entity.Pd_Logo);
            //删除二维码文件
            if (System.IO.File.Exists(resPath + entity.Pd_QrCode))
            {
                System.IO.File.Delete(resPath + entity.Pd_QrCode);
            }
            tran.Delete <Product>(Product._.Pd_Id == entity.Pd_Id);
        }
예제 #16
0
 public void TrpDelete(string uid)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Delete <ExamGroup>(ExamGroup._.Exam_UID == uid);
             tran.Delete <TrPlan>(TrPlan._.TrP_UID == uid);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
 /// <summary>
 /// 删除,按主键ID;
 /// </summary>
 /// <param name="identify">实体的主键</param>
 public void ThemeDelete(int identify)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             tran.Delete <ProfitSharing>(ProfitSharing._.Ps_ID == identify);
             tran.Delete <ProfitSharing>(ProfitSharing._.Ps_PID == identify);
             tran.Commit();
         }
         catch
         {
             tran.Rollback();
             throw;
         }
         finally
         {
             tran.Close();
         }
     }
 }
예제 #18
0
        public void Delete(int identify)
        {
            Columns[] child = this.Children(identify, null);
            foreach (Columns n in child)
            {
                Delete(n.Col_ID);
            }
            Columns col = Gateway.Default.From <Columns>().Where(Columns._.Col_ID == identify).ToFirst <Columns>();

            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    //如果是新闻栏目,则删除所有新闻
                    if (col.Col_Type == "News")
                    {
                        Business.Do <IContents>().ArticleDeleteAll(-1, identify);
                    }
                    if (col.Col_Type == "Product")
                    {
                        Business.Do <IContents>().ProductDeleteAll(-1, identify);                           //删除当前栏目下的产品
                    }
                    if (col.Col_Type == "Picture")
                    {
                        Business.Do <IContents>().PictureDeleteAll(-1, identify);                           //删除图片
                    }
                    if (col.Col_Type == "Video")
                    {
                        Business.Do <IContents>().VideoDeleteAll(-1, identify);                             //删除视频
                    }
                    if (col.Col_Type == "Download")
                    {
                        Business.Do <IContents>().DownloadDeleteAll(-1, identify);                              //删除下载资料
                    }
                    if (col.Col_Type == "Article")
                    {
                        Business.Do <IContents>().ArticleDeleteAll(-1, identify);
                    }
                    tran.Delete <Columns>(Columns._.Col_ID == identify);
                    tran.Commit();
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    throw ex;
                }
                finally
                {
                    tran.Close();
                }
            }
        }
예제 #19
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="entity">业务实体</param>
 public void ThemeDelete(Vote entity)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             //先删除当前主题下的选择项目
             tran.Delete <Vote>(Vote._.Vt_UniqueId == entity.Vt_UniqueId);
             //删除当前调查主题
             tran.Delete <Vote>(Vote._.Vt_Id == entity.Vt_Id);
             //删除当前调查主题的图片信息
             string img = "~/upload/" + this._uppath + "/" + entity.Vt_Image;
             img = WeiSha.Common.Server.MapPath(img);
             if (System.IO.File.Exists(img))
             {
                 System.IO.File.Delete(img);
             }
             string imgSmall = "~/upload/" + this._uppath + "/" + entity.Vt_ImageSmall;
             imgSmall = WeiSha.Common.Server.MapPath(imgSmall);
             if (System.IO.File.Exists(imgSmall))
             {
                 System.IO.File.Delete(imgSmall);
             }
             tran.Commit();
         }
         catch
         {
             tran.Rollback();
             throw;
         }
         finally
         {
             tran.Close();
         }
     }
 }
예제 #20
0
        /// <summary>
        /// 清理当前机构的数据
        /// </summary>
        /// <param name="orgid"></param>
        public void OrganClear(int identify)
        {
            Organization org = this.OrganSingle(identify);

            if (org.Org_IsRoot)
            {
                return;
            }
            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    //删除教师与学生
                    tran.Delete <Teacher>(Teacher._.Org_ID == identify);
                    //tran.Delete<TeacherHistory>(TeacherHistory._.Org_ID == identify);
                    tran.Delete <TeacherSort>(TeacherSort._.Org_ID == identify);
                    tran.Delete <Accounts>(Accounts._.Org_ID == identify);
                    tran.Delete <StudentSort>(StudentSort._.Org_ID == identify);
                    //删除课程
                    tran.Delete <Course>(Course._.Org_ID == identify);
                    tran.Delete <Student_Course>(Student_Course._.Org_ID == identify);
                    //删除试题、试卷、考试、成绩
                    tran.Delete <Questions>(Questions._.Org_ID == identify);
                    //tran.Delete<Student_Ques>(Student_Ques._.Org_ID == identify);
                    tran.Delete <TestPaper>(TestPaper._.Org_ID == identify);
                    tran.Delete <Examination>(Examination._.Org_ID == identify);
                    //tran.Delete<ExamResults>(ExamResults._.Org_ID == identify);
                    //删除知识库
                    tran.Delete <KnowledgeSort>(KnowledgeSort._.Org_ID == identify);
                    tran.Delete <Knowledge>(Knowledge._.Org_ID == identify);
                    //删除新闻、通知
                    tran.Delete <Columns>(Columns._.Org_ID == identify);
                    tran.Delete <Article>(Article._.Org_ID == identify);
                    tran.Delete <Notice>(Notice._.Org_ID == identify);
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
                finally
                {
                    tran.Close();
                }
            }
        }
예제 #21
0
        /// <summary>
        /// 批量添加
        /// </summary>
        /// <param name="memberId">成员id,即权限赋予对象的id</param>
        /// <param name="mmids">管理菜单的id</param>
        /// <param name="type">成员类型</param>
        public void AddBatch(int memberId, string mmids, string type)
        {
            using (DbTrans tran = Gateway.Default.BeginTrans())
            {
                try
                {
                    type = type.ToLower();
                    WhereClip wc = Purview._.Pur_Type == type;
                    //删除所有
                    switch (type)
                    {
                    case "posi":
                        tran.Delete <Purview>(wc && Purview._.Posi_Id == memberId);
                        break;

                    case "group":
                        tran.Delete <Purview>(wc && Purview._.EGrp_Id == memberId);
                        break;

                    case "depart":
                        tran.Delete <Purview>(wc && Purview._.Dep_Id == memberId);
                        break;

                    case "organ":
                        tran.Delete <Purview>(wc && Purview._.Org_ID == memberId);
                        break;

                    case "orglevel":
                        tran.Delete <Purview>(wc && Purview._.Olv_ID == memberId);
                        break;
                    }
                    foreach (string node in mmids.Split(','))
                    {
                        if (node.Trim() == "")
                        {
                            continue;
                        }
                        if (node.IndexOf("|") < 0)
                        {
                            continue;
                        }
                        int    id               = Convert.ToInt32(node.Substring(0, node.IndexOf("|")));
                        string state            = node.Substring(node.IndexOf("|") + 1);
                        Song.Entities.Purview p = new Song.Entities.Purview();
                        p.Pur_Type  = type;
                        p.Pur_State = state;
                        p.MM_Id     = Convert.ToInt32(id);
                        switch (type)
                        {
                        case "posi":
                            p.Posi_Id = memberId;
                            break;

                        case "group":
                            p.EGrp_Id = memberId;
                            break;

                        case "depart":
                            p.Dep_Id = memberId;
                            break;

                        case "organ":
                            p.Org_ID = memberId;
                            break;

                        case "orglevel":
                            p.Olv_ID = memberId;
                            break;
                        }
                        tran.Save <Purview>(p);
                    }
                    tran.Commit();
                }
                catch
                {
                    tran.Rollback();
                    throw;
                }
                finally
                {
                    tran.Close();
                }
            }
        }