public static async void InsertHWCfgModule(HWCfgModule module) { //6 SpecifiedIndex var sql = "insert into HWCfgModule values('{0}','{1}','{2}',{3},'{4}',{5},{6},{7},{8},'{9}',{10},{11},{12})"; var list = new List <HWCfgModule>(); using (var conn = DBFactory.Create()) { conn.Open(); sql = string.Format(sql, module.InstrumentName, module.HWName, module.ModelName, module.ModelIndex, module.ModuleClassify, module.Channel, module.SpecifiedIndex, module.Active, module.ModuleNo, module.ModuleName, module.ModulesOccupy, module.ChannelsOccupy, module.ChannelsPresent); var cmd = conn.CreateCommand() as DbCommand; cmd.CommandText = sql; await cmd.ExecuteNonQueryAsync(); } }
private static async Task <List <HWCfgModule> > HWCfgModuleList(string condition) { var list = new List <HWCfgModule>(); var sql = "select * from HWCfgModule " + condition; using (var conn = DBFactory.Create()) { conn.Open(); var cmd = conn.CreateCommand() as DbCommand; cmd.CommandText = sql; var reader = await cmd.ExecuteReaderAsync(); while (reader.Read()) { var model = new HWCfgModule(); model.HWName = reader["HWName"].ToString(); model.InstrumentName = reader["InstrumentName"].ToString(); model.ModelName = reader["ModelName"].ToString(); model.ModelIndex = reader["ModelIndex"].ToInt32(); model.ModuleClassify = reader["ModuleClassify"].ToString(); model.Channel = reader["Channel"].ToInt32(); model.SpecifiedIndex = reader["SpecifiedIndex"].ToInt32(); model.ModuleNo = reader["ModuleNo"].ToInt32(); model.ModuleName = reader["ModuleName"].ToString(); model.ModulesOccupy = reader["ModulesOccupy"].ToInt32(); model.ChannelsOccupy = reader["ChannelsOccupy"].ToInt32(); model.ChannelsPresent = reader["ChannelsPresent"].ToInt32(); model.Active = reader["Active"].ToInt32(); list.Add(model); } return(list); } }