/// <summary> /// 得到一个对象实体 /// </summary> public CardCenter.Entity.HandleLog DataRowToModel(DataRow row) { CardCenter.Entity.HandleLog model = new CardCenter.Entity.HandleLog(); if (row != null) { if (row["Guid"] != null) { model.Guid = row["Guid"].ToString(); } if (row["LastOpeartion"] != null) { model.LastOpeartion = row["LastOpeartion"].ToString(); } if (row["LastRemark"] != null) { model.LastRemark = row["LastRemark"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(CardCenter.Entity.HandleLog model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into HandleLog("); strSql.Append("Guid,LastOpeartion,LastRemark)"); strSql.Append(" values ("); strSql.Append("@Guid,@LastOpeartion,@LastRemark)"); SqlParameter[] parameters = { new SqlParameter("@Guid", SqlDbType.NVarChar, 64), new SqlParameter("@LastOpeartion", SqlDbType.NVarChar, 8), new SqlParameter("@LastRemark", SqlDbType.NVarChar, 512) }; parameters[0].Value = model.Guid; parameters[1].Value = model.LastOpeartion; parameters[2].Value = model.LastRemark; TranHelper.AddTran(strSql, parameters); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(CardCenter.Entity.HandleLog model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update HandleLog set "); strSql.Append("Guid=@Guid,"); strSql.Append("LastOpeartion=@LastOpeartion,"); strSql.Append("LastRemark=@LastRemark"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@Guid", SqlDbType.NVarChar, 64), new SqlParameter("@LastOpeartion", SqlDbType.NVarChar, 8), new SqlParameter("@LastRemark", SqlDbType.NVarChar, 512) }; parameters[0].Value = model.Guid; parameters[1].Value = model.LastOpeartion; parameters[2].Value = model.LastRemark; TranHelper.AddTran(strSql, parameters); }
/// <summary> /// 得到一个对象实体 /// </summary> public CardCenter.Entity.HandleLog GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Guid,LastOpeartion,LastRemark from HandleLog "); strSql.Append(" where "); SqlParameter[] parameters = { }; CardCenter.Entity.HandleLog model = new CardCenter.Entity.HandleLog(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }