Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(LearnSite.Model.SurveyFeedback model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SurveyFeedback set ");
            strSql.Append("Fnum=@Fnum,");
            strSql.Append("Fyear=@Fyear,");
            strSql.Append("Fgrade=@Fgrade,");
            strSql.Append("Fclass=@Fclass,");
            strSql.Append("Fterm=@Fterm,");
            strSql.Append("Fcid=@Fcid,");
            strSql.Append("Fvid=@Fvid,");
            strSql.Append("Fvtype=@Fvtype,");
            strSql.Append("Fselect=@Fselect,");
            strSql.Append("Fscore=@Fscore,");
            strSql.Append("Fdate=@Fdate");
            strSql.Append(" where Fid=@Fid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Fnum",    SqlDbType.NVarChar,  50),
                new SqlParameter("@Fyear",   SqlDbType.Int,        4),
                new SqlParameter("@Fgrade",  SqlDbType.Int,        4),
                new SqlParameter("@Fclass",  SqlDbType.Int,        4),
                new SqlParameter("@Fterm",   SqlDbType.Int,        4),
                new SqlParameter("@Fcid",    SqlDbType.Int,        4),
                new SqlParameter("@Fvid",    SqlDbType.Int,        4),
                new SqlParameter("@Fvtype",  SqlDbType.Int,        4),
                new SqlParameter("@Fselect", SqlDbType.NText),
                new SqlParameter("@Fscore",  SqlDbType.Int,        4),
                new SqlParameter("@Fdate",   SqlDbType.DateTime),
                new SqlParameter("@Fid",     SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.Fnum;
            parameters[1].Value  = model.Fyear;
            parameters[2].Value  = model.Fgrade;
            parameters[3].Value  = model.Fclass;
            parameters[4].Value  = model.Fterm;
            parameters[5].Value  = model.Fcid;
            parameters[6].Value  = model.Fvid;
            parameters[7].Value  = model.Fvtype;
            parameters[8].Value  = model.Fselect;
            parameters[9].Value  = model.Fscore;
            parameters[10].Value = model.Fdate;
            parameters[11].Value = model.Fid;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(LearnSite.Model.SurveyFeedback model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SurveyFeedback(");
            strSql.Append("Fnum,Fyear,Fgrade,Fclass,Fterm,Fcid,Fvid,Fvtype,Fselect,Fscore,Fdate,Fsid)");
            strSql.Append(" values (");
            strSql.Append("@Fnum,@Fyear,@Fgrade,@Fclass,@Fterm,@Fcid,@Fvid,@Fvtype,@Fselect,@Fscore,@Fdate,@Fsid)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Fnum",    SqlDbType.NVarChar,  50),
                new SqlParameter("@Fyear",   SqlDbType.Int,        4),
                new SqlParameter("@Fgrade",  SqlDbType.Int,        4),
                new SqlParameter("@Fclass",  SqlDbType.Int,        4),
                new SqlParameter("@Fterm",   SqlDbType.Int,        4),
                new SqlParameter("@Fcid",    SqlDbType.Int,        4),
                new SqlParameter("@Fvid",    SqlDbType.Int,        4),
                new SqlParameter("@Fvtype",  SqlDbType.Int,        4),
                new SqlParameter("@Fselect", SqlDbType.NText),
                new SqlParameter("@Fscore",  SqlDbType.Int,        4),
                new SqlParameter("@Fdate",   SqlDbType.DateTime),
                new SqlParameter("@Fsid",    SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.Fnum;
            parameters[1].Value  = model.Fyear;
            parameters[2].Value  = model.Fgrade;
            parameters[3].Value  = model.Fclass;
            parameters[4].Value  = model.Fterm;
            parameters[5].Value  = model.Fcid;
            parameters[6].Value  = model.Fvid;
            parameters[7].Value  = model.Fvtype;
            parameters[8].Value  = model.Fselect;
            parameters[9].Value  = model.Fscore;
            parameters[10].Value = model.Fdate;
            parameters[11].Value = model.Fsid;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LearnSite.Model.SurveyFeedback GetModel(int Fid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Fid,Fnum,Fyear,Fgrade,Fclass,Fterm,Fcid,Fvid,Fvtype,Fselect,Fscore,Fdate from SurveyFeedback ");
            strSql.Append(" where Fid=@Fid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Fid", SqlDbType.Int, 4)
            };
            parameters[0].Value = Fid;

            LearnSite.Model.SurveyFeedback model = new LearnSite.Model.SurveyFeedback();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Fid"] != null && ds.Tables[0].Rows[0]["Fid"].ToString() != "")
                {
                    model.Fid = int.Parse(ds.Tables[0].Rows[0]["Fid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fnum"] != null && ds.Tables[0].Rows[0]["Fnum"].ToString() != "")
                {
                    model.Fnum = ds.Tables[0].Rows[0]["Fnum"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Fyear"] != null && ds.Tables[0].Rows[0]["Fyear"].ToString() != "")
                {
                    model.Fyear = int.Parse(ds.Tables[0].Rows[0]["Fyear"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fgrade"] != null && ds.Tables[0].Rows[0]["Fgrade"].ToString() != "")
                {
                    model.Fgrade = int.Parse(ds.Tables[0].Rows[0]["Fgrade"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fclass"] != null && ds.Tables[0].Rows[0]["Fclass"].ToString() != "")
                {
                    model.Fclass = int.Parse(ds.Tables[0].Rows[0]["Fclass"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fterm"] != null && ds.Tables[0].Rows[0]["Fterm"].ToString() != "")
                {
                    model.Fterm = int.Parse(ds.Tables[0].Rows[0]["Fterm"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fcid"] != null && ds.Tables[0].Rows[0]["Fcid"].ToString() != "")
                {
                    model.Fcid = int.Parse(ds.Tables[0].Rows[0]["Fcid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fvid"] != null && ds.Tables[0].Rows[0]["Fvid"].ToString() != "")
                {
                    model.Fvid = int.Parse(ds.Tables[0].Rows[0]["Fvid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fvtype"] != null && ds.Tables[0].Rows[0]["Fvtype"].ToString() != "")
                {
                    model.Fvtype = int.Parse(ds.Tables[0].Rows[0]["Fvtype"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fselect"] != null && ds.Tables[0].Rows[0]["Fselect"].ToString() != "")
                {
                    model.Fselect = ds.Tables[0].Rows[0]["Fselect"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Fscore"] != null && ds.Tables[0].Rows[0]["Fscore"].ToString() != "")
                {
                    model.Fscore = int.Parse(ds.Tables[0].Rows[0]["Fscore"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Fdate"] != null && ds.Tables[0].Rows[0]["Fdate"].ToString() != "")
                {
                    model.Fdate = DateTime.Parse(ds.Tables[0].Rows[0]["Fdate"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }