Exemple #1
0
        public void AddFundStatus(FundStatus model)
        {
            FundStatus.Add(model);

            string sql = "INSERT INTO FundStatus (Id,Date,YesterdayBalance,CustomerRights,Remittance,MatterDeposit,ClosedProfit,Margin,Commission,FreeMargin,TodayBalance,VentureFactor,FloatingProfit,AdditionalMargin,SettlementType,AccountId) "
                         + "VALUES(@Id,@Date,@YesterdayBalance,@CustomerRights,@Remittance,@MatterDeposit,@ClosedProfit,@Margin,@Commission,@FreeMargin,@TodayBalance,@VentureFactor,@FloatingProfit,@AdditionalMargin,@SettlementType,@AccountId)";
            SQLiteCommand cmd = new SQLiteCommand(sql);

            cmd.Parameters.AddWithValue("@AccountId", model.AccountId.ToString());
            cmd.Parameters.AddWithValue("@AdditionalMargin", model.AdditionalMargin);
            cmd.Parameters.AddWithValue("@ClosedProfit", model.ClosedProfit);
            cmd.Parameters.AddWithValue("@Commission", model.Commission);
            cmd.Parameters.AddWithValue("@CustomerRights", model.CustomerRights);
            cmd.Parameters.AddWithValue("@Date", model.Date);
            cmd.Parameters.AddWithValue("@FloatingProfit", model.FloatingProfit);
            cmd.Parameters.AddWithValue("@FreeMargin", model.FreeMargin);
            cmd.Parameters.AddWithValue("@Id", model.Id.ToString());
            cmd.Parameters.AddWithValue("@Margin", model.Margin);
            cmd.Parameters.AddWithValue("@MatterDeposit", model.MatterDeposit);
            cmd.Parameters.AddWithValue("@Remittance", model.Remittance);
            cmd.Parameters.AddWithValue("@SettlementType", model.SettlementType);
            cmd.Parameters.AddWithValue("@TodayBalance", model.TodayBalance);
            cmd.Parameters.AddWithValue("@VentureFactor", model.VentureFactor);
            cmd.Parameters.AddWithValue("@YesterdayBalance", model.YesterdayBalance);
            cmds.Add(cmd);
        }
Exemple #2
0
        public List <FundStatus> GetFundStatus()
        {
            List <FundStatus> result = new List <FundStatus>();
            SQLiteConnection  conn   = null;

            try
            {
                conn = new SQLiteConnection(connectionStr);
                conn.Open();
                string           sql    = string.Format("SELECT * FROM FundStatus");
                SQLiteCommand    cmd    = new SQLiteCommand(sql, conn);
                SQLiteDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    FundStatus model = new FundStatus();
                    model.Id               = Guid.Parse(reader.GetString(0));
                    model.Date             = reader.GetDateTime(1);
                    model.YesterdayBalance = reader.GetDecimal(2);
                    model.CustomerRights   = reader.GetDecimal(3);
                    model.Remittance       = reader.GetDecimal(4);
                    model.MatterDeposit    = reader.GetDecimal(5);
                    model.ClosedProfit     = reader.GetDecimal(6);
                    model.Margin           = reader.GetDecimal(7);
                    model.Commission       = reader.GetDecimal(8);
                    model.FreeMargin       = reader.GetDecimal(9);
                    model.TodayBalance     = reader.GetDecimal(10);
                    model.VentureFactor    = reader.GetDouble(11);
                    model.FloatingProfit   = reader.GetDecimal(12);
                    model.AdditionalMargin = reader.GetDecimal(13);
                    model.SettlementType   = (SettlementType)reader.GetInt32(14);
                    model.AccountId        = Guid.Parse(reader.GetString(15));
                    result.Add(model);
                }
                conn.Close();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
            return(result);
        }
Exemple #3
0
        public void Dispose()
        {
            if (Commoditys != null)
            {
                Commoditys.Clear();
            }
            if (Users != null)
            {
                Users.Clear();
            }
            if (Accounts != null)
            {
                Accounts.Clear();
            }
            if (ClosedTradeDetails != null)
            {
                ClosedTradeDetails.Clear();
            }
            if (CommoditySummarizations != null)
            {
                CommoditySummarizations.Clear();
            }
            if (FundStatus != null)
            {
                FundStatus.Clear();
            }
            if (Parameters != null)
            {
                Parameters.Clear();
            }
            if (PositionDetails != null)
            {
                PositionDetails.Clear();
            }
            if (Positions != null)
            {
                Positions.Clear();
            }
            if (Remittances != null)
            {
                Remittances.Clear();
            }
            if (Stocks != null)
            {
                Stocks.Clear();
            }
            if (TradeDetails != null)
            {
                TradeDetails.Clear();
            }
            if (Trades != null)
            {
                Trades.Clear();
            }

            Commoditys              = null;
            Users                   = null;
            Accounts                = null;
            ClosedTradeDetails      = null;
            CommoditySummarizations = null;
            FundStatus              = null;
            Parameters              = null;
            PositionDetails         = null;
            Positions               = null;
            Remittances             = null;
            Stocks                  = null;
            TradeDetails            = null;
            Trades                  = null;
        }
Exemple #4
0
        public void Delete(DateTime dateTime, Guid accountId, params Type[] types)
        {
            foreach (var type in types)
            {
                SQLiteCommand cmd = null;

                if (type == typeof(Commodity))
                {
                    continue;
                }
                else if (type == typeof(User))
                {
                    continue;
                }
                else if (type == typeof(Account))
                {
                    continue;
                }
                else if (type == typeof(ClosedTradeDetail))
                {
                    string sql = "DELETE FROM ClosedTradeDetail WHERE AccountId=@AccountId AND ActualDate>=@Date";
                    cmd = new SQLiteCommand(sql);
                    ClosedTradeDetails.RemoveAll(m => m.AccountId == accountId && m.ActualDate >= dateTime.Date);
                }
                else if (type == typeof(CommoditySummarization))
                {
                    string sql = "DELETE FROM CommoditySummarization WHERE AccountId=@AccountId AND Date>=@Date";
                    cmd = new SQLiteCommand(sql);
                    CommoditySummarizations.RemoveAll(m => m.AccountId == accountId && m.Date >= dateTime.Date);
                }
                else if (type == typeof(FundStatus))
                {
                    string sql = "DELETE FROM FundStatus WHERE AccountId=@AccountId AND Date>=@Date";
                    cmd = new SQLiteCommand(sql);
                    FundStatus.RemoveAll(m => m.AccountId == accountId && m.Date >= dateTime.Date);
                }
                else if (type == typeof(Parameter))
                {
                    continue;
                }
                else if (type == typeof(PositionDetail))
                {
                    string sql = "DELETE FROM PositionDetail WHERE AccountId=@AccountId AND DateForPosition>=@Date";
                    cmd = new SQLiteCommand(sql);
                    PositionDetails.RemoveAll(m => m.AccountId == accountId && m.DateForPosition >= dateTime.Date);
                }
                else if (type == typeof(Position))
                {
                    string sql = "DELETE FROM Position WHERE AccountId=@AccountId AND Date>=@Date";
                    cmd = new SQLiteCommand(sql);
                    Positions.RemoveAll(m => m.AccountId == accountId && m.Date >= dateTime.Date);
                }
                else if (type == typeof(Remittance))
                {
                    string sql = "DELETE FROM Remittance WHERE AccountId=@AccountId AND Date>=@Date";
                    cmd = new SQLiteCommand(sql);
                    Remittances.RemoveAll(m => m.AccountId == accountId && m.Date >= dateTime.Date);
                }
                else if (type == typeof(Stock))
                {
                    string sql = "DELETE FROM Stock WHERE AccountId=@AccountId AND Date>=@Date";
                    cmd = new SQLiteCommand(sql);
                    Stocks.RemoveAll(m => m.AccountId == accountId && m.Date >= dateTime.Date);
                }
                else if (type == typeof(TradeDetail))
                {
                    string sql = "DELETE FROM TradeDetail WHERE AccountId=@AccountId AND ActualTime>=@Date";
                    cmd = new SQLiteCommand(sql);
                    TradeDetails.RemoveAll(m => m.AccountId == accountId && m.ActualTime >= dateTime.Date);
                }
                else if (type == typeof(Trade))
                {
                    string sql = "DELETE FROM Trade WHERE AccountId=@AccountId AND Date>=@Date";
                    cmd = new SQLiteCommand(sql);
                    Trades.RemoveAll(m => m.AccountId == accountId && m.Date >= dateTime.Date);
                }
                else
                {
                    continue;
                }
                cmd.Parameters.AddWithValue("@AccountId", accountId.ToString());
                cmd.Parameters.AddWithValue("@Date", dateTime.Date);
                cmds.Add(cmd);
            }
        }