Esempio n. 1
0
 private void btnPzEditSave_Click(object sender, EventArgs e)
 {
     try
     {
         this._commPz = new AutoTradePzCommand();
         this._commPz.RefNo = this._refNo;
         this._commPz.Symbol = this._symbol;
         this._commPz.CommandType = "EDIT";
         this._commPz.Items = new List<AutoTradePzItem>();
         AutoTradePzItem autoTradePzItem = new AutoTradePzItem();
         autoTradePzItem.RefNo = this._refNo;
         autoTradePzItem.TransNo = this._tranNo;
         autoTradePzItem.BuyPrice = Convert.ToDecimal(this.tbPzEditPrice.Text);
         autoTradePzItem.BuyVolume = Convert.ToInt64(this.tbPzEditVolume.Text.Replace(",", ""));
         long num;
         long.TryParse(this.tbPzEditMVol.Text.Replace(",", ""), out num);
         autoTradePzItem.MatchedVol = num;
         decimal d;
         decimal.TryParse(this.tbPzEditMAvg.Text, out d);
         autoTradePzItem.MatchedVal = num * d;
         CultureInfo cultureInfo = new CultureInfo("en-US");
         autoTradePzItem.SendDate = ((num > 0L) ? DateTime.Now.ToString("yyyyMMdd") : "");
         if (autoTradePzItem.BuyVolume <= 0L)
         {
             this.ShowMessageBox("Invalid Volume", frmOrderFormConfirm.OpenStyle.Error, this.tbPzEditVolume);
         }
         else if (autoTradePzItem.MatchedVol < 0L)
         {
             this.ShowMessageBox("Invalid Matched Volume", frmOrderFormConfirm.OpenStyle.Error, this.tbPzEditMVol);
         }
         else if (autoTradePzItem.MatchedVol > autoTradePzItem.BuyVolume)
         {
             this.ShowMessageBox("Invalid Matched Volume", frmOrderFormConfirm.OpenStyle.Error, this.tbPzEditMVol);
         }
         else if (autoTradePzItem.MatchedVol > 0L && autoTradePzItem.MatchedVal <= 0m)
         {
             this.ShowMessageBox("Invalid Avg", frmOrderFormConfirm.OpenStyle.Error, this.tbPzEditMAvg);
         }
         else
         {
             this._commPz.Items.Add(autoTradePzItem);
             string orderParam = string.Concat(new object[]
             {
                 "Pricing zone : Edit ",
                 "\nRefNo : ‘",
                 autoTradePzItem.RefNo,
                 "’",
                 "\nTransNo : ",
                 autoTradePzItem.TransNo
             });
             this.ShowOrderFormConfirm("Confirm to send?", orderParam, frmOrderFormConfirm.OpenStyle.ConfirmSendNew);
         }
     }
     catch (Exception ex)
     {
         this.ShowError("btnPzEditSave_Click", ex);
     }
 }
Esempio n. 2
0
 private void btnPzCancel_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.gridPzMain.FocusItemIndex > -1 && AutoTradeConstant.GetStatusByName(this.gridPzMain.Records(this.gridPzMain.FocusItemIndex).Fields("status").Text.ToString(), this._typeId) == "ST")
         {
             RecordItem recordItem = this.gridPzMain.Records(this.gridPzMain.FocusItemIndex);
             long num;
             long.TryParse(recordItem.Fields("refno").Text.ToString(), out num);
             string text = recordItem.Fields("stock").Text.ToString();
             AutoTradePzCommand autoTradePzCommand = new AutoTradePzCommand();
             autoTradePzCommand.RefNo = num;
             autoTradePzCommand.Symbol = text;
             autoTradePzCommand.CommandType = "CANCEL";
             autoTradePzCommand.Items = new List<AutoTradePzItem>();
             this._commandMain = new AutoTradeMain();
             this._commandMain.Pack("PZ", autoTradePzCommand);
             string orderParam = string.Concat(new object[]
             {
                 "Pricing Zone :",
                 "Cancel Pricing Zone , Reference no ",
                 num,
                 "\nStock : ‘",
                 text,
                 "’"
             });
             this.ShowOrderFormConfirm("Do you want to cancel?\r\n", orderParam, frmOrderFormConfirm.OpenStyle.ConfirmCancel);
         }
         else
         {
             this.ShowMessageBox("Can not find the item you want to cancel.", frmOrderFormConfirm.OpenStyle.ShowBox, null);
         }
     }
     catch (Exception ex)
     {
         this.ShowError("btn3Cancel_Click", ex);
     }
 }
Esempio n. 3
0
 private void btnPzSimulate_Click(object sender, EventArgs e)
 {
     try
     {
         this._commandPz = new AutoTradePzCommand();
         decimal d = Convert.ToDecimal(this.tbPzBudget.Text.Replace(",", ""));
         string text = this.cbPzStock.Text.Trim();
         decimal num = Convert.ToDecimal(this.tbPzStartPrice.Text);
         decimal num2 = Convert.ToDecimal(this.tbPzPChg.Text);
         int num3 = Convert.ToInt32(this.tbPzSegment.Text);
         int num4 = num3;
         StockList.StockInformation stockInformation = ApplicationInfo.StockInfo[text];
         if (stockInformation.Number <= 0)
         {
             this.ShowMessageBox("Invalid Symbol!", frmOrderFormConfirm.OpenStyle.Error, this.cbPzStock);
         }
         else
         {
             decimal num5 = num;
             decimal spreadPrice = Utilities.GetSpreadPrice(num, stockInformation.PriorPrice, stockInformation.IsCheckSpread);
             if (num % spreadPrice != 0m)
             {
                 num5 -= num % spreadPrice;
             }
             decimal num6 = 0m;
             long num7 = 0L;
             this.gridPzSimm.Rows = num3 + 1;
             long num8;
             RecordItem recordItem;
             for (int i = 0; i < num3; i++)
             {
                 decimal d2 = d / num4;
                 num4--;
                 d2 -= d2 * ApplicationInfo.UserCommVAT;
                 num8 = (long)(d2 / num5);
                 if (num8 % (long)stockInformation.BoardLot != 0L)
                 {
                     num8 -= num8 % (long)stockInformation.BoardLot;
                 }
                 decimal num9 = num8 * num5;
                 num9 += num9 * ApplicationInfo.UserCommVAT;
                 d -= num9;
                 recordItem = this.gridPzSimm.Records(i);
                 recordItem.Fields("no").Text = i + 1;
                 recordItem.Fields("price").Text = Utilities.PriceFormat(num5);
                 recordItem.Fields("volume").Text = num8;
                 recordItem.Fields("budget").Text = num9;
                 recordItem.Fields("volume").FontColor = MyColor.UnChgColor;
                 recordItem.Fields("budget").FontColor = Color.Cyan;
                 spreadPrice = Utilities.GetSpreadPrice(num5 - 0.01m, stockInformation.PriorPrice, stockInformation.IsCheckSpread);
                 num5 -= num5 * num2 / 100m;
                 num5 -= num5 % spreadPrice;
                 num7 += num8;
                 num6 += num9;
             }
             recordItem = this.gridPzSimm.Records(this.gridPzSimm.Rows - 1);
             recordItem.Fields("no").Text = "Avg";
             recordItem.Fields("price").Text = ((num7 > 0L) ? Utilities.PriceFormat(num6 / num7, 4) : "0");
             recordItem.Fields("volume").Text = num7;
             recordItem.Fields("budget").Text = num6;
             recordItem.Fields("no").FontColor = Color.Cyan;
             recordItem.Fields("volume").FontColor = MyColor.UnChgColor;
             recordItem.Fields("volume").FontStyle = FontStyle.Bold;
             recordItem.Fields("budget").FontColor = Color.Cyan;
             recordItem.BackColor = Color.DimGray;
             this.gridPzSimm.Redraw();
             decimal num10 = Convert.ToDecimal(this.tbPzBudget.Text.Replace(",", ""));
             this._commandPz.UserId = ApplicationInfo.UserLoginID;
             this._commandPz.Account = ApplicationInfo.AccInfo.CurrentAccount;
             this._commandPz.CustType = ApplicationInfo.AccInfo.Items[ApplicationInfo.AccInfo.CurrentAccount].PcFlag;
             this._commandPz.Symbol = text;
             this._commandPz.CommandType = "ADD";
             this._commandPz.Budget = (long)num10;
             this._commandPz.PChg = num2;
             this._commandPz.StartPrice = num;
             this._commandPz.Segment = this.gridPzSimm.Rows - 1;
             this._commandPz.Items = new List<AutoTradePzItem>();
             num8 = 0L;
             for (int j = 0; j < this.gridPzSimm.Rows - 1; j++)
             {
                 recordItem = this.gridPzSimm.Records(j);
                 if (!string.IsNullOrEmpty(recordItem.Fields("no").Text.ToString()))
                 {
                     decimal buyPrice;
                     decimal.TryParse(recordItem.Fields("price").Text.ToString(), out buyPrice);
                     long.TryParse(recordItem.Fields("volume").Text.ToString().Replace(",", ""), out num8);
                     decimal.TryParse(recordItem.Fields("budget").Text.ToString().Replace(",", ""), out num10);
                     if (num8 <= 0L)
                     {
                         this.ShowMessageBox("The budget is not enough!", frmOrderFormConfirm.OpenStyle.Error, this.tbPzBudget);
                         break;
                     }
                     AutoTradePzItem item = new AutoTradePzItem(j + 1, buyPrice, num8, num10, this._commandPz.UserId, this._commandPz.Account, this._commandPz.CustType, this._commandPz.Symbol);
                     this._commandPz.Items.Add(item);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         this.ShowError("btnPzSimulate_Click", ex);
     }
 }