Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,MaxPrice")] Buy buy)
        {
            if (id != buy.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(buy);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BuyExists(buy.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(buy));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,CustomerId,StaffId,BikeId")] Buy buy)
        {
            if (id != buy.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(buy);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BuyExists(buy.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BikeId"]     = new SelectList(_context.Bike, "Id", "Id", buy.BikeId);
            ViewData["CustomerId"] = new SelectList(_context.Set <Customer>(), "Id", "Id", buy.CustomerId);
            ViewData["StaffId"]    = new SelectList(_context.Set <Staff>(), "Id", "Id", buy.StaffId);
            return(View(buy));
        }
Пример #3
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // 在此处放置用户代码以初始化页面
            // 设置 Response编码格式为GB2312
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");

            string pb_TrxId = Request.Form["pb_TrxId"];
            string p3_Amt   = Request.Form["p3_Amt"];
            string p4_Cur   = Request.Form["p4_Cur"];
            string p5_Desc  = Request.Form["p5_Desc"];

            try
            {
                BuyRefundOrdResult result = Buy.RefundOrd(pb_TrxId, p3_Amt, p4_Cur, p5_Desc);

                if (result.R1_Code == "1")
                {
                    Response.Write("退款成功");
                    Response.Write("<br>退款金额:" + result.R3_Amt);
                }
                else
                {
                    Response.Write("退款失败 " + result.R1_Code);
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
        public int BuyCost()
        {
            return(Buy?.Sum(
                       b =>
            {
                switch (b)
                {
                case BoosterType.Extension:
                    return 1000;

                case BoosterType.Drill:
                    return 700;

                case BoosterType.FastWheels:
                    return 300;

                case BoosterType.Teleport:
                    return 1200;

                case BoosterType.Cloning:
                    return 2000;

                default:
                    throw new ArgumentOutOfRangeException(nameof(b), b, null);
                }
            }) ?? 0);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // 商家的交易定单号
            string p2_Order = Request.Form["p2_Order"];

            try
            {
                // 查询订单
                BuyQueryOrdDetailResult result = Buy.QueryOrdDetail(p2_Order);

                if (result.R1_Code == "1")
                {
                    Response.Write("查询成功!");
                    Response.Write("<br>商户订单号:" + result.R6_Order);
                    Response.Write("<br>商品名称:" + result.R5_Pid);
                    Response.Write("<br>支付金额:" + result.R3_Amt);
                    Response.Write("<br>订单状态:" + result.Rb_PayStatus);
                }
                else
                {
                    Response.Write("<br>查询失败!" + result.R1_Code);
                }
            }

            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Пример #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // 设置 Response编码格式为GB2312
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");

        p1_MerId = "10000432521";                                                  // 商家ID
        keyValue = "8UPp0KE8sq73zVP370vko7C39403rtK1YwX40Td6irH216036H27Eb12792t"; // 商家密钥

        //Buy.NodeAuthorizationURL = @"https://www.yeepay.com/app-merchant-proxy/node";   // 设置请求地址
        Buy.NodeAuthorizationURL = @"http://tech.yeepay.com:8080/robot/debug.action"; //test


        pb_TrxId = Request.Form["pb_TrxId"];
        p3_Amt   = Request.Form["p3_Amt"];
        p5_Desc  = Request.Form["p5_Desc"];

        try
        {
            BuyRefundOrdResult result = Buy.RefundOrd(p1_MerId, keyValue, pb_TrxId, p3_Amt, "CNY", p5_Desc);

            if (result.R1_Code == "1")
            {
                Response.Write("退款成功");
                Response.Write("<br>退款金额:" + result.R3_Amt);
            }
            else
            {
                Response.Write("退款失败 " + result.R1_Code);
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
Пример #7
0
        /// <summary>
        ///     Method that sets up event listeners
        /// </summary>
        ///
        public static void DefaultBuild()
        {
            try
            {
                // Use Default build
                if (Builds.Keys.Any(b => b.Equals(Build.BuildName())) && Builds.FirstOrDefault(b => b.Key.Equals(Build.BuildName())).Value.TryParseData(out CurrentChampionBuild))
                {
                    Logger.Send(Build.BuildName() + " build Loaded!", Logger.LogLevel.Info);

                    // and set up event listeners
                    SetUpEventListeners();
                    if (Player.Instance.IsInShopRange())
                    {
                        Buy.BuyNextItem(CurrentChampionBuild);
                    }
                }
                else
                {
                    // An error occured during parsing. Catch the error and print it in the console
                    Logger.Send("The selected AutoShop JSON could not be parsed.", Logger.LogLevel.Error);

                    Logger.Send("No build is currently used!", Logger.LogLevel.Warn);
                }
            }
            catch (Exception ex)
            {
                // An exception occured somewhere else. Notify the user of the error, and print the exception to the console
                Logger.Send("Exception occurred on initialization of AutoShop:", ex, Logger.LogLevel.Error);

                // Warn the user about the exception
                Logger.Send("Exception occurred during AutoShop initialization. AutoShop will most likely NOT work properly!", Logger.LogLevel.Warn);
            }
        }
        public async Task <ActionResult <Buy> > PostBuy(Buy buy)
        {
            _context.Buy.Add(buy);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetBuy", new { id = buy.BuyId }, buy));
        }
Пример #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="orderid"></param>
        /// <param name="orderAmt"></param>
        /// <param name="bankcode"></param>
        /// <returns></returns>
        public string GetPayUrl(string orderid, decimal orderAmt, string bankcode)
        {
            string puserid  = this.SuppAccount;
            string puserkey = this.SuppKey;

            HttpContext.Current.Response.ContentEncoding = Encoding.GetEncoding("gb2312");
            Buy.NodeAuthorizationURL = "https://www.yeepay.com/app-merchant-proxy/node";
            if (!string.IsNullOrEmpty(this.PostBankUrl))
            {
                Buy.NodeAuthorizationURL = this.PostBankUrl;
            }

            string p2_Order = orderid;
            string p3_Amt   = decimal.Round(orderAmt, 2).ToString(CultureInfo.InvariantCulture);
            string p4_Cur   = "CNY";
            string p5_Pid   = SysConfig.PaymentSetting.yeepay_pid;
            string p6_Pcat  = SysConfig.PaymentSetting.yeepay_pcat;
            string p7_Pdesc = SysConfig.PaymentSetting.yeepay_pdesc;
            /*代理支付页*/
            string p8_Url = NotifyUrl;//Configuration.GetConfig().SiteDomain

            string p9_SAF = "1";
            //if (!string.IsNullOrEmpty(orderInfo.returnurl))
            //p9_SAF = "1";

            string pa_MP           = "";
            string pd_FrpId        = Bank.GetBankCode(bankcode);
            string pr_NeedResponse = "1";

            return(Buy.CreateBuyUrl(puserid, puserkey, p2_Order, p3_Amt, p4_Cur, p5_Pid, p6_Pcat, p7_Pdesc, p8_Url, p9_SAF, pa_MP, pd_FrpId, pr_NeedResponse) + "&noLoadingPage=1");
        }
Пример #10
0
        public IHttpActionResult CreateNewBuy(NewBuyDto newBuy)
        {
            var user = _context.Users.Single(
                c => c.Id == newBuy.UserId);

            var programs = _context.Programs.Where(
                m => newBuy.ProgramIds.Contains(m.Id)).ToList();

            foreach (var program in programs)
            {
                if (program.NumberAvailable == 0)
                {
                    return(BadRequest("Program is not available."));
                }

                program.NumberAvailable--;

                var buy = new Buy
                {
                    User       = user,
                    Program    = program,
                    DateBought = DateTime.Now
                };

                _context.Buys.Add(buy);
            }

            _context.SaveChanges();

            return(Ok());
        }
Пример #11
0
        public ActionResult Buy(int Id)
        {
            Game game = _session.Get <Game>(Id);
            Buy  buy  = Mapper.Map <Buy>(game);

            return(View(buy));
        }
Пример #12
0
        public IEnumerable <LimitOrder> DeleteMarketMakerOrders(string marketMakerId, string[] idsToDelete)
        {
            var deletedBuy  = Buy.DeleteMarketMakerOrders(marketMakerId, idsToDelete);
            var deletedSell = Sell.DeleteMarketMakerOrders(marketMakerId, idsToDelete);

            return(deletedBuy.Concat(deletedSell));
        }
Пример #13
0
 public bool IsEqual(Buy previousBuy, Buy newBuy)
 {
     if (previousBuy == null || newBuy == null)
     {
         return(false);
     }
     if (previousBuy.TrackingCode != newBuy.TrackingCode)
     {
         return(false);
     }
     if (previousBuy.Year != newBuy.Year)
     {
         return(false);
     }
     if (previousBuy.Month != newBuy.Month)
     {
         return(false);
     }
     if (previousBuy.Day != newBuy.Day)
     {
         return(false);
     }
     if (previousBuy.CustomerID != newBuy.CustomerID)
     {
         return(false);
     }
     if (previousBuy.CardNumber != newBuy.CardNumber)
     {
         return(false);
     }
     return(true);
 }
Пример #14
0
        private void UpdateBestPrice()
        {
            var newBestPrice = new InstrumentBidAskPair
            {
                Instrument = Instrument,
                Date       = DateTime.UtcNow
            };

            if (Sell.Any())
            {
                var fl = Sell.First();
                newBestPrice.Ask = fl.Key;
                newBestPrice.AskFirstLevelVolume = fl.Value.Sum(o => Math.Abs(o.Volume));
            }
            else
            {
                newBestPrice.Ask = BestPrice?.Ask ?? 0;
            }

            if (Buy.Any())
            {
                var fl = Buy.First();
                newBestPrice.Bid = fl.Key;
                newBestPrice.BidFirstLevelVolume = fl.Value.Sum(o => Math.Abs(o.Volume));
            }
            else
            {
                newBestPrice.Bid = BestPrice?.Bid ?? 0;
            }

            if (newBestPrice.Ask > 0 && newBestPrice.Bid > 0)
            {
                BestPrice = newBestPrice;
            }
        }
        private void BuyCheckDetailForm_Load(object sender, EventArgs e)
        {
            Text = "审核申请单";

            try
            {
                Buy bd = bm.SelBuyByCodeToModel(code);
                auditState = bd.Buy_AuditStatus;

                labtextboxTop1.Enabled   = false;
                labtextboxTop1.BackColor = Color.White;
                pictureBox1.Enabled      = false;
                Supplier su = sm.SelUpdateSupplierByCode(bd.Buy_SupplierCode);
                labtextboxTop1.Text = bd.Buy_Class;
                labtextboxTop2.Text = bd.Buy_SupplierName;
                labtextboxTop3.Text = "";
                labtextboxTop4.Text = su.Su_Bank;
                labtextboxTop5.Text = su.Su_Surplus;

                //业务员
                labtextboxBotton1.Text = bd.Buy_SalesMan;
                //摘要
                labtextboxBotton2.Text = bd.Buy_Remark;
                //制单人
                labtextboxBotton3.Text = bd.Buy_Operation;
                //审核人
                labtextboxBotton4.Text = bd.Buy_AuditMan;
                textBoxOddNumbers.Text = code;
                superGridControl1.PrimaryGrid.DataSource = bdm.SelBuyDetailByCodeToTable(code);
            }
            catch (Exception ex)
            {
                MessageBox.Show("错误代码:3203-审核申请单加载时异常,异常信息:" + ex.Message);
            }
        }
Пример #16
0
        private const string keyValue = "4I9A2hY6s87441M910498Ip01E2YJMNbiz904202DJr8P520au43LS2I9M6K"; // 商家密钥

        /// <summary>
        /// 易宝普通支付
        /// </summary>
        /// <param name="p2_Order">商户订单号</param>
        /// <param name="p3_Amt">支付金额,单位:元,精确到分</param>
        /// <param name="sPoints">充值点数</param>
        /// <param name="pa_MP">商户扩展信息,用户账号</param>
        /// <param name="pd_FrpId">银行编码</param>
        /// <returns></returns>
        public static string CreateBuyUrl(string p2_Order, string p3_Amt, string sPoints, string pa_MP, string pd_FrpId, string p8_Url)
        {
            // 设置请求地址
            Buy.NodeAuthorizationURL = @"https://www.yeepay.com/app-merchant-proxy/node";
            // 商家设置用户购买商品的支付信息.
            //易宝支付平台统一使用GBK/GB2312编码方式,参数如用到中文,请注意转码
            //交易币种,固定值"CNY".
            string        p4_Cur = "CNY";
            StringBuilder sbText = new StringBuilder();

            sbText.Append("到武林");
            sbText.Append(sPoints);
            sbText.Append("武林币");
            string p5_Pid  = sbText.ToString();
            string p6_Pcat = "wulin B";//商品种类

            //商品描述
            string p7_Pdesc = "wulinbi";
            //商户接收支付成功数据的地址,支付成功后易宝支付会向该地址发送两次成功通知.
            //p8_Url = Request.Form["p8_Url"];
            //送货地址为“1”: 需要用户将送货地址留在易宝支付系统;为“0”: 不需要,默认为 ”0”.
            string p9_SAF = "0";
            //应答机制为"1": 需要应答机制;为"0": 不需要应答机制.
            string pr_NeedResponse = "1";

            return(Buy.CreateBuyUrl(p1_MerId, keyValue, p2_Order, p3_Amt, p4_Cur, p5_Pid, p6_Pcat, p7_Pdesc, p8_Url, p9_SAF, pa_MP, pd_FrpId, pr_NeedResponse));
        }
    // Public function for NextCar select button in menu
    public void NextCar()
    {
        if (ID < vehicles.Length - 1)
        {
            ID++;
        }

        PlayerPrefs.SetInt("CarID", ID);

        Destroy(GameObject.FindGameObjectWithTag("Player"));

        ID = PlayerPrefs.GetInt("CarID");

        // Instantiate last selected car by saved ID
        Instantiate(vehicles [ID], point.position, point.rotation);

        if (PlayerPrefs.GetInt("Car" + ID.ToString()) == 3)
        {
            Lock.SetActive(false);
            Buy.SetActive(false);
        }
        else
        {
            Lock.SetActive(true);
            Buy.SetActive(true);
        }

        vehiclePriceText.text = Values [ID].ToString() + " $";
    }
    private void Start()
    {
        GetComponent <SaveLoad>().Load5();
        GetComponent <SaveLoad>().Load3();
        VolumeOn  = GameObject.Find("VolumeOn");
        volumeOff = GameObject.Find("VolumeOff");
        Lock      = GameObject.Find("Lock");
        Buy       = GameObject.Find("Buy");
        Video     = GameObject.Find("Advertisment");
        volumeMixer.SetFloat("volume", Value);
        Coins.text = coins + "";
        if (Value == -80)
        {
            volumeOff.SetActive(true);
            VolumeOn.SetActive(false);
        }
        else
        {
            volumeOff.SetActive(false);
            VolumeOn.SetActive(true);
        }

        pnlCarSelectMenu.SetActive(false);
        pnlSettingsMenu.SetActive(false);
        pnlMainMenu.SetActive(true);
        Video.SetActive(false);
        Buy.SetActive(false);
        Lock.SetActive(false);
    }
Пример #19
0
        public BuyForm(Buy buy)
        {
            InitializeComponent();
            Icon = Resources.Purchase11;

            _buy = buy;
        }
Пример #20
0
        // GET: Buy/Details/5

        public ActionResult Details(int id)
        {
            Buy buy = null;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:8081/buy/");
                //HTTP GET
                var responseTask = client.GetAsync("getOne/" + id);
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var readTask = result.Content.ReadAsAsync <Buy>();
                    readTask.Wait();

                    buy = readTask.Result;
                }
            }
            using (MemoryStream ms = new MemoryStream())
            {
                QRCodeGenerator oQRCodeGenerator = new QRCodeGenerator();
                QRCodeData      oQRCodeData      = oQRCodeGenerator.CreateQrCode(buy.ToString(), QRCodeGenerator.ECCLevel.Q);
                QRCode          oQRCode          = new QRCode(oQRCodeData);
                using (Bitmap oBitmap = oQRCode.GetGraphic(20))
                {
                    oBitmap.Save(ms, ImageFormat.Png);
                    ViewBag.QRCode = "data:image/png;base64," + Convert.ToBase64String(ms.ToArray());
                }
            }
            return(View(buy));
        }
Пример #21
0
    public void Hide_AllScreen()
    {
        Teleport.SetActive(false);
        P_Screen.SetActive(false);
        BackVillage.SetActive(false);
        BackManu.SetActive(false);
        Exit.SetActive(false);
        SeveGame.SetActive(false);
        EndStage.SetActive(false);
        Status.SetActive(false);
        Npc.SetActive(false);
        Die.SetActive(false);
        Setting.SetActive(false);
        Tooltip.SetActive(false);
        BuySell.SetActive(false);
        Enchant.SetActive(false);
        HelpKey.SetActive(false);
        AdminScreen.SetActive(false);
        Sell.SetActive(false);
        Buy.SetActive(false);
        EndButtom.SetActive(false);
        inventory.SetActive(false);

        if (Application.loadedLevelName == "Village")
        {
            ButtomBackVillage.SetActive(false);
        }
        else
        {
            ButtomBackVillage.SetActive(true);
        }
    }
Пример #22
0
        public ActionResult Save(Buy buy)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new BuyFormViewModel
                {
                    Accounts = _context.Accounts.ToList(),
                    Games    = _context.Games.ToList()
                };

                return(View("BuyForm", viewModel));
            }

            if (buy.BuyID == 0)
            {
                buy.BuyDate = DateTime.Now;
                _context.Buys.Add(buy);
            }

            else
            {
                var buyInDb = _context.Buys.Single(b => b.BuyID == buy.BuyID);

                buyInDb.AccountID = buy.AccountID;
                buyInDb.GameID    = buy.GameID;
            }
            _context.SaveChanges();
            return(RedirectToAction("Index", "Buys"));
        }
        public async Task <IActionResult> PutBuy(int id, Buy buy)
        {
            if (id != buy.BuyId)
            {
                return(BadRequest());
            }

            _context.Entry(buy).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BuyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #24
0
        private RowDoubleClickedEventArgs OnRowDoubleClicked(Buy buy)
        {
            RowDoubleClickedEventArgs args = new RowDoubleClickedEventArgs(buy);

            OnRowDoubleClicked(args);

            return(args);
        }
Пример #25
0
        /// <summary>
        ///     Fired when buying is allowed
        /// </summary>
        /// <param name="args">Arguments of the event</param>
        private static void Events_OnBuyAllow(EventArgs args)
        {
            // Notify the user that we are going to try to buy items now
            Logger.Send("Can buy items", Logger.LogLevel.Info);

            // Attempt to buy as many consecutive items on the build as we can
            Buy.BuyNextItem(CurrentChampionBuild);
        }
Пример #26
0
        /// <summary>
        /// 获取支付成功返回信息
        /// </summary>
        /// <param name="p1_MerId">商户编号</param>
        /// <param name="keyValue">商户密钥</param>
        /// <returns></returns>
        private BuyCallbackResult GetPayResult()
        {
            BuyCallbackResult payResult = Buy.VerifyCallback(FormatQueryString.GetQueryString("p1_MerId"), keyValue, FormatQueryString.GetQueryString("r0_Cmd"), FormatQueryString.GetQueryString("r1_Code"), FormatQueryString.GetQueryString("r2_TrxId"),
                                                             FormatQueryString.GetQueryString("r3_Amt"), FormatQueryString.GetQueryString("r4_Cur"), FormatQueryString.GetQueryString("r5_Pid"), FormatQueryString.GetQueryString("r6_Order"), FormatQueryString.GetQueryString("r7_Uid"),
                                                             FormatQueryString.GetQueryString("r8_MP"), FormatQueryString.GetQueryString("r9_BType"), FormatQueryString.GetQueryString("rp_PayDate"), FormatQueryString.GetQueryString("hmac"));

            return(payResult);
        }
Пример #27
0
        /// <summary>
        ///     Fired when a build reset is forced
        /// </summary>
        /// <param name="args">Arguments of the event</param>
        private static void Events_OnBuildReset(EventArgs args)
        {
            // Notify the user that the build has been reset
            Logger.Send("Build has been reset!", Logger.LogLevel.Event);

            // Reset the build index, restarting the build process from the start
            Buy.ResetIndex();
        }
 public bool Delete(Buy buy)
 {
     db.Buys.Remove(buy);
     if (Convert.ToBoolean(db.SaveChanges()))
     {
         return(true);
     }
     return(false);
 }
 public bool Add(Buy buy)
 {
     db.Buys.Add(buy);
     if (Convert.ToBoolean(db.SaveChanges()))
     {
         return(true);
     }
     return(false);
 }
Пример #30
0
    // Update is called once per frame
    void Update()
    {
        //if (Input.GetMouseButtonDown(0))
        //{
        textMoney      = Buy.GetMoneyPoint();
        Moneytext.text = "残金" + textMoney.ToString() + "円";

        //}
    }
Пример #31
0
    void Start()
    {
        backgroundColor = gameObject.GetComponent<Image>();
        buy = gameObject.GetComponent<Buy>();

        if (ItemToBuy().id != SaveLoad.data.actualSkin.id)
        {
            backgroundColor.enabled = false;
        }
    }
Пример #32
0
        void Quant()
        {
            double price = 0;
            double volume = 0;
            double gross = 0;

            try
            {
                if (txtPrice.Text.Length != 0)
                    price = double.Parse(txtPrice.Text);
                if (txtVolume.Text.Length != 0)
                    volume = double.Parse(txtVolume.Text);
                if (txtGross.Text.Length != 0)
                    gross = double.Parse(txtGross.Text);

                if (txtPrice.Text.Length == 0)
                {
                    price =  gross / volume;
                    txtPrice.Text = string.Format("{0}", price);
                }
                if (txtVolume.Text.Length == 0)
                {
                    volume = gross / price;
                    txtVolume.Text = string.Format("{0}", volume);
                }
                gross = price * volume;
                txtGross.Text = string.Format("{0}", gross);

                Buy buy = new Buy()
                {
                    Price = price,
                    Volume = (int)volume
                };
                Fees buyFees = feeSvc.CalculateFees(buy);
                txtBuyFees.Clear();
                txtBuyFees.Text += string.Format("Gross     : {0}\n", buy.Price * buy.Volume);
                txtBuyFees.Text += string.Format("Fees      : {0}\n", buyFees.Total);
                txtBuyFees.Text += string.Format("      Commission: {0}\n", buyFees.Commission);
                txtBuyFees.Text += string.Format("      PSE Fee   : {0}\n", buyFees.PseFee);
                txtBuyFees.Text += string.Format("      SCCP Fee  : {0}\n", buyFees.SccpFee);
                txtBuyFees.Text += string.Format("---------------------------\n");
                txtBuyFees.Text += string.Format("Net       : {0}\n", (buy.Price * buy.Volume) + buyFees.Total);

                txtPlTable.Clear();
                PrintForProfits(buy, -0.10, -0.05, 0.0, 0.01, 0.05, 0.10, 0.15, 0.20);
            }
            catch
            { }
        }
Пример #33
0
 public JsonMtGOX()
 {
     high = new High();
     low = new Low();
     avg = new Avg();
     vwap = new Vwap();
     vol = new Vol();
     lastlocal = new LastLocal();
     lastorig = new LastOrig();
     lastall = new LastAll();
     last = new Last();
     buy = new Buy();
     sell = new Sell();
     rootobject = new RootObject();
     returnObject = new Return();
 }
 /// Action generator
 /// @todo Implement lookup table or a design pattern for easier/automatic function generation
 public void actionGenerator( List<GameObject[]> combinations )
 {
     iThinkAction action;
     //printEverything(combinations);
     foreach ( GameObject[] matrix in combinations )
     {
       			switch ( schemaElements[0] )
         {
             case "get" :
                 action = new Get( "Get", matrix[0], matrix[1] );
                 tempActionList.Add(action);
                 break;
             case "buy" :
                 action = new Buy( "Buy", matrix[0], matrix[1], matrix[2] );
                 tempActionList.Add(action);
                 break;
             case "store" :
                 action = new Store( "Store", matrix[0], matrix[1]);
                 tempActionList.Add(action);
                 break;
             case "hunt" :
                 action = new Hunt( "Hunt", matrix[0], matrix[1], matrix[2], matrix[3]);
                 tempActionList.Add(action);
                 break;
             case "make" :
                 action = new Make( "Make", matrix[0], matrix[1], matrix[2]);
                 tempActionList.Add(action);
                 break;
             case "harvest" :
                 action = new Harvest( "Harvest", matrix[0], matrix[1], matrix[2]);
                 tempActionList.Add(action);
                 break;
             case "produce" :
                 action = new Produce( "Produce", matrix[0], matrix[1], matrix[2]);
                 tempActionList.Add(action);
                 break;
             case "craftSpell" :
                 action = new CraftSpell ("CraftSpell", matrix[0], matrix[1], matrix[2]);
                 tempActionList.Add(action);
                 break;
             case "craftSimpleWeapon" :
                 action = new CraftSimpleWeapon("CraftSimpleWeapon", matrix[0], matrix[1], matrix[2]);
                 tempActionList.Add(action);
                 break;
         }
     }
 }
        public ProfitLoss CalculateProfitLoss(Buy buy, Sell sell)
        {
            double buyPrice = buy.Price * buy.Volume;
            double sellPrice = sell.Price * sell.Volume;
            double buyFees = feeCalc.CalculateFees(buy).Total;
            double sellFees = feeCalc.CalculateFees(sell).Total;
            double buyNet = buyPrice + buyFees;
            double sellNet = sellPrice - sellFees;

            ProfitLoss result = new ProfitLoss()
            {
                Amount = sellNet - buyNet,
                Ratio = (sellNet / buyNet) - 1.0
            };

            return result;
        }
        public Sell GetSellActionForTargetProfit(Buy buy, double targetProfit)
        {
            Sell sell = new Sell()
            {
                Price = buy.Price + targetProfit,
                Volume = buy.Volume
            };

            for (int i = 0; i < int.MaxValue; ++i)
            {
                ProfitLoss pl = CalculateProfitLoss(buy, sell);
                if (Math.Abs(pl.Amount - targetProfit) < config.epsilon)
                    break;
                if (targetProfit < pl.Ratio)
                    sell.Price -= config.epsilon;
                else
                    sell.Price += config.epsilon;
            }

            return sell;
        }
Пример #37
0
		void SendBuyRequest(string sku)
		{
			var req = new Buy(sku, m_requestId++);

			m_service.SendRequest<Response>(req).ContinueWith(t =>
			{
				this.RunOnUiThread(() =>
				{
					if (t.Result.Success)
						Toast.MakeText(this, "Purchase complete. Item: " + req.Sku, ToastLength.Long).Show();
					else
						Toast.MakeText(this, "Purchase failure. Error: " + t.Result.Message, ToastLength.Long).Show();
				});
			});	
		}
Пример #38
0
        public bool AddBuy(BuyDto buyDto)
        {
            try
            {
                var accountEntity = context.Account.FirstOrDefault(p => p.Id == buyDto.AccountId);
                var buyEntity = new Buy
                {
                    Account = accountEntity,

                    TransactionTypeId = buyDto.TransactionTypeId,
                    TranType = buyDto.TransactionType,
                    AddedBy = buyDto.AddedBy,
                    AmtInv = buyDto.AmtInv,
                    BuyCommission = buyDto.BuyCommission,
                    BuyDate = buyDto.BuyDate,
                    BuyPrice = buyDto.BuyPrice,
                    BuyType = buyDto.BuyType,
                    Comments = buyDto.Comments,
                    DividendAmount = buyDto.DividendAmount,
                    ModifiedBy = buyDto.ModifiedBy,
                    NumShares = buyDto.NumShares,
                    orderby = buyDto.orderby,
                    OriginalBuyGUID = buyDto.OriginalBuyGUID,
                    refID = buyDto.refID,
                    DateAdded = DateTime.Now,
                    DateModified = DateTime.Now,
                    BuyGUID = Guid.NewGuid(),

                    InvestmentClassification = accountEntity.InvestmentClassification,
                    InvestmentClassificationGuid = accountEntity.InvestmentClassificationGuid,
                    SubAccount = accountEntity.SubAccount,
                    SubAccountGuid = accountEntity.SubAccountGuid,
                    Broker = accountEntity.Broker,
                    BrokerGUID = accountEntity.BrokerGUID,
                };
                Ticker tickerEntity;
                // public Ticker Ticker1 { get; set; }
                if (buyDto.Ticker.Length > 0)
                {
                    tickerEntity = context.Tickers.FirstOrDefault(p => p.Symbol == buyDto.Ticker);
                    if (tickerEntity == null)
                    {
                        tickerEntity = new Ticker { Symbol = buyDto.Ticker, tickerGUID = Guid.NewGuid(), type = "", current = true };
                    }
                }
                else
                {
                    tickerEntity = context.Tickers.FirstOrDefault(p => p.Id == buyDto.TickerId);
                }
                buyEntity.Ticker1 = (tickerEntity != null) ? tickerEntity : new Ticker { Symbol = buyDto.Ticker, tickerGUID = Guid.NewGuid(), type = "", current = true };

                buyEntity.Ticker = buyDto.Ticker;

                buyEntity.TickerGUID = tickerEntity.tickerGUID;

                buyEntity.Transactions.Add(new Transaction { AmtInv = buyDto.AmtInv, NumShares = buyDto.NumShares, buySplitPercent = 1, DateAdded = DateTime.Now, DateUpdated = DateTime.Now});

                context.SaveChanges();
                return true;
            }
            catch(Exception ex)
            {
                throw;

            }
        }
Пример #39
0
        void PrintForProfits(Buy buy, params double[] profits)
        {
            txtPlTable.Text += "Profit-Loss table\n\n";

            txtPlTable.Text += "Target".PadLeft(10, ' ');
            foreach (double profit in profits)
                txtPlTable.Text += string.Format("{0}%", profit * 100).PadLeft(10, ' ');
            txtPlTable.Text += "\n";
 
            txtPlTable.Text += "Profit".PadLeft(10, ' ');
            foreach (double profit in profits)
                txtPlTable.Text += string.Format("P{0}", buy.Price * buy.Volume * profit).PadLeft(10, ' ');
            txtPlTable.Text += "\n";

            List<Sell> sells = new List<Sell>();

            txtPlTable.Text += "Price".PadLeft(10, ' ');
            foreach (double profit in profits)
            {
                Sell sell = plSvc.GetSellActionForTargetProfitPercentage(buy, profit);
                sells.Add(sell);
                txtPlTable.Text += string.Format("P{0}", Math.Round(sell.Price, 4)).PadLeft(10, ' ');
            }
            txtPlTable.Text += "\n";

            txtPlTable.Text += "Diff".PadLeft(10, ' ');
            foreach (Sell sell in sells)
                txtPlTable.Text += string.Format("P{0}", Math.Round(sell.Price - buy.Price, 4)).PadLeft(10, ' ');
            txtPlTable.Text += "\n";

            txtPlTable.Text += "Diff%".PadLeft(10, ' ');
            foreach (Sell sell in sells)
                txtPlTable.Text += string.Format("{0}%", Math.Round(100 * (sell.Price / buy.Price - 1), 4)).PadLeft(10, ' ');
            txtPlTable.Text += "\n";
        }