private int RunCommandWithTransatcion(VSM.Entities.BuKindInfo ent, string vSql, IDbTransaction TRANS) { if (null == TRANS) { MySqlParameter[] paras = new MySqlParameter[ent.Column.Count]; for (int i = 0; i < ent.Column.Count; i++) { paras[i] = new MySqlParameter(); paras[i].ParameterName = ent.Column[i].FieldName; paras[i].DbType = ent.Column[i].FieldType; paras[i].Value = ent.Column[i].FieldValue; } return(DataBaseManage.ExecuteSql(vSql, paras)); } else { System.Data.IDbCommand CM = TRANS.Connection.CreateCommand(); CM.CommandText = vSql; CM.CommandType = CommandType.Text; CM.Transaction = TRANS; GetEntityDeleteParameter(CM, ent); try { return(CM.ExecuteNonQuery()); } catch (System.Exception e) { if (isDebug) { throw new Exception(e.Message); } return(0); } } }
/// <summary> /// 得到列表 /// </summary> /// <param name="ent"></param> /// <returns></returns> public List<BuKindInfo> GetBuKindInfoList(string Where) { List<BuKindInfo> list = new List<BuKindInfo>(); using(DbDataReader reader = DataBaseManage.ExecuteReader(DalSql+Where)) { while (reader.Read()) { BuKindInfo ent = new BuKindInfo(); SetEnt(ent, reader); list.Add(ent); } } return list; }
/// <summary> /// 根据KindId得到 BuKindInfo 实体 /// </summary> /// <param name="ent"></param> /// <returns></returns> public BuKindInfo GetBuKindInfo(int KindId) { BuKindInfo ent = null; string sql = DalSql; sql = sql + " And KindId"; MySqlParameter[] paras = new MySqlParameter[] { new MySqlParameter("KindId",KindId) }; using(DbDataReader reader = DataBaseManage.ExecuteReader(sql, paras)) { if (reader.Read()) { ent = new BuKindInfo(); SetEnt(ent, reader); } } return ent; }
public void SetEnt(BuKindInfo ent, IDataReader dr) { ent.KindId = MyConvert.ToInt(dr["KindId"]); ent.KindName = MyConvert.ToString(dr["KindName"]); }