private bool Dialog_SpotSecu_SaveData(object sender, object data) { bool ret = false; if (sender == null || data == null) { throw new Exception("Fail to get the setting from dialog"); } PortfolioSecurityDialog dialog = sender as PortfolioSecurityDialog; if (dialog == null) { return(ret); } if (data is TemplateStock) { TemplateStock stock = data as TemplateStock; switch (dialog.DialogType) { case DialogType.New: { TemplateStock findStock = _spotDataSource.SingleOrDefault(p => p.SecuCode.Equals(stock.SecuCode)); if (findStock != null) { ret = false; MessageDialog.Warn(this, msgCannotAddSameSecurity); } else { _spotDataSource.Add(stock); ret = true; } } break; case DialogType.Modify: { int findIndex = _spotDataSource.ToList().FindIndex(p => p.SecuCode.Equals(stock.SecuCode)); if (findIndex >= 0 && findIndex < _spotDataSource.Count) { ret = true; _spotDataSource[findIndex] = stock; } } break; default: break; } if (ret) { var template = _tempDataSource.Single(p => p.TemplateId == stock.TemplateNo); CalculateAmount(template); SwitchTemplateStockSave(true); this.secuGridView.Invalidate(); } } return(ret); }
private void ServerForm_Load(object sender, EventArgs e) { try { //load NSCC projected needs ProjectedNeedFactory pnf = new ProjectedNeedFactory(); ProjectedNeedParam pnp = new ProjectedNeedParam(); List <ProjectedNeedObject> pn = new List <ProjectedNeedObject>(); pnp.DateOfData_Date.AddParamValue(DateTime.Today); pnp.Todays_Current_Net_Position.AddParamValue(0, "<"); pnp.Participant_Clearing_Number.AddParamValue(Settings.DatabaseName); pnf.Load(pn, pnp); //load up todays projected needs foreach (ProjectedNeedObject p in pn) { ProjectedNeedsSummaryObject ps = new ProjectedNeedsSummaryObject(p); ps.Ticker = calc.UpdateStockInfo(p.CUSIP); ProjectedNeeds.Add(ps); } //load up todays balance orders BalanceOrderViewFactory bof = new BalanceOrderViewFactory(); BalanceOrderViewParam bop = new BalanceOrderViewParam(); List <BalanceOrderViewObject> bol = new List <BalanceOrderViewObject>(); List <BalanceOrderViewObject> combined = new List <BalanceOrderViewObject>(); bop.DateOfData_Date.AddParamValue(Utils.GetNthBusinessDay(DateTime.Today, -1)); bop.Participant_Clearing_Number.AddParamValue(Settings.Account.PadLeft(4, '0')); bof.Load(bol, bop); foreach (BalanceOrderViewObject b in bol) { BalanceOrderViewObject f = combined.Find(c => c.CUSIP == b.CUSIP); if (f == null) { combined.Add(b); } else { f.Quantity += b.Quantity; } } foreach (BalanceOrderViewObject b in combined) { if (ProjectedNeeds.Any(x => x.Cusip != null && b.CUSIP != null && x.Cusip.ToLower() == b.CUSIP.ToLower())) { var item = ProjectedNeeds.SingleOrDefault(x => x.Cusip.ToLower() == b.CUSIP.ToLower()); item.BeginningNeed += Math.Abs(b.Quantity.Value); } else { ProjectedNeedsSummaryObject ps = new ProjectedNeedsSummaryObject(b); ps.Ticker = calc.UpdateStockInfo(b.CUSIP); ProjectedNeeds.Add(ps); } } //ALANDIAS--------Balance orders weren't updating for overnight deliveries------------------------------ if (combined.Count > 0) { List <tblDTFPARTObject> DTFPO = new List <tblDTFPARTObject>(); tblDTFPARTFactory DTFPFact = new tblDTFPARTFactory(); tblDTFPARTParam DTFParam = new tblDTFPARTParam(); DTFParam.DateofData.AddParamValue(DateTime.Today); DTFParam.TransOrigSource.AddParamValue("CFSD", "!="); DTFParam.ParticipantNum.AddParamValue(Settings.Account.PadLeft(4, '0')); DTFParam.SubFunction.AddParamValue("DTFPDQ"); DTFParam.StatusCode.AddParamValue("m"); DTFParam.TransTypeNew.AddParamValue("026"); DTFParam.ContraParticipantNum.AddParamValue("0888"); DTFPFact.Load(DTFPO, DTFParam); var BOinPN = ProjectedNeeds.Where(x => x.NeedType != null && x.NeedType.ToLower() == "balanceorder"); foreach (var b in BOinPN) { var overNightDelivery = DTFPO.SingleOrDefault(x => x.CUSIP.ToLower() == b.Cusip.ToLower()); if (overNightDelivery != null) { b.DeliveredToCns += Convert.ToInt32(overNightDelivery.ShareQuantity); } } } //------------------------------------------------------------------------------------------------------ //ALANDIAS NSCCMISCFILE---------------------------------------- //Please Note //Misc import was done incorrectly. QuantityReceived is actually QuantityDelivered and vice versa //Activity '15' is cancel and '02' is new deliver //quantitydelivered with activity '15' means we received and it reduces the balance order we have to deliver //QuantityReceived with activity '02' means we have to deliver string NSCCMISCNewDeliver = "02"; string NSCCMISCCancel = "15"; vNSCCMiscellaneousActivityFactory MAF = new vNSCCMiscellaneousActivityFactory(); vNSCCMiscellaneousActivityParam MAP = new vNSCCMiscellaneousActivityParam(); List <vNSCCMiscellaneousActivityObject> MAList = new List <vNSCCMiscellaneousActivityObject>(); string Acct = Settings.Account.PadLeft(4, '0'); MAP.DateOfData.AddParamValue(DateTime.Today); MAP.ParticipantClearingNumber.AddParamValue(Acct); MAP.Activity.AddParamValue(NSCCMISCNewDeliver); MAP.Activity.AddParamValue(NSCCMISCCancel); MAF.Load(MAList, MAP); var WhatWeHaveToDeliver = MAList.Where(x => (x.Activity == NSCCMISCNewDeliver) && (x.QuantityReceived != 0)); var ReduceBalanceOrder = MAList.Where(x => (x.Activity == NSCCMISCCancel) && (x.QuantityDelivered != 0)); foreach (vNSCCMiscellaneousActivityObject MAItem in WhatWeHaveToDeliver) { ProjectedNeedsSummaryObject ps = new ProjectedNeedsSummaryObject(MAItem); ps.Ticker = calc.UpdateStockInfo(MAItem.CUSIP); ProjectedNeeds.Add(ps); } foreach (vNSCCMiscellaneousActivityObject rbo in ReduceBalanceOrder) { if (ProjectedNeeds.Any(x => x.Cusip != null && rbo.CUSIP != null && x.Cusip.ToLower() == rbo.CUSIP.ToLower())) { var item = ProjectedNeeds.FirstOrDefault(x => x.Cusip.ToLower() == rbo.CUSIP.ToLower()); item.BeginningNeed -= Math.Abs(Convert.ToInt32(rbo.QuantityDelivered.Value)); } /* * else * { * ProjectedNeedsSummaryObject ps = new ProjectedNeedsSummaryObject(b); * ps.Ticker = calc.UpdateStockInfo(b.CUSIP); * ProjectedNeeds.Add(ps); * } */ } //-------------------------------------------------------------------------------- /*IncomingDeliveryOrderObject o = calc.AllDtcActivity.Find(p => p.ReasonCode == "620"); * * int a = 5;*/ //load the data from the table first foreach (IncomingDeliveryOrderObject ido in calc.AllDtcActivity) { if (ido.Receiver == "00000888" && ido.Deliverer == Settings.Account.Padded()) { int i = ProjectedNeeds.Find("Cusip", ido.Cusip); if (i != -1) { ProjectedNeeds[i].DeliveredToCns += ido.ShareQuantity.Value; } } if (ido.Deliverer == "00000888" && ido.Receiver == Settings.Account.Padded()) { int i = ProjectedNeeds.Find("Cusip", ido.Cusip); if (i != -1) { ProjectedNeeds[i].Received += ido.ShareQuantity.Value; } } if (ido.ReasonCode == "620" /*"030"*/ && ido.Deliverer == Settings.Account.Padded()) { int i = ProjectedNeeds.Find("Cusip", ido.Cusip); if (i != -1 && ProjectedNeeds[i].NeedType == "BalanceOrder") { ProjectedNeeds[i].DeliveredToCns += ido.ShareQuantity.Value; CalcSummary(); ProjectedNeeds.Sort("OpenNeed", ListSortDirection.Descending); } } //ALANDIAS added for NSCCMISC if (ido.ReasonCode == "620" /*"030"*/ && ido.Deliverer == Settings.Account.Padded()) { int i = ProjectedNeeds.Find("Cusip", ido.Cusip); if (i != -1 && ProjectedNeeds[i].NeedType == "MiscellaneousFile") { ProjectedNeeds[i].DeliveredToCns += ido.ShareQuantity.Value; CalcSummary(); ProjectedNeeds.Sort("OpenNeed", ListSortDirection.Descending); } } } ProjectedNeeds.Sort("OpenNeed", ListSortDirection.Descending); foreach (DataGridViewColumn c in dgvRealTimePosition.Columns) { c.ReadOnly = true; } //dgvRealTimePosition.Columns["Ticker"].ReadOnly = false; ColorRows(); //ETB stuff EtbStockViewFactory ef = new EtbStockViewFactory(); EtbStockViewParam ep = new EtbStockViewParam(); List <EtbStockViewObject> temp = new List <EtbStockViewObject>(); ep.DateOfData_Date.AddParamValue(DateTime.Today); ef.Load(temp, ep); etbList = temp.ToDictionary(t => t.Symbol, t => t); ep = new EtbStockViewParam(); temp = new List <EtbStockViewObject>(); ep.DateOfData_Date.AddParamValue(Utils.GetNthBusinessDay(DateTime.Today, -3)); ef.Load(temp, ep); etbT3List = temp.ToDictionary(t => t.Symbol, t => t); } catch (Exception ex) { Trace.WriteLine(ex, TraceEnum.LoggedError); MessageBox.Show("Error starting app: \r\n" + ex.ToString()); } foreach (DataGridViewColumn c in dgvRealTimePosition.Columns) { c.ReadOnly = true; } CalcSummary(); }