private static async Task <List <HWCfgModel> > HWCfgModelList(string condition) { var list = new List <HWCfgModel>(); var sql = "select * from HWCfgModel " + 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 HWCfgModel(); model.HWName = reader["HWName"].ToString(); model.InstrumentName = reader["InstrumentName"].ToString(); model.ModelName = reader["ModelName"].ToString(); model.ModelIndex = reader["ModelIndex"].ToInt32(); model.Interface = reader["Interface"].ToString(); model.InterfaceParameter = reader["InterfaceParameter"].ToString(); model.ModulesMax = reader["ModulesMax"].ToInt32(); model.ChannelsPerModule = reader["ChannelsPerModule"].ToInt32(); model.SubDevices = reader["SubDevices"].ToString(); model.ModuleClassify = reader["ModuleClassify"].ToString(); model.Active = reader["Active"].ToInt32(); list.Add(model); } return(list); } }
public static async void Insert(HWCfgModel model) { try { var sql = "insert into HWCfgModel values('{0}','{1}','{2}',{3},'{4}','{5}',{6},{7},'{8}','{9}',{10})"; using (var conn = DBFactory.Create()) { conn.Open(); sql = string.Format(sql, model.ModelName, model.HWName, model.InstrumentName, model.ModelIndex, model.Interface, model.InterfaceParameter, model.ModulesMax, model.ChannelsPerModule, model.SubDevices, model.ModuleClassify, model.Active ); var cmd = conn.CreateCommand() as DbCommand; cmd.CommandText = sql; await cmd.ExecuteNonQueryAsync(); } } catch (Exception e) { } }
private void tsmiAddFZ_Click(object sender, EventArgs e) { var memuItem = sender as ToolStripItem; var node = memuItem.Tag as TreeNode; var window = new FrmModelType(node.Tag.ToString()); var dialog = window.ShowDialog(); if (dialog == DialogResult.OK) { var modeltype = window.ModelList; var subNode = new TreeNode(modeltype.ModelName); var array = node.Tag.ToString().Split(splitchar); var model = new HWCfgModel(); model.ModelName = modeltype.ModelName; model.HWName = array[0]; model.InstrumentName = array[1]; model.Interface = modeltype.InterfaceAvailable; model.InterfaceParameter = modeltype.DefaultParameter; model.ModelIndex = node.Nodes.Count + 1; subNode.Tag = model; subNode.ContextMenuStrip = GetDeleteContextMenuStrip(node); node.Nodes.Add(subNode); if (node.IsExpanded == false) { node.Expand(); } modelList.Add(model); } }
public static async void DeleteModel(HWCfgModel model) { var sql = "delete from HWCfgModel where HWName='{0}' and InstrumentName='{1}' and ModelName='{2}' and ModelIndex={3}"; sql = string.Format(sql, model.HWName, model.InstrumentName, model.ModelName, model.ModelIndex); using (var conn = DBFactory.Create()) { conn.Open(); var cmd = conn.CreateCommand() as DbCommand; cmd.CommandText = sql; await cmd.ExecuteNonQueryAsync(); } }
public static async void UpdateModel(HWCfgModel model) { var list = new List <HWCfgModel>(); var sql = "update HWCfgModel set "; sql += "InterfaceParameter='{0}' "; sql += "where "; sql = string.Format(sql, model.InterfaceParameter); using (var conn = DBFactory.Create()) { conn.Open(); var cmd = conn.CreateCommand() as DbCommand; cmd.CommandText = sql; await cmd.ExecuteNonQueryAsync(); } }
public FrmInterFaceType(HWCfgModel model) { InitializeComponent(); this.model = model; this.parameter = model.InterfaceParameter; }