private void Button_Confirm_Click(object sender, EventArgs e) { string outMsg = string.Empty; var selectedItems = _secuDataSource.Where(p => p.Selection).ToList(); if (selectedItems.Count == 0) { MessageDialog.Warn(this, msgNoSecuritySelected); return; } //only cancel the selected items var failedCancelItems = new List <CancelSecurityItem>(); var submitIds = selectedItems.ToList().Select(p => p.SubmitId).Distinct().ToList(); foreach (var submitId in submitIds) { var submitCalcItems = selectedItems.Where(p => p.SubmitId == submitId).ToList(); var commandIds = submitCalcItems.Select(p => p.CommandId).Distinct().ToList(); if (commandIds != null && commandIds.Count > 0) { foreach (var commandId in commandIds) { var calcSrcItems = submitCalcItems.Where(p => p.CommandId == commandId).ToList(); var calcResItems = _withdrawBLL.CancelSecuItem(submitId, commandId, calcSrcItems, null); if (calcResItems.Count != calcSrcItems.Count) { var failItems = calcSrcItems.ToList().Except(calcResItems).ToList(); failedCancelItems.AddRange(failItems); } } } } if (failedCancelItems.Count > 0) { var failedSecuCode = failedCancelItems.Select(p => p.SecuCode).ToList(); string strSecuCode = string.Join("|", failedSecuCode); string label = ConfigManager.Instance.GetLabelConfig().GetLabelText(msgPartialSecurityFail); string msg = string.Format("{0} {1}", label, strSecuCode); MessageDialog.Warn(this, msg); DialogResult = System.Windows.Forms.DialogResult.Cancel; } else { MessageDialog.Info(this, msgCancelSuccess); DialogResult = System.Windows.Forms.DialogResult.OK; } }
private void Button_Confirm_Click(object sender, EventArgs e) { string outMsg = string.Empty; var selectItems = _secuDataSource.Where(p => p.Selection).ToList(); if (selectItems.Count == 0) { MessageDialog.Warn(this, msgNoSecuritySelected); return; } if (!ValidateEntrustSecurities(selectItems, out outMsg)) { MessageDialog.Warn(this, outMsg); return; } if (MessageDialog.Info(this, msgEntrustCancelRedoConfirm, MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) { return; } var commandIds = selectItems.Select(p => p.CommandId).Distinct().ToList(); var submitIds = selectItems.Select(p => p.SubmitId).Distinct().ToList(); var failedCancelItems = new List <CancelRedoItem>(); var successCancelItems = new List <CancelRedoItem>(); foreach (var commandId in commandIds) { foreach (var submitId in submitIds) { var secuItems = selectItems.Where(p => p.Selection && p.CommandId == commandId && p.SubmitId == submitId).ToList(); var cancelItems = _withdrawBLL.CancelSecuItem(submitId, commandId, secuItems, null); if (cancelItems.Count > 0) { successCancelItems.AddRange(cancelItems); } if (cancelItems.Count != secuItems.Count) { var failItems = secuItems.Except(cancelItems); failedCancelItems.AddRange(failItems); } } } //Get the price type PriceType spotBuyPrice = PriceTypeHelper.GetPriceType(this.cbSpotBuyPrice); PriceType spotSellPrice = PriceTypeHelper.GetPriceType(this.cbSpotSellPrice); PriceType futureBuyPrice = PriceTypeHelper.GetPriceType(this.cbFuturesBuyPrice); PriceType futureSellPrice = PriceTypeHelper.GetPriceType(this.cbFuturesSellPrice); string resultMsg = string.Empty; foreach (var commandId in commandIds) { var oneCancelRedoItem = successCancelItems.Where(p => p.CommandId == commandId).ToList(); if (oneCancelRedoItem.Count > 0) { resultMsg += Submit(commandId, oneCancelRedoItem, null); } } StringBuilder sb = new StringBuilder(); if (failedCancelItems.Count > 0) { string format1 = ConfigManager.Instance.GetLabelConfig().GetLabelText(msgEntrustCancelPartialFail); string format2 = ConfigManager.Instance.GetLabelConfig().GetLabelText(msgEntrustCancelFailSecurity); sb.Append(format1); failedCancelItems.ForEach(p => { sb.AppendFormat(format2, p.SubmitId, p.CommandId, p.SecuCode); }); } if (!string.IsNullOrEmpty(resultMsg)) { sb.Append(resultMsg); } if (sb.Length > 0) { MessageDialog.Warn(this, sb.ToString()); } DialogResult = System.Windows.Forms.DialogResult.OK; }