Exemple #1
0
        /// <summary>
        /// 供给创建文章使用
        /// </summary>
        /// <param name="article"></param>
        /// <returns></returns>
        public static int InsertTempArticle(TempArticle article)
        {
            int ID = 0;//存储执行insert存储过程返回的ID

            SqlConnection conn = DBLink.GetConnection();

            conn.Open();
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = conn;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "TempArticleInsert";
            //cmd.Parameters.Add(new SqlParameter("@ArticleID", article.ArticleID));  //注释的部分都是存储过程中默认值是null的
            cmd.Parameters.Add(new SqlParameter("@TypeID", article.TypeID));
            cmd.Parameters.Add(new SqlParameter("@Title", article.Title));
            cmd.Parameters.Add(new SqlParameter("@Introduction", article.Introduction));
            //cmd.Parameters.Add(new SqlParameter("@PlaceSecondID", article.PlaceSecondID));
            cmd.Parameters.Add(new SqlParameter("@EditTime", article.EditTime));
            cmd.Parameters.Add(new SqlParameter("@EditorAccount", article.EditorAccount));
            cmd.Parameters.Add(new SqlParameter("@ContactInfo", article.ContactInfo));
            if (article.TypeID == 1)  //专场招聘
            {
                cmd.Parameters.Add(new SqlParameter("@PlaceFirstID", article.PlaceFirstID));
                cmd.Parameters.Add(new SqlParameter("@RecruitTime", article.RecruitTime));
            }
            else
            {
                cmd.Parameters.Add(new SqlParameter("@PlaceFirstID", DBNull.Value));
                cmd.Parameters.Add(new SqlParameter("@RecruitTime", DBNull.Value));
            }

            if (article.FileAddr == null || article.FileAddr == "")
            {
                cmd.Parameters.Add(new SqlParameter("@FileAddr", DBNull.Value));
            }
            else
            {
                cmd.Parameters.Add(new SqlParameter("@FileAddr", article.FileAddr));
            }
            cmd.Parameters.Add(new SqlParameter("@ArticleDescription", article.ArticleDescription));
            cmd.Parameters.Add(new SqlParameter("@BigArticleID", article.BigArticleID));
            cmd.Parameters.Add(new SqlParameter("@IsAudit", article.IsAudit));

            try { ID = Convert.ToInt32(cmd.ExecuteScalar()); }
            catch
            {
                return(-1); //如果出错,返回-1
            }
            finally
            {
                cmd.Dispose();
                conn.Close();
            }
            return(ID);//如果没有出错,返回ID
        }
Exemple #2
0
 public AllModel(Admin admin, News news, ArticleType articleType, Article article, List <DemandInfo> demandInfo, TempArticle tempArticle, List <TempDemandInfo> tempDemandInfo, PlaceListFirst placeListFirst, PlaceListSecond placeListSecond, Employer employer)
 {
     this.admin           = admin;
     this.news            = news;
     this.articleType     = articleType;
     this.article         = article;
     this.demandInfo      = demandInfo;
     this.tempArticle     = tempArticle;
     this.tempDemandInfo  = tempDemandInfo;
     this.placeListFirst  = placeListFirst;
     this.placeListSecond = placeListSecond;
     this.employer        = employer;
 }
Exemple #3
0
        public static bool Update(TempArticle article)
        {
            SqlConnection conn = DBLink.GetConnection();

            conn.Open();
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = conn;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "TempArticleUpdate";
            cmd.Parameters.Add(new SqlParameter("@TempArticleID", article.TempArticleID));
            cmd.Parameters.Add(new SqlParameter("@Title", article.Title));
            cmd.Parameters.Add(new SqlParameter("@Introduction", article.Introduction));
            cmd.Parameters.Add(new SqlParameter("@ContactInfo", article.ContactInfo));
            if (article.TypeID == 1)
            {//专场招聘
                cmd.Parameters.Add(new SqlParameter("@PlaceFirstID", article.PlaceFirstID));
                cmd.Parameters.Add(new SqlParameter("@RecruitTime", article.RecruitTime));
            }
            else
            {
                cmd.Parameters.Add(new SqlParameter("@PlaceFirstID", DBNull.Value));
                cmd.Parameters.Add(new SqlParameter("@RecruitTime", DBNull.Value));
            }

            if (article.FileAddr == null || article.FileAddr == "")
            {
                cmd.Parameters.Add(new SqlParameter("@FileAddr", DBNull.Value));
            }
            else
            {
                cmd.Parameters.Add(new SqlParameter("@FileAddr", article.FileAddr));
            }
            cmd.Parameters.Add(new SqlParameter("@BigArticleID", article.BigArticleID));
            cmd.Parameters.Add(new SqlParameter("@ArticleDescription", article.ArticleDescription));
            cmd.Parameters.Add(new SqlParameter("@IsAudit", article.IsAudit));
            try
            {
                cmd.ExecuteNonQuery();
            }
            catch
            {
                return(false); //如果出错,返回false
            }
            finally
            {
                cmd.Dispose();
                conn.Close();
            }
            return(true);//如果没有出错,返回true
        }
Exemple #4
0
        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);
        }