示例#1
0
        /// <summary>
        /// Here is the *MAGIC TRICK* !
        /// Rather than attempting align parameters via string formats - we use
        /// MAGIC STRINGS that no one in their right mind would ever use; defined
        /// from the ReceiptPieces class.
        ///
        /// The conundrum to this approach is ; Any data extracted for receipts
        /// must be 1) Labeled in ReceiptPieces and 2) Addressed to proper assignment
        /// here.
        /// </summary>
        /// <param name="input"></param>
        /// <param name="line"></param>
        /// <returns></returns>
        private string ProcessReceiptFormat(string input, Line line = null)
        {
            string output = input.Replace(ReceiptPieces.Company, Company);

            if (line != null)
            {
                output = output.Replace(ReceiptPieces.LinePrice, line.Bike.DiscountMarker.discount(line.Quantity).ToString("C"));
                output = output.Replace(ReceiptPieces.LineQuantity, line.Quantity.ToString());
                output = output.Replace(ReceiptPieces.BikeBrand, line.Bike.Brand);
                output = output.Replace(ReceiptPieces.BikeModel, line.Bike.Model);
            }

            output = output.Replace(ReceiptPieces.Total, Total.ToString("C"));
            output = output.Replace(ReceiptPieces.SubTotal, SubTotal.ToString("C"));
            output = output.Replace(ReceiptPieces.Tax, Taxes.ToString("C"));

            return(output);
        }
示例#2
0
文件: Trade.cs 项目: Dartya/WpfApp1
        public string EditQuery()
        {
            roundParams();
            int iTradeClosed = 0;

            if (TradeClosed == false)
            {
                iTradeClosed = 0;
                ClosingPrice = 0;
                Comission    = 0;
                Taxes        = 0;
                Profit       = 0;
            }
            else
            {
                iTradeClosed = 1;
            }

            int iTradeType      = 0;
            int iInstrumentType = 0;

            switch (InstrumentType.ToString())
            {
            case "Валюта":
                iInstrumentType = 0;
                break;

            case "Акция":
                iInstrumentType = 1;
                break;

            case "Фьючерс":
                iInstrumentType = 2;
                break;
            }
            switch (TradeType.ToString())
            {
            case "Long":
                iTradeType = 0;
                break;

            case "Short":
                iTradeType = 1;
                break;
            }

            //UPDATE `tradesassistant`.`trades` SET `trade_type`='0', `trade_sum`='2120.00' WHERE `id`='6';
            string query = "UPDATE `" + Schema + "`.`" + Table + "` SET " +
                           "`instrument_name`='" + InstrumentName + "', " +
                           "`instrument_class`='" + iInstrumentType.ToString() + "', " +
                           "`instrument_ticker`='" + Ticker + "', " +
                           "`trade_type`='" + iTradeType.ToString() + "', " +
                           "`opening_price`='" + OpeningPrice.ToString().Replace(",", ".") + "', " +
                           "`trade_volume`='" + TradeSize.ToString() + "', " +
                           "`trade_sum`='" + TradeSum.ToString().Replace(",", ".") + "', " +
                           "`trade_closed`='" + iTradeClosed.ToString() + "', " +
                           "`closing_price`='" + ClosingPrice.ToString().Replace(",", ".") + "', " +
                           "`comissions`='" + Comission.ToString().Replace(",", ".") + "', " +
                           "`taxes`='" + Taxes.ToString().Replace(",", ".") + "', " +
                           "`profit`='" + Profit.ToString().Replace(",", ".") + "' " +
                           "WHERE `id`='" + TradeId + "';";

            return(query);
        }
示例#3
0
文件: Trade.cs 项目: Dartya/WpfApp1
        //метод формирования строки удаления записи
        public string AddQuery()
        {
            roundParams();
            int iTradeClosed = 0;

            if (TradeClosed == false)
            {
                iTradeClosed = 0;
            }
            else
            {
                iTradeClosed = 1;
            }

            int iTradeType      = 0;
            int iInstrumentType = 0;

            switch (InstrumentType.ToString())
            {
            case "Валюта":
                iInstrumentType = 0;
                break;

            case "Акция":
                iInstrumentType = 1;
                break;

            case "Фьючерс":
                iInstrumentType = 2;
                break;
            }
            switch (TradeType.ToString())
            {
            case "Long":
                iTradeType = 0;
                break;

            case "Short":
                iTradeType = 1;
                break;
            }

            string query = "INSERT INTO `" + Schema + "`.`" + Table + "` " +
                           "(`instrument_name`, " +
                           "`instrument_class`, " +
                           "`instrument_ticker`, " +
                           "`trade_type`, " +
                           "`opening_price`, " +
                           "`trade_volume`, " +
                           "`trade_sum`, " +
                           "`trade_closed`, " +
                           "`closing_price`, " +
                           "`comissions`, " +
                           "`taxes`, " +
                           "`profit`) " +
                           "VALUES ('" +
                           InstrumentName + "', '"
                           + iInstrumentType.ToString() + "', '"
                           + Ticker + "', '"
                           + iTradeType.ToString() + "', '"
                           + OpeningPrice.ToString().Replace(",", ".") + "', '"
                           + TradeSize.ToString() + "', '"
                           + TradeSum.ToString().Replace(",", ".") + "', '"
                           + iTradeClosed.ToString() + "', '"
                           + ClosingPrice.ToString().Replace(",", ".") + "', '"
                           + Comission.ToString().Replace(",", ".") + "', '"
                           + Taxes.ToString().Replace(",", ".") + "', '"
                           + Profit.ToString().Replace(",", ".") + "');";

            return(query);
        }