コード例 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ForKids.DB.Model.GRADEBASE model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update GRADEBASE set ");
            strSql.Append("NAME=@NAME,");
            strSql.Append("HEADTEACHERID=@HEADTEACHERID,");
            strSql.Append("TUITION=@TUITION,");
            strSql.Append("DESCRIPTION=@DESCRIPTION");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@NAME",          OleDbType.VarChar, 255),
                new OleDbParameter("@HEADTEACHERID", OleDbType.Integer,   4),
                new OleDbParameter("@TUITION",       OleDbType.Integer,   4),
                new OleDbParameter("@DESCRIPTION",   OleDbType.VarChar, 255),
                new OleDbParameter("@ID",            OleDbType.Integer, 4)
            };
            parameters[0].Value = model.NAME;
            parameters[1].Value = model.HEADTEACHERID;
            parameters[2].Value = model.TUITION;
            parameters[3].Value = model.DESCRIPTION;
            parameters[4].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(ForKids.DB.Model.GRADEBASE model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into GRADEBASE(");
            strSql.Append("NAME,HEADTEACHERID,TUITION,DESCRIPTION)");
            strSql.Append(" values (");
            strSql.Append("@NAME,@HEADTEACHERID,@TUITION,@DESCRIPTION)");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@NAME",          OleDbType.VarChar, 255),
                new OleDbParameter("@HEADTEACHERID", OleDbType.Integer,   4),
                new OleDbParameter("@TUITION",       OleDbType.Integer,   4),
                new OleDbParameter("@DESCRIPTION",   OleDbType.VarChar, 255)
            };
            parameters[0].Value = model.NAME;
            parameters[1].Value = model.HEADTEACHERID;
            parameters[2].Value = model.TUITION;
            parameters[3].Value = model.DESCRIPTION;

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

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

            strSql.Append("select ID,NAME,HEADTEACHERID,TUITION,DESCRIPTION from GRADEBASE ");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@ID", OleDbType.Integer, 4)
            };
            parameters[0].Value = ID;

            ForKids.DB.Model.GRADEBASE model = new ForKids.DB.Model.GRADEBASE();
            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]["NAME"] != null && ds.Tables[0].Rows[0]["NAME"].ToString() != "")
                {
                    model.NAME = ds.Tables[0].Rows[0]["NAME"].ToString();
                }
                if (ds.Tables[0].Rows[0]["HEADTEACHERID"] != null && ds.Tables[0].Rows[0]["HEADTEACHERID"].ToString() != "")
                {
                    model.HEADTEACHERID = int.Parse(ds.Tables[0].Rows[0]["HEADTEACHERID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TUITION"] != null && ds.Tables[0].Rows[0]["TUITION"].ToString() != "")
                {
                    model.TUITION = int.Parse(ds.Tables[0].Rows[0]["TUITION"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DESCRIPTION"] != null && ds.Tables[0].Rows[0]["DESCRIPTION"].ToString() != "")
                {
                    model.DESCRIPTION = ds.Tables[0].Rows[0]["DESCRIPTION"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #4
0
ファイル: GRADEBASE.cs プロジェクト: BaiMath/ForKids
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ForKids.DB.Model.GRADEBASE GetModel(int ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select ID,NAME,HEADTEACHERID,TUITION,DESCRIPTION from GRADEBASE ");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters = {
                    new OleDbParameter("@ID", OleDbType.Integer,4)
            };
            parameters[0].Value = ID;

            ForKids.DB.Model.GRADEBASE model=new ForKids.DB.Model.GRADEBASE();
            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]["NAME"]!=null && ds.Tables[0].Rows[0]["NAME"].ToString()!="")
                {
                    model.NAME=ds.Tables[0].Rows[0]["NAME"].ToString();
                }
                if(ds.Tables[0].Rows[0]["HEADTEACHERID"]!=null && ds.Tables[0].Rows[0]["HEADTEACHERID"].ToString()!="")
                {
                    model.HEADTEACHERID=int.Parse(ds.Tables[0].Rows[0]["HEADTEACHERID"].ToString());
                }
                if(ds.Tables[0].Rows[0]["TUITION"]!=null && ds.Tables[0].Rows[0]["TUITION"].ToString()!="")
                {
                    model.TUITION=int.Parse(ds.Tables[0].Rows[0]["TUITION"].ToString());
                }
                if(ds.Tables[0].Rows[0]["DESCRIPTION"]!=null && ds.Tables[0].Rows[0]["DESCRIPTION"].ToString()!="")
                {
                    model.DESCRIPTION=ds.Tables[0].Rows[0]["DESCRIPTION"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }