コード例 #1
0
ファイル: Article.cs プロジェクト: LiuYingyingCSU/liuyy
        public static bool UpdateArticle(AllModel articleAndPlace, int articleID, string typeName)
        {
            //得到文章ID
            int ArticleID = articleID;
            //根据文章ID更新Title
            SqlConnection connTitle   = DBLink.GetConnection();
            string        sqlstrTitle = "update Article set Title='" + articleAndPlace.article.Title + "' where ArticleID=" + ArticleID;
            SqlCommand    cmmTitle    = new SqlCommand(sqlstrTitle, connTitle);

            try
            {
                connTitle.Open();
                cmmTitle.ExecuteNonQuery();
                cmmTitle.Dispose();
                connTitle.Close();
            }
            catch (Exception)
            {
                return(false);
            }

            //接下来是专场招聘(要更新场地)
            if (typeName == "专场招聘")
            {
                DataTable dtArticle = Article.GetArticleByIDForUpdate(ArticleID);    //根据ArticleID得到Article文章信息
                if (dtArticle.Rows[0]["TypeName"].ToString().Trim() == "专场招聘")
                {
                    //更新场地
                    int      placeSecondID = Int32.Parse(dtArticle.Rows[0]["PlaceSecondID"].ToString());
                    int      placefirstID  = articleAndPlace.placeListSecond.PlaceFirstID;
                    string   placeName     = articleAndPlace.placeListSecond.PlaceName;
                    DateTime placeTime     = articleAndPlace.placeListSecond.PlaceTime;
                    if (PlaceListSecond.PlaceListSecondUpdate(placeSecondID, placefirstID, placeName, placeTime))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #2
0
ファイル: Article.cs プロジェクト: LiuYingyingCSU/liuyy
        public static bool AuditArticle(AllModel auditArticle, int tempArticleID, string typeName, int isAgree)
        {
            //isAgree=1表示通过审核,=-1表示审核未通过
            if (isAgree == 1)
            {
                //根据文章ID更新Title
                SqlConnection connTitle   = DBLink.GetConnection();
                string        sqlstrTitle = "update TempArticle set Title='" + auditArticle.tempArticle.Title + "' where TempArticleID=" + tempArticleID;
                SqlCommand    cmmTitle    = new SqlCommand(sqlstrTitle, connTitle);
                try
                {
                    connTitle.Open();
                    cmmTitle.ExecuteNonQuery();
                    cmmTitle.Dispose();
                    connTitle.Close();
                }
                catch (Exception)
                {
                    return(false);
                }
                DataTable dtTempArticle = TempArticle.GetTempArticleByTempArticleID(tempArticleID); //根据TempArticleID得到TempArticle文章信息
                if (dtTempArticle.Rows[0]["ArticleID"].ToString() == "")                            //第一次审核
                {
                    int PlaceSecondID = -1;                                                         //根据这个为-1还是其他值判断是否专场招聘
                    if (dtTempArticle.Rows[0]["PlaceSecondID"].ToString() != "")
                    {
                        //如果以前PlaceSecondID字段不为空,则默认为这个值
                        PlaceSecondID = Int32.Parse(dtTempArticle.Rows[0]["PlaceSecondID"].ToString());
                    }
                    if (dtTempArticle.Rows[0]["TypeID"].ToString().Trim() == "1")//是专场招聘
                    {
                        //先判空,专场招聘必须填写招聘时间和地点
                        //插入PlaceListSecond表并且得到刚刚插入的ID
                        PlaceSecondID = PlaceListSecond.PlaceListSecondInsert(auditArticle.placeListSecond.PlaceFirstID, auditArticle.placeListSecond.PlaceName, auditArticle.placeListSecond.PlaceTime);
                    }
                    Article article = new Article();
                    article.TypeID        = Int32.Parse(dtTempArticle.Rows[0]["TypeID"].ToString());
                    article.Title         = dtTempArticle.Rows[0]["Title"].ToString();
                    article.Introduction  = dtTempArticle.Rows[0]["Introduction"].ToString();
                    article.PlaceSecondID = PlaceSecondID;
                    article.EditTime      = DateTime.Parse(dtTempArticle.Rows[0]["EditTime"].ToString());
                    article.EditorAccount = dtTempArticle.Rows[0]["EditorAccount"].ToString();
                    article.ContactInfo   = dtTempArticle.Rows[0]["ContactInfo"].ToString();
                    article.ClickTimes    = 0;
                    article.FileAddr      = dtTempArticle.Rows[0]["FileAddr"].ToString();;
                    //把TempArticle表内容插入到Article表并且得到刚刚插入的ArticleID
                    int ArticleID = Article.ArticleInsert(article);
                    //判断是不是大型招聘会
                    if (Int32.Parse(dtTempArticle.Rows[0]["TypeID"].ToString()) == 2 || Int32.Parse(dtTempArticle.Rows[0]["TypeID"].ToString()) == 3)
                    {
                        Article.InsertBigArticle(ArticleID, Convert.ToInt32(dtTempArticle.Rows[0]["BigArticleID"].ToString()));
                    }

                    //把对应TempDemandInfo记录插入到DemandInfo
                    DataTable dtTempDemandInfo = TempDemandInfo.GetTempDemandInfoByTempArticleID(tempArticleID);
                    for (int i = 0; i < dtTempDemandInfo.Rows.Count; i++)
                    {
                        DemandInfo demandInfo = new DemandInfo();
                        demandInfo.ArticleID        = ArticleID;
                        demandInfo.PositionName     = dtTempDemandInfo.Rows[i]["PositionName"].ToString();
                        demandInfo.EducationalLevel = dtTempDemandInfo.Rows[i]["EducationalLevel"].ToString();
                        demandInfo.Major            = dtTempDemandInfo.Rows[i]["Major"].ToString();
                        demandInfo.DemandNum        = Int32.Parse(dtTempDemandInfo.Rows[i]["DemandNum"].ToString());
                        demandInfo.PositionDec      = dtTempDemandInfo.Rows[i]["PositionDec"].ToString();
                        DemandInfo.Insert(demandInfo);
                    }
                }
                else    //二次审核,TempArticle的ArticleID不为空
                {
                    //先得到TempArticle记录的ArticleID
                    int ArticleID = Int32.Parse(dtTempArticle.Rows[0]["ArticleID"].ToString());
                    if (dtTempArticle.Rows[0]["TypeID"].ToString().Trim() == "1")  //是专场招聘
                    {
                        //先判空,专场招聘必须填写招聘时间和地点
                        //先根据TempArticle表正在审核的ArticelID找到Article表记录再找PlaceSecondID对应PlaceSecondList的记录然后update
                        PlaceListSecond placeListSecond = new PlaceListSecond();
                        placeListSecond.PlaceFirstID = auditArticle.placeListSecond.PlaceFirstID;
                        placeListSecond.PlaceName    = auditArticle.placeListSecond.PlaceName;
                        placeListSecond.PlaceTime    = auditArticle.placeListSecond.PlaceTime;
                        if (!PlaceListSecond.PlaceListSecondUpdateByArticleIDFromTempArticle(ArticleID, placeListSecond))
                        {
                            return(false);
                        }
                    }
                    //判断是不是大型招聘会
                    if (Int32.Parse(dtTempArticle.Rows[0]["TypeID"].ToString()) == 2 || Int32.Parse(dtTempArticle.Rows[0]["TypeID"].ToString()) == 3)
                    {
                        Article.UpdateBigArticle(ArticleID, Convert.ToInt32(dtTempArticle.Rows[0]["BigArticleID"].ToString()));
                    }

                    //把对应TempArticle表ArticleID的Article表对应记录update
                    Article article = new Article();
                    article.ArticleID    = ArticleID;
                    article.Title        = dtTempArticle.Rows[0]["Title"].ToString();
                    article.Introduction = dtTempArticle.Rows[0]["Introduction"].ToString();
                    article.ContactInfo  = dtTempArticle.Rows[0]["ContactInfo"].ToString();
                    article.FileAddr     = dtTempArticle.Rows[0]["FileAddr"].ToString();
                    if (!Article.Update(article))
                    {
                        return(false);
                    }
                    //先删除原来的DemandInfo
                    SqlConnection cn     = DBLink.GetConnection();
                    string        sqlstr = "delete from DemandInfo where ArticleID=" + ArticleID;
                    SqlCommand    cmm    = new SqlCommand(sqlstr, cn);
                    try
                    {
                        cn.Open();
                        cmm.ExecuteNonQuery();
                        cmm.Dispose();
                        cn.Close();
                    }
                    catch (Exception)
                    {
                        return(false);
                    }
                    //把对应TempDemandInfo记录插入到DemandInfo
                    DataTable dtTempDemandInfo = TempDemandInfo.GetTempDemandInfoByTempArticleID(tempArticleID);
                    for (int i = 0; i < dtTempDemandInfo.Rows.Count; i++)
                    {
                        DemandInfo demandInfo = new DemandInfo();
                        demandInfo.ArticleID        = ArticleID;
                        demandInfo.PositionName     = dtTempDemandInfo.Rows[i]["PositionName"].ToString();
                        demandInfo.EducationalLevel = dtTempDemandInfo.Rows[i]["EducationalLevel"].ToString();
                        demandInfo.Major            = dtTempDemandInfo.Rows[i]["Major"].ToString();
                        demandInfo.DemandNum        = Int32.Parse(dtTempDemandInfo.Rows[i]["DemandNum"].ToString());
                        demandInfo.PositionDec      = dtTempDemandInfo.Rows[i]["PositionDec"].ToString();
                        DemandInfo.Insert(demandInfo);
                    }
                }
                //最后先删掉TempDemandInfo内容,再删掉TempArticle内容
                SqlConnection conn    = DBLink.GetConnection();
                string        sqlstr1 = "delete from TempDemandInfo where TempArticleID=" + tempArticleID;
                string        sqlstr2 = "delete from TempArticle where TempArticleID=" + tempArticleID;
                SqlCommand    cmm1    = new SqlCommand(sqlstr1, conn);
                SqlCommand    cmm2    = new SqlCommand(sqlstr2, conn);
                try
                {
                    conn.Open();
                    cmm1.ExecuteNonQuery();
                    cmm2.ExecuteNonQuery();
                    cmm1.Dispose();
                    cmm2.Dispose();
                    conn.Close();
                }
                catch (Exception)
                {
                    return(false);
                }
                return(true);
            }
            if (isAgree == -1)
            {
                SqlConnection cn = DBLink.GetConnection();
                //审核信息
                string auditInfo = auditArticle.tempArticle.AuditInfo;
                //Audit=0表示拒绝了审核
                string     sqlstr = "update TempArticle set IsAudit=0,AuditInfo='" + auditInfo + "' where TempArticleID=" + tempArticleID;
                SqlCommand cmm    = new SqlCommand(sqlstr, cn);
                try
                {
                    cn.Open();
                    cmm.ExecuteNonQuery();
                    cmm.Dispose();
                    cn.Close();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            return(false);
        }