//更新数据 public void Update(PrincipalEntity PE) { SQLiteCommand cmd = new SQLiteCommand(conn); cmd.CommandText = "update '" + user + "_Principal' set money=@money"; cmd.Parameters.Add(new SQLiteParameter("money", PE.money)); cmd.ExecuteNonQuery(); }
//插入数据 public void Insert(PrincipalEntity PE) { SQLiteCommand cmd = new SQLiteCommand(conn); cmd.CommandText = "insert into '" + user + "_Principal' values(@money)"; cmd.Parameters.Add(new SQLiteParameter("money", PE.money)); cmd.ExecuteNonQuery(); }
//读取数据 public void Select(out PrincipalEntity PE) { SQLiteCommand cmd = new SQLiteCommand(conn); cmd.CommandText = "select * from '" + user + "_Principal'"; SQLiteDataReader reader = cmd.ExecuteReader(); PE = new PrincipalEntity(); if (reader.HasRows) { if (reader.Read()) { PE.money = reader.GetValue(0).ToString(); } } }
//写入本金 private void PrincipalWrite(double m) { PrincipalEntity PE = new PrincipalEntity(); PE.money = m.ToString(); principal.Update(PE); money.principal = m; }
//创建本金 public void PrincipalCreate(double m) { PrincipalEntity PE = new PrincipalEntity(); PE.money = m.ToString(); principal.Insert(PE); //本金与现金创建 money.principal = m; money.now = m; //交易记录创建持股表 StockHold_Init(); }