/// <summary> /// 增加一条数据 /// </summary> public int Add(ROYcms.Sys.Model.ROYcms_Jurisdiction model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ROYcms_Jurisdiction("); strSql.Append("JID,AdminID,ClassID,ClassKind,CreateTime)"); strSql.Append(" values ("); strSql.Append("@JID,@AdminID,@ClassID,@ClassKind,@CreateTime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@JID", SqlDbType.VarChar, 50), new SqlParameter("@AdminID", SqlDbType.Int, 4), new SqlParameter("@ClassID", SqlDbType.Int, 4), new SqlParameter("@ClassKind", SqlDbType.VarChar, 100), new SqlParameter("@CreateTime", SqlDbType.DateTime) }; parameters[0].Value = model.JID; parameters[1].Value = model.AdminID; parameters[2].Value = model.ClassID; parameters[3].Value = model.ClassKind; parameters[4].Value = model.CreateTime; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public ROYcms.Sys.Model.ROYcms_Jurisdiction GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,JID,AdminID,ClassID,ClassKind,CreateTime from ROYcms_Jurisdiction "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; ROYcms.Sys.Model.ROYcms_Jurisdiction model = new ROYcms.Sys.Model.ROYcms_Jurisdiction(); DataSet ds = DbHelperSQL.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]["JID"] != null && ds.Tables[0].Rows[0]["JID"].ToString() != "") { model.JID = ds.Tables[0].Rows[0]["JID"].ToString(); } if (ds.Tables[0].Rows[0]["AdminID"] != null && ds.Tables[0].Rows[0]["AdminID"].ToString() != "") { model.AdminID = int.Parse(ds.Tables[0].Rows[0]["AdminID"].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]["ClassKind"] != null && ds.Tables[0].Rows[0]["ClassKind"].ToString() != "") { model.ClassKind = ds.Tables[0].Rows[0]["ClassKind"].ToString(); } if (ds.Tables[0].Rows[0]["CreateTime"] != null && ds.Tables[0].Rows[0]["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ROYcms.Sys.Model.ROYcms_Jurisdiction model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ROYcms_Jurisdiction set "); strSql.Append("JID=@JID,"); strSql.Append("AdminID=@AdminID,"); strSql.Append("ClassID=@ClassID,"); strSql.Append("ClassKind=@ClassKind,"); strSql.Append("CreateTime=@CreateTime"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@JID", SqlDbType.VarChar, 50), new SqlParameter("@AdminID", SqlDbType.Int, 4), new SqlParameter("@ClassID", SqlDbType.Int, 4), new SqlParameter("@ClassKind", SqlDbType.VarChar, 100), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.JID; parameters[1].Value = model.AdminID; parameters[2].Value = model.ClassID; parameters[3].Value = model.ClassKind; parameters[4].Value = model.CreateTime; parameters[5].Value = model.Id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }