/// <summary> /// 更新一条数据 /// </summary> public bool Update(ForKids.DB.Model.COURSEBASE model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update COURSEBASE set "); strSql.Append("NAME=@NAME,"); strSql.Append("GRADEID=@GRADEID,"); strSql.Append("DESCRIPTION=@DESCRIPTION"); strSql.Append(" where ID=@ID"); OleDbParameter[] parameters = { new OleDbParameter("@NAME", OleDbType.VarChar, 20), new OleDbParameter("@GRADEID", OleDbType.Integer, 4), new OleDbParameter("@DESCRIPTION", OleDbType.VarChar, 255), new OleDbParameter("@ID", OleDbType.Integer, 4) }; parameters[0].Value = model.NAME; parameters[1].Value = model.GRADEID; parameters[2].Value = model.DESCRIPTION; parameters[3].Value = model.ID; int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(ForKids.DB.Model.COURSEBASE model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into COURSEBASE("); strSql.Append("NAME,GRADEID,DESCRIPTION)"); strSql.Append(" values ("); strSql.Append("@NAME,@GRADEID,@DESCRIPTION)"); OleDbParameter[] parameters = { new OleDbParameter("@NAME", OleDbType.VarChar, 20), new OleDbParameter("@GRADEID", OleDbType.Integer, 4), new OleDbParameter("@DESCRIPTION", OleDbType.VarChar, 255) }; parameters[0].Value = model.NAME; parameters[1].Value = model.GRADEID; parameters[2].Value = model.DESCRIPTION; int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public ForKids.DB.Model.COURSEBASE GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ID,NAME,GRADEID,DESCRIPTION from COURSEBASE "); strSql.Append(" where ID=@ID"); OleDbParameter[] parameters = { new OleDbParameter("@ID", OleDbType.Integer, 4) }; parameters[0].Value = ID; ForKids.DB.Model.COURSEBASE model = new ForKids.DB.Model.COURSEBASE(); 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]["GRADEID"] != null && ds.Tables[0].Rows[0]["GRADEID"].ToString() != "") { model.GRADEID = int.Parse(ds.Tables[0].Rows[0]["GRADEID"].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); } }
/// <summary> /// 得到一个对象实体 /// </summary> public ForKids.DB.Model.COURSEBASE GetModel(int ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select ID,NAME,GRADEID,DESCRIPTION from COURSEBASE "); strSql.Append(" where ID=@ID"); OleDbParameter[] parameters = { new OleDbParameter("@ID", OleDbType.Integer,4) }; parameters[0].Value = ID; ForKids.DB.Model.COURSEBASE model=new ForKids.DB.Model.COURSEBASE(); 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]["GRADEID"]!=null && ds.Tables[0].Rows[0]["GRADEID"].ToString()!="") { model.GRADEID=int.Parse(ds.Tables[0].Rows[0]["GRADEID"].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; } }