/// <summary> /// 更新一条数据 /// </summary> public bool Update(Eday.Model.ISOTrain_Course model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ISOTrain_Course set "); strSql.Append("ID=@ID,"); strSql.Append("CourseCode=@CourseCode,"); strSql.Append("CourseRevision=@CourseRevision,"); strSql.Append("EffectiveDate=@EffectiveDate,"); strSql.Append("bak1=@bak1,"); strSql.Append("bak2=@bak2,"); strSql.Append("bak3=@bak3,"); strSql.Append("bak4=@bak4,"); strSql.Append("bak5=@bak5"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.NVarChar, 50), new SqlParameter("@CourseCode", SqlDbType.NVarChar, 50), new SqlParameter("@CourseRevision", SqlDbType.NVarChar, 50), new SqlParameter("@EffectiveDate", SqlDbType.DateTime), new SqlParameter("@bak1", SqlDbType.NVarChar, 50), new SqlParameter("@bak2", SqlDbType.NVarChar, 50), new SqlParameter("@bak3", SqlDbType.NVarChar, 50), new SqlParameter("@bak4", SqlDbType.NVarChar, 50), new SqlParameter("@bak5", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.ID; parameters[1].Value = model.CourseCode; parameters[2].Value = model.CourseRevision; parameters[3].Value = model.EffectiveDate; parameters[4].Value = model.bak1; parameters[5].Value = model.bak2; parameters[6].Value = model.bak3; parameters[7].Value = model.bak4; parameters[8].Value = model.bak5; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Eday.Model.ISOTrain_Course DataRowToModel(DataRow row) { Eday.Model.ISOTrain_Course model = new Eday.Model.ISOTrain_Course(); if (row != null) { if (row["ID"] != null) { model.ID = row["ID"].ToString(); } if (row["CourseCode"] != null) { model.CourseCode = row["CourseCode"].ToString(); } if (row["CourseRevision"] != null) { model.CourseRevision = row["CourseRevision"].ToString(); } if (row["EffectiveDate"] != null && row["EffectiveDate"].ToString() != "") { model.EffectiveDate = DateTime.Parse(row["EffectiveDate"].ToString()); } if (row["bak1"] != null) { model.bak1 = row["bak1"].ToString(); } if (row["bak2"] != null) { model.bak2 = row["bak2"].ToString(); } if (row["bak3"] != null) { model.bak3 = row["bak3"].ToString(); } if (row["bak4"] != null) { model.bak4 = row["bak4"].ToString(); } if (row["bak5"] != null) { model.bak5 = row["bak5"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Eday.Model.ISOTrain_Course model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ISOTrain_Course("); strSql.Append("ID,CourseCode,CourseRevision,EffectiveDate,bak1,bak2,bak3,bak4,bak5)"); strSql.Append(" values ("); strSql.Append("@ID,@CourseCode,@CourseRevision,@EffectiveDate,@bak1,@bak2,@bak3,@bak4,@bak5)"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.NVarChar, 50), new SqlParameter("@CourseCode", SqlDbType.NVarChar, 50), new SqlParameter("@CourseRevision", SqlDbType.NVarChar, 50), new SqlParameter("@EffectiveDate", SqlDbType.DateTime), new SqlParameter("@bak1", SqlDbType.NVarChar, 50), new SqlParameter("@bak2", SqlDbType.NVarChar, 50), new SqlParameter("@bak3", SqlDbType.NVarChar, 50), new SqlParameter("@bak4", SqlDbType.NVarChar, 50), new SqlParameter("@bak5", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.ID; parameters[1].Value = model.CourseCode; parameters[2].Value = model.CourseRevision; parameters[3].Value = model.EffectiveDate; parameters[4].Value = model.bak1; parameters[5].Value = model.bak2; parameters[6].Value = model.bak3; parameters[7].Value = model.bak4; parameters[8].Value = model.bak5; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Eday.Model.ISOTrain_Course GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,CourseCode,CourseRevision,EffectiveDate,bak1,bak2,bak3,bak4,bak5 from ISOTrain_Course "); strSql.Append(" where "); SqlParameter[] parameters = { }; Eday.Model.ISOTrain_Course model = new Eday.Model.ISOTrain_Course(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }