Esempio n. 1
0
        private void ToolStripButton_ModifyTemplate_Click(object sender, System.EventArgs e)
        {
            StockTemplate stockTemplate = GetSelectTemplate();

            if (stockTemplate == null)
            {
                return;
            }

            TemplateDialog dialog = new TemplateDialog();

            dialog.SaveData     += new FormLoadHandler(Dialog_ModifyTemplate);
            dialog.Owner         = this;
            dialog.StartPosition = FormStartPosition.CenterParent;
            dialog.OnLoadControl(dialog, null);
            dialog.OnLoadData(dialog, stockTemplate);
            dialog.ShowDialog();
            if (dialog.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                MessageDialog.Info(this, msgModifySuccess);
                dialog.Dispose();
            }
            else
            {
                dialog.Close();
                dialog.Dispose();
            }
        }
Esempio n. 2
0
        private void ToolStripButton_DeleteTemplate_Click(object sender, EventArgs e)
        {
            StockTemplate template = GetSelectTemplate();

            if (template == null)
            {
                return;
            }

            //archive before deleting
            ArchiveTemplate(template);

            //delete
            int ret = _templateBLL.DeleteTemplate(template);

            if (ret == 1)
            {
                _tempDataSource.Remove(template);
                tempGridView.Invalidate();

                MessageDialog.Info(this, msgDeleteTempSuccess);
            }
            else
            {
                MessageDialog.Warn(this, msgDeleteTemp);
            }
        }
Esempio n. 3
0
        private void ToolStripButton_DeleteStock_Click(object sender, EventArgs e)
        {
            StockTemplate template = GetSelectTemplate();

            if (template == null)
            {
                return;
            }

            List <int> selectIndex = TSDataGridViewHelper.GetSelectRowIndex(this.secuGridView);

            if (selectIndex.Count == 0)
            {
                MessageDialog.Warn(this, msgDeleteSecuritySelect);
                return;
            }

            string format = ConfigManager.Instance.GetLabelConfig().GetLabelText(msgDeleteSecurity);
            string msg    = string.Format(format, template.TemplateId, template.TemplateName, selectIndex.Count);

            if (MessageDialog.Warn(this, msg, MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            List <TemplateStock> deleteItems = new List <TemplateStock>();

            for (int i = 0, count = selectIndex.Count; i < count; i++)
            {
                int rowIndex = selectIndex[i];
                if (rowIndex >= 0 && rowIndex < _spotDataSource.Count)
                {
                    deleteItems.Add(_spotDataSource[rowIndex]);
                }
            }

            int success = _templateBLL.DeleteStock(deleteItems);

            if (success > 0)
            {
                foreach (var deleteItem in deleteItems)
                {
                    _spotDataSource.Remove(deleteItem);
                }

                MessageDialog.Info(this, msgSecurityDeleteSuccess);
            }
            else
            {
                MessageDialog.Info(this, msgSecurityDeleteFail);
            }

            SwitchTemplateStockSave(false);
        }
Esempio n. 4
0
        public void Execute()
        {
            WorkbookContext workbookContext = App.Context.GetActiveWorkbookContext();
            var             testContext     = new TestContextImpl(workbookContext);

            testContext.Compile(workbookContext.TestCases);

            if (0 == testContext.TestSequence.CompileErrorCount)
            {
                MessageDialog.Info(Properties.Resources.SyntaxCheckSuccess);
            }
            else
            {
                MessageDialog.Error(Properties.Resources.SyntaxCheckFailed, testContext.TestSequence.CompileErrorCount);
            }
        }
Esempio n. 5
0
        private async void TryAddFile(string pathName)
        {
            if (fargs.ContainsKey(pathName))
            {
                await MessageDialog.Info("文件已存在", pathName);

                return;
            }
            else
            {
                OperationClerk.TryAdd(pathName);
            }
            //ToggleSwitch ts = NewSwitch(pathName);
            // ProcessListBox.Items.Add(ts);
            //switchCache[pathName] = ts;
        }
Esempio n. 6
0
        private void ToolStripButton_DeleteTemplate_Click(object sender, EventArgs e)
        {
            StockTemplate template = GetSelectTemplate();

            if (template == null)
            {
                return;
            }

            int ret = _templateBLL.DeleteTemplate(template);

            if (ret == 1)
            {
                MessageDialog.Info(this, msgDeleteTempSuccess);
            }
            else
            {
                MessageDialog.Warn(this, msgDeleteTemp);
            }
        }
Esempio n. 7
0
        private void ModifyTemplate(StockTemplate template)
        {
            TemplateDialog dialog = new TemplateDialog();

            dialog.SaveData     += new FormSaveHandler(Dialog_ModifyTemplate);
            dialog.Owner         = this;
            dialog.StartPosition = FormStartPosition.CenterParent;
            dialog.OnLoadControl(dialog, null);
            dialog.OnLoadData(dialog, template);
            dialog.ShowDialog();
            if (dialog.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                MessageDialog.Info(this, msgModifySuccess);
                dialog.Dispose();
            }
            else
            {
                dialog.Close();
                dialog.Dispose();
            }
        }
        private void Button_Transfer_Click(object sender, EventArgs e)
        {
            //get the source portfolio, instance
            AccountItem srcAccount    = null;
            var         srcSelectFund = cbSrcFundCode.SelectedItem as ComboOptionItem;

            if (srcSelectFund != null)
            {
                srcAccount = srcSelectFund.Data as AccountItem;
            }

            PortfolioItem srcPortfolio       = null;
            var           srcSelectPortfolio = cbSrcPortfolio.SelectedItem as ComboOptionItem;

            if (srcSelectPortfolio != null)
            {
                srcPortfolio = srcSelectPortfolio.Data as PortfolioItem;
            }

            TradeInstance srcTradingInstance = null;
            var           srcSelectInstance  = cbSrcTradeInst.SelectedItem as ComboOptionItem;

            if (srcSelectInstance != null)
            {
                srcTradingInstance = srcSelectInstance.Data as TradeInstance;
            }

            //get the target portfolio, instance
            AccountItem destAccount    = null;
            var         destSelectFund = cbDestFundCode.SelectedItem as ComboOptionItem;

            if (destSelectFund != null)
            {
                destAccount = destSelectFund.Data as AccountItem;
            }
            PortfolioItem destPortfolio       = null;
            var           destSelectPortfolio = cbDestPortfolio.SelectedItem as ComboOptionItem;

            if (destSelectPortfolio != null)
            {
                destPortfolio = destSelectPortfolio.Data as PortfolioItem;
            }

            TradeInstance destTradingInstance = null;
            var           destSelectInstance  = cbDestTradeInst.SelectedItem as ComboOptionItem;

            if (destSelectInstance != null)
            {
                destTradingInstance = destSelectInstance.Data as TradeInstance;
            }

            if (!ValidatePortfolio(srcPortfolio) || !ValidatePortfolio(destPortfolio))
            {
                MessageDialog.Warn(this, msgNoEmptyDest);
                return;
            }

            if (!ValidateTradingInstance(srcTradingInstance) || !ValidateTradingInstance(destTradingInstance))
            {
                MessageDialog.Warn(this, msgNoEmptyDest);
                return;
            }

            var selectedItems = _srcDataSource.Where(p => p.Seletion).ToList();

            if (selectedItems.Count == 0)
            {
                MessageDialog.Warn(this, msgNoSecuritySelected);
                return;
            }

            var selectedAmountItems = selectedItems.Where(p => p.TransferedAmount <= 0).ToList();

            if (selectedAmountItems.Count > 0)
            {
                MessageDialog.Warn(this, msgNoTransferAmount);
                return;
            }

            var invalidItems = selectedItems.Where(p => p.TransferedAmount > p.AvailableTransferedAmount || p.TransferedAmount > p.CurrentAmount).ToList();

            if (invalidItems.Count > 0)
            {
                MessageDialog.Warn(this, msgInvalidAmount);
                return;
            }

            string notes = this.rtbNotes.Text;

            if (srcTradingInstance != null && destTradingInstance != null)
            {
                int ret = _tradeInstanceSecuBLL.Transfer(destTradingInstance, srcTradingInstance, selectedItems, notes);
                if (ret > 0)
                {
                    MessageDialog.Info(this, msgSuccess);
                    //TODO: update the gridview security in both source and destination
                    AdjustSecurity(selectedItems);

                    this.srcGridView.Invalidate();
                    this.destGridView.Invalidate();
                }
            }
        }
        private void GiveOrder()
        {
            List <OrderConfirmItem> orderItemList = new List <OrderConfirmItem>();
            var selectedItems = _monitorDataSource.Where(p => p.Selection).ToList();

            if (selectedItems.Count == 1)
            {
                var openItem  = selectedItems[0];
                var orderItem = GetSubmitItem(openItem);
                if (orderItem == null)
                {
                    string format = ConfigManager.Instance.GetLabelConfig().GetLabelText(msgSubmitFail);
                    string msg    = string.Format(format, openItem.MonitorName);
                    MessageDialog.Fail(this, msg);
                    return;
                }
                else
                {
                    orderItemList.Add(orderItem);
                }
            }
            else if (selectedItems.Count > 1)
            {
                DateTime startDate  = DateUtil.OpenDate;
                DateTime endDate    = DateUtil.CloseDate;
                var      orderItems = new List <OrderConfirmItem>();
                foreach (var openItem in selectedItems)
                {
                    OrderConfirmItem orderItem = new OrderConfirmItem
                    {
                        MonitorId     = openItem.MonitorId,
                        MonitorName   = openItem.MonitorName,
                        PortfolioId   = openItem.PortfolioId,
                        PortfolioName = openItem.PortfolioName,
                        PortfolioCode = openItem.PortfolioCode,
                        TemplateId    = openItem.TemplateId,
                        TemplateName  = openItem.TemplateName,
                        InstanceCode  = string.Format("{0}-{1}-{2}", openItem.PortfolioId, openItem.TemplateId, DateFormat.Format(DateTime.Now, ConstVariable.DateFormat1)),
                        Copies        = openItem.Copies,
                        FuturesList   = new List <string>()
                        {
                            openItem.FuturesContract
                        },
                        StartDate = DateUtil.GetIntDate(startDate),
                        EndDate   = DateUtil.GetIntDate(endDate),
                        StartTime = DateUtil.GetIntTime(startDate),
                        EndTime   = DateUtil.GetIntTime(endDate),
                    };

                    orderItems.Add(orderItem);
                }

                OpenMultiPositionDialog dialog = new OpenMultiPositionDialog(_gridConfig);
                dialog.Owner         = this;
                dialog.StartPosition = FormStartPosition.CenterParent;
                dialog.OnLoadControl(dialog, null);
                dialog.OnLoadData(dialog, orderItems);
                if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    orderItemList = (List <OrderConfirmItem>)dialog.GetData();
                    dialog.Dispose();
                }
                else
                {
                    dialog.Dispose();
                }
            }

            if (orderItemList.Count == 0)
            {
                return;
            }

            List <OrderConfirmItem> successItems = new List <OrderConfirmItem>();
            List <OrderConfirmItem> failItems    = new List <OrderConfirmItem>();

            foreach (var orderItem in orderItemList)
            {
                var      newOpenItem       = GetOpenPositionItem(orderItem);
                var      selectedSecuItems = _securityDataSource.Where(p => p.Selection && p.MonitorId == newOpenItem.MonitorId).ToList();
                DateTime startDate         = DateUtil.GetDateTimeFromInt(orderItem.StartDate, orderItem.StartTime);
                DateTime endDate           = DateUtil.GetDateTimeFromInt(orderItem.EndDate, orderItem.EndTime);
                startDate = DateUtil.GetStartDate(startDate);
                endDate   = DateUtil.GetEndDate(endDate, startDate);

                int ret = _tradeCommandBLL.SubmitOpenPosition(newOpenItem, selectedSecuItems, startDate, endDate);

                if (ret > 0)
                {
                    successItems.Add(orderItem);
                }
                else
                {
                    failItems.Add(orderItem);
                }
            }

            if (successItems.Count == orderItemList.Count)
            {
                MessageDialog.Info(this, msgCommandSuccess);
            }
            else if (failItems.Count == orderItemList.Count)
            {
                MessageDialog.Fail(this, msgCommandFail);
            }
            else
            {
                StringBuilder sbSuccess = new StringBuilder();
                StringBuilder sbFail    = new StringBuilder();
                successItems.ForEach(p => sbSuccess.AppendFormat("{0}|", p.MonitorId));

                failItems.ForEach(p => sbFail.AppendFormat("{0}|", p.MonitorId));

                string format = ConfigManager.Instance.GetLabelConfig().GetLabelText(msgCommandSuccessFail);
                string msg    = string.Format(format, sbSuccess.ToString().TrimEnd('|'), sbFail.ToString().TrimEnd('|'));

                MessageDialog.Warn(this, msg);
            }
        }
Esempio n. 10
0
 private void ToolStripButton_Click_Refresh(object sender, System.EventArgs e)
 {
     MessageDialog.Info(this, "菜单未完成");
 }
Esempio n. 11
0
 private void MenuItem_Click_Help(object sender, System.EventArgs e)
 {
     MessageDialog.Info(this, "菜单未完成");
 }
Esempio n. 12
0
        private void ToolStripButton_Click_Cancel(object sender, System.EventArgs e)
        {
            var selectedItems = _dataSource.Where(p => p.Selection).ToList();

            if (selectedItems.Count == 0)
            {
                MessageDialog.Warn(this, msgNoSelected);
                return;
            }

            var invalidItems = selectedItems.Where(p => p.ECommandStatus != Model.EnumType.CommandStatus.Effective &&
                                                   p.ECommandStatus != Model.EnumType.CommandStatus.Modified).ToList();

            if (invalidItems.Count > 0)
            {
                MessageDialog.Warn(this, msgInvalidSelected);
                return;
            }

            CancelCommandDialog dialog = new CancelCommandDialog();

            dialog.Owner         = this;
            dialog.StartPosition = FormStartPosition.CenterParent;
            dialog.OnLoadControl(dialog, null);
            dialog.OnLoadData(dialog, null);
            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string        notes     = (string)dialog.GetData();
                StringBuilder sbSuccess = new StringBuilder();
                StringBuilder sbFailure = new StringBuilder();

                sbSuccess.Append("撤销成功指令:");
                sbFailure.Append("撤销失败指令:");
                List <int> lsSuccess = new List <int>();
                List <int> lsFailure = new List <int>();
                foreach (var selectedItem in selectedItems)
                {
                    //call the UFX interface to withdraw the entrust securities

                    //TODO: update the security in tradinginstance table
                    if (_commandManagementBLL.Update(selectedItem) > 0)
                    {
                        lsSuccess.Add(selectedItem.CommandId);
                    }
                    else
                    {
                        lsFailure.Add(selectedItem.CommandId);
                    }
                }

                string msg = string.Empty;
                if (lsSuccess.Count > 0)
                {
                    sbSuccess.Append(string.Join(",", lsSuccess));
                    msg = sbSuccess.ToString();
                }

                if (lsFailure.Count > 0)
                {
                    sbFailure.Append(string.Join(",", lsFailure));

                    msg += sbFailure.ToString();
                }

                MessageDialog.Info(this, msg);
            }
            else
            {
                //do nothing
            }

            //dialog.Close();
            dialog.Dispose();
        }
Esempio n. 13
0
        private void ToolStripButton_Click_Modify(object sender, System.EventArgs e)
        {
            var selectedItems = _dataSource.Where(p => p.Selection).ToList();

            if (selectedItems.Count == 0)
            {
                MessageDialog.Warn(this, msgNoSelected);
                return;
            }

            if (selectedItems.Count > 1)
            {
                MessageDialog.Warn(this, msgCanEditOnlyOne);
                return;
            }

            var invalidItems = selectedItems.Where(p => p.ECommandStatus != Model.EnumType.CommandStatus.Effective &&
                                                   p.ECommandStatus != Model.EnumType.CommandStatus.Modified).ToList();

            if (invalidItems.Count > 0)
            {
                MessageDialog.Warn(this, msgInvalidSelected);
                return;
            }

            var selectedItem           = selectedItems.First();
            ModifyCommandDialog dialog = new ModifyCommandDialog(_gridConfig);

            dialog.Owner         = this;
            dialog.StartPosition = FormStartPosition.CenterParent;
            dialog.OnLoadControl(dialog, null);
            dialog.OnLoadData(dialog, selectedItem);
            var dialogResult = dialog.ShowDialog();

            if (dialogResult == System.Windows.Forms.DialogResult.OK)
            {
                //object resData = dialog.GetData();
                //if (resData != null && resData is List<ModifySecurityItem>)
                //{
                //    var secuItems = resData as List<ModifySecurityItem>;

                //    //TODO: update the tradeinstance item
                //    if (UpdateItem(selectedItem, secuItems) > 0)
                //    {
                MessageDialog.Info(this, msgModifySuccess);
                //    }
                //    else
                //    {
                //        MessageDialog.Fail(this, msgModifyFailure);
                //    }
                //}

                dialog.Dispose();
            }
            else if (dialogResult == System.Windows.Forms.DialogResult.No)
            {
                //do nothing
                MessageDialog.Fail(this, msgModifyFailure);

                dialog.Dispose();
            }
        }