/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.Dictionary model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Dictionary set "); strSql.Append("Idx=@Idx,"); strSql.Append("Caption=@Caption,"); strSql.Append("Note=@Note"); strSql.Append(" where CatgID=@CatgID "); SqlParameter[] parameters = { new SqlParameter("@Idx", SqlDbType.Int, 4), new SqlParameter("@Caption", SqlDbType.NVarChar, 50), new SqlParameter("@Note", SqlDbType.NVarChar, 50), new SqlParameter("@CatgID", SqlDbType.Int, 4) }; parameters[0].Value = model.Idx; parameters[1].Value = model.Caption; parameters[2].Value = model.Note; parameters[3].Value = model.CatgID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Maticsoft.Model.Dictionary model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Dictionary("); strSql.Append("Idx,CatgID,Caption,Note)"); strSql.Append(" values ("); strSql.Append("@Idx,@CatgID,@Caption,@Note)"); SqlParameter[] parameters = { new SqlParameter("@Idx", SqlDbType.Int, 4), new SqlParameter("@CatgID", SqlDbType.Int, 4), new SqlParameter("@Caption", SqlDbType.NVarChar, 50), new SqlParameter("@Note", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.Idx; parameters[1].Value = model.CatgID; parameters[2].Value = model.Caption; parameters[3].Value = model.Note; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Dictionary DataRowToModel(DataRow row) { Maticsoft.Model.Dictionary model = new Maticsoft.Model.Dictionary(); if (row != null) { if (row["Idx"] != null && row["Idx"].ToString() != "") { model.Idx = int.Parse(row["Idx"].ToString()); } if (row["CatgID"] != null && row["CatgID"].ToString() != "") { model.CatgID = int.Parse(row["CatgID"].ToString()); } if (row["Caption"] != null) { model.Caption = row["Caption"].ToString(); } if (row["Note"] != null) { model.Note = row["Note"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Dictionary GetModel(int CatgID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Idx,CatgID,Caption,Note from Dictionary "); strSql.Append(" where CatgID=@CatgID "); SqlParameter[] parameters = { new SqlParameter("@CatgID", SqlDbType.Int, 4) }; parameters[0].Value = CatgID; Maticsoft.Model.Dictionary model = new Maticsoft.Model.Dictionary(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }