示例#1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(ForKids.DB.Model.CLASSCOURSE model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CLASSCOURSE(");
            strSql.Append("CLASSID,COURSEID,ATTENDANCE,TEACHERID,SUMMARY)");
            strSql.Append(" values (");
            strSql.Append("@CLASSID,@COURSEID,@ATTENDANCE,@TEACHERID,@SUMMARY)");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@CLASSID",    OleDbType.Integer, 4),
                new OleDbParameter("@COURSEID",   OleDbType.Integer, 4),
                new OleDbParameter("@ATTENDANCE", OleDbType.Double),
                new OleDbParameter("@TEACHERID",  OleDbType.Integer, 4),
                new OleDbParameter("@SUMMARY",    OleDbType.VarChar, 255)
            };
            parameters[0].Value = model.CLASSID;
            parameters[1].Value = model.COURSEID;
            parameters[2].Value = model.ATTENDANCE;
            parameters[3].Value = model.TEACHERID;
            parameters[4].Value = model.SUMMARY;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ForKids.DB.Model.CLASSCOURSE GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,CLASSID,COURSEID,ATTENDANCE,TEACHERID,SUMMARY from CLASSCOURSE ");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@ID", OleDbType.Integer, 4)
            };
            parameters[0].Value = ID;

            ForKids.DB.Model.CLASSCOURSE model = new ForKids.DB.Model.CLASSCOURSE();
            DataSet ds = DbHelperOleDb.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CLASSID"] != null && ds.Tables[0].Rows[0]["CLASSID"].ToString() != "")
                {
                    model.CLASSID = int.Parse(ds.Tables[0].Rows[0]["CLASSID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["COURSEID"] != null && ds.Tables[0].Rows[0]["COURSEID"].ToString() != "")
                {
                    model.COURSEID = int.Parse(ds.Tables[0].Rows[0]["COURSEID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ATTENDANCE"] != null && ds.Tables[0].Rows[0]["ATTENDANCE"].ToString() != "")
                {
                    model.ATTENDANCE = double.Parse(ds.Tables[0].Rows[0]["ATTENDANCE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TEACHERID"] != null && ds.Tables[0].Rows[0]["TEACHERID"].ToString() != "")
                {
                    model.TEACHERID = int.Parse(ds.Tables[0].Rows[0]["TEACHERID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SUMMARY"] != null && ds.Tables[0].Rows[0]["SUMMARY"].ToString() != "")
                {
                    model.SUMMARY = ds.Tables[0].Rows[0]["SUMMARY"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ForKids.DB.Model.CLASSCOURSE model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update CLASSCOURSE set ");
            strSql.Append("CLASSID=@CLASSID,");
            strSql.Append("COURSEID=@COURSEID,");
            strSql.Append("ATTENDANCE=@ATTENDANCE,");
            strSql.Append("TEACHERID=@TEACHERID,");
            strSql.Append("SUMMARY=@SUMMARY");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@CLASSID",    OleDbType.Integer,   4),
                new OleDbParameter("@COURSEID",   OleDbType.Integer,   4),
                new OleDbParameter("@ATTENDANCE", OleDbType.Double),
                new OleDbParameter("@TEACHERID",  OleDbType.Integer,   4),
                new OleDbParameter("@SUMMARY",    OleDbType.VarChar, 255),
                new OleDbParameter("@ID",         OleDbType.Integer, 4)
            };
            parameters[0].Value = model.CLASSID;
            parameters[1].Value = model.COURSEID;
            parameters[2].Value = model.ATTENDANCE;
            parameters[3].Value = model.TEACHERID;
            parameters[4].Value = model.SUMMARY;
            parameters[5].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ForKids.DB.Model.CLASSCOURSE GetModel(int ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select ID,CLASSID,COURSEID,ATTENDANCE,TEACHERID,SUMMARY from CLASSCOURSE ");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters = {
                    new OleDbParameter("@ID", OleDbType.Integer,4)
            };
            parameters[0].Value = ID;

            ForKids.DB.Model.CLASSCOURSE model=new ForKids.DB.Model.CLASSCOURSE();
            DataSet ds=DbHelperOleDb.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                if(ds.Tables[0].Rows[0]["ID"]!=null && ds.Tables[0].Rows[0]["ID"].ToString()!="")
                {
                    model.ID=int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if(ds.Tables[0].Rows[0]["CLASSID"]!=null && ds.Tables[0].Rows[0]["CLASSID"].ToString()!="")
                {
                    //model.CLASSID=ds.Tables[0].Rows[0]["CLASSID"].ToString();
                }
                if(ds.Tables[0].Rows[0]["COURSEID"]!=null && ds.Tables[0].Rows[0]["COURSEID"].ToString()!="")
                {
                    //model.COURSEID=ds.Tables[0].Rows[0]["COURSEID"].ToString();
                }
                if(ds.Tables[0].Rows[0]["ATTENDANCE"]!=null && ds.Tables[0].Rows[0]["ATTENDANCE"].ToString()!="")
                {
                    //model.ATTENDANCE=ds.Tables[0].Rows[0]["ATTENDANCE"].ToString();
                }
                if(ds.Tables[0].Rows[0]["TEACHERID"]!=null && ds.Tables[0].Rows[0]["TEACHERID"].ToString()!="")
                {
                    //model.TEACHERID=ds.Tables[0].Rows[0]["TEACHERID"].ToString();
                }
                if(ds.Tables[0].Rows[0]["SUMMARY"]!=null && ds.Tables[0].Rows[0]["SUMMARY"].ToString()!="")
                {
                    model.SUMMARY=ds.Tables[0].Rows[0]["SUMMARY"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }