private void PopulateMachineCheckboxes(Data.EnterpriseTest.Model.User selectedUser) { Cursor = Cursors.WaitCursor; User currentUser = _users.FirstOrDefault(f => f.UserName == selectedUser.UserName); if (currentUser != null) { var hostNames = currentUser.UserGroups.SelectMany(e => e.VirtualMachineGroupAssocs).Select(e => e.MachineName).Distinct(); if (hostNames.Count() == 0) { foreach (DataGridViewRow row in machines_DataGridView.Rows) { row.Cells[0].Value = machine_ImageList.Images["Blank"]; } } else { foreach (DataGridViewRow row in machines_DataGridView.Rows) { bool check = hostNames.Contains((string)row.Cells["hostNameColumn"].Value); if (check) { row.Cells[0].Value = machine_ImageList.Images["Tick"]; } else { row.Cells[0].Value = machine_ImageList.Images["Blank"]; } } } } Cursor = Cursors.Default; }
/// <summary> /// Populates the checkboxes. /// </summary> /// <param name="selectedGroup">The selected group.</param> private void PopulateMachineCheckboxes(UserGroup selectedGroup) { Cursor = Cursors.WaitCursor; UserGroup currentGroup = _groups.FirstOrDefault(f => f.GroupName == selectedGroup.GroupName); if (currentGroup != null) { var hostNames = (from u in currentGroup.VirtualMachineGroupAssocs select u.MachineName).ToList(); if (hostNames.Count == 0) { foreach (DataGridViewRow row in machines_DataGridView.Rows) { row.Cells[0].Value = false; } } else { foreach (DataGridViewRow row in machines_DataGridView.Rows) { bool check = hostNames.Contains((string)row.Cells["hostNameColumn"].Value); row.Cells[0].Value = check; } } } Cursor = Cursors.Default; }
private void UserEditForm_Load(object sender, EventArgs e) { var selectedItem = _selectedItemsList.FirstOrDefault(x => x.Name.Equals(_group.Name)); if (selectedItem != null) { var actualGroup = _masterItemsList.FirstOrDefault(x => x.Name.Equals(_group.Name)); if (actualGroup != null) { groupName_ComboBox.Items.Add(actualGroup); groupName_ComboBox.SelectedIndex = 0; groupName_ComboBox.Enabled = false; description_TextBox.Focus(); } else { MessageBox.Show("The group '{0}' is not configured on the Active Directory server, so it will be removed"); _selectedItemsList.Remove(selectedItem); Close(); } } else { foreach (var item in _masterItemsList) { if (!_selectedItemsList.Any(x => x.Name.Equals(item.Name))) { groupName_ComboBox.Items.Add(item); } } } description_TextBox.DataBindings.Add("Text", _group, "Description", false, DataSourceUpdateMode.OnPropertyChanged); }
/// <summary> /// One method to edit the current customer in the DataGridView /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// * /// * Another method is to data bind customer properties to controls on the edit form. /// </remarks> private void cmdEditCurrent_Click(object sender, EventArgs e) { EditorForm f = new EditorForm(bsCustomers.Customer(), ContactTitles); try { if (f.ShowDialog() == DialogResult.OK) { Customer customer = blCustomers.FirstOrDefault(cust => cust.CustomerIdentifier == bsCustomers.CustomerIdentifier()); Customers customers = new Customers(); if (customers.UpdateCustomer(customer)) { bsCustomers.ResetCurrentItem(); } else { MessageBox.Show(customers.ValidationMessage); } } } finally { f.Dispose(); } }
private void AddButton_Click(object sender, EventArgs e) { decimal newAmount = AmountTextbox.Value; if (newAmount > _origAmount) { ClientHelper.ShowErrorMessage("Amount cannot be greater than original amount."); return; } if (!selectedDebits.Any(a => a.Reference == ReferenceTextbox.Text)) { var newDebit = new DebitDetailModel() { Id = this.id, Reference = ReferenceTextbox.Text, Amount = AmountTextbox.Value }; selectedDebits.Add(newDebit); } else { var oldDebit = selectedDebits.FirstOrDefault(a => a.Reference == ReferenceTextbox.Text); oldDebit.Amount = AmountTextbox.Value; } BindSelectedDebits(); ComputeTotal(); }
/// <summary> /// For validating stuff, currently not production ready. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddNewCustomerButton_Click(object sender, EventArgs e) { /* * NOTE: WIP */ CustomerEntity customerEntity = _customerView.FirstOrDefault(x => x.CustomerIdentifier == 0); customerEntity.ContactIdentifier = 52; customerEntity.CountryIdentifier = 9; Customers customers = new Customers { CompanyName = customerEntity.CompanyName, CountryIdentifier = customerEntity.CountryIdentifier, ContactId = 52, ContactTypeIdentifier = 5 }; CustomersTestOperations.Context.Attach(customers).State = EntityState.Added; if (CustomersTestOperations.Context.SaveChanges() != 1) { // alert user and/or write to log file. } }
//ALANDIAS Run This everytime ProcessOrders() runs, not inside the method since this method runs through a loop private void RemoveNonCashItemsFromProblemOrders(SortableBindingList <PriceControlDeliveryOrder> POList) { List <NonCashItemsFromCurrentPositionObject> NCIList = new List <NonCashItemsFromCurrentPositionObject>(); NonCashItemsFromCurrentPositionDa NCIDA = new NonCashItemsFromCurrentPositionDa(); NCIDA.Load(NCIList); NCIList.ForEach(x => { if (x.Ctpydtcnumber != null) { x.Ctpydtcnumber = x.Ctpydtcnumber.PadLeft(4, '0'); } }); List <PriceControlDeliveryOrder> ProblemOrdersItemsToRemove = new List <PriceControlDeliveryOrder>(); foreach (var item in NCIList) { PriceControlDeliveryOrder ItemToRemove = POList.FirstOrDefault(x => x.ClearingNumber == item.ClearingNo && x.CounterParty == item.Ctpydtcnumber && x.Cusip == item.cusip && x.ShareQuantity == item.quantity); if (ItemToRemove != null) { ProblemOrdersItemsToRemove.Add(ItemToRemove); } } //Allow in production ProblemOrdersItemsToRemove.ForEach(x => POList.Remove(x)); }
private void OnChanged(object source, FileSystemEventArgs e) { // TODO var file = _borderlands3FilesList.FirstOrDefault(a => a.FileName == e.Name); if (file != null) { Console.WriteLine("OnChange " + e.FullPath); file.ReReadFile(new FileInfo(e.FullPath)); // Try to update row now. No lag please var row = dataGridView1.Rows.Cast <DataGridViewRow>().Where(r => r.Cells[0].Value.ToString().Equals(e.Name)).FirstOrDefault(); if (row != null) { dataGridView1.InvalidateRow(row.Index); } } }
/// <summary> /// Requests that the control finalize any edits that have been made by saving /// them from the UI controls to their backing objects. /// </summary> public override void FinalizeEdit() { // Modify focus so that any data bindings will update name_TextBox.Focus(); // Push the configuration data into the ExecutionPlan property of the metadata foreach (var item in _loadTester.VirtualResourceMetadataSet) { if (string.IsNullOrEmpty(item.ExecutionPlan)) { var configItem = _configurations.FirstOrDefault(e => e.Metadata.VirtualResourceMetadataId == item.VirtualResourceMetadataId); if (configItem != null) { item.ExecutionPlan = LegacySerializer.SerializeDataContract(configItem.ExecutionPlan).ToString(); } } else { // Entity Framework handles all situations where no fields have changed, except serialized XML. // So to ensure this form doesn't think something has changed when it hasn't, only update // the serialized XML if there is actually a change. XDocument oldPlan = XDocument.Parse(item.ExecutionPlan); var configItem = _configurations.FirstOrDefault(e => e.Metadata.VirtualResourceMetadataId == item.VirtualResourceMetadataId); if (configItem != null) { string serializedPlan = LegacySerializer.SerializeDataContract(configItem.ExecutionPlan).ToString(); XDocument newPlan = XDocument.Parse(serializedPlan); if (!XmlUtil.AreEqual(oldPlan, newPlan, orderInvariant: true)) { item.ExecutionPlan = serializedPlan; } } } } if (GlobalSettings.IsDistributedSystem) { // Need to grab the platform directly from the combobox _loadTester.Platform = ((FrameworkClientPlatform)virtualMachinePlatform_ComboBox.SelectedItem).FrameworkClientPlatformId; } }
/// <summary> /// Gets a faculty list /// </summary> /// <param name="sender">Form object</param> public async void GetAllAfaculty(object sender = null) { if (String.IsNullOrWhiteSpace(DataConnectionClass.ConnectionString)) { return; } Sender = sender; SortableBindingList <Faculty> fac = await Task.Run(() => Get_Faculty_List()); SortableBindingList <BuildingClass> b = Get_Building_List(); long cnt = 0; while ((b is null)) { cnt++; System.Threading.Thread.Sleep(150); } foreach (Faculty f in fac) { if (b.Any(g => f.Building_Id == g.BuildingId)) { f.Building_Name = b.FirstOrDefault(i => f.Building_Id == i.BuildingId).ToString(); } else { f.Building_Name = "Needs Updated"; } } if (Sender is Manage) { Manage t = (Manage)Sender; DataConnectionClass.DataLists.FacultyList = fac; BindingSource bs = new BindingSource { DataSource = DataConnectionClass.DataLists.FacultyList }; t.dataGridView1.DataSource = bs; try { t.dataGridView1.Columns["Id"].Visible = false; t.dataGridView1.Columns["Faculty_PersonId"].Visible = false; t.dataGridView1.Columns["Building_Id"].Visible = false; } catch (Exception) { // } } else { DataConnectionClass.DataLists.FacultyList = fac; } }
private void この行を削除ToolStripMenuItem_Click(object sender, EventArgs e) { try { var ttt = (string)dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[6].Value; var ttt2 = lists_si.FirstOrDefault(x => x.LiveId == ttt); lists_si.Remove(ttt2); } catch (Exception Ex) { Debug.WriteLine(Ex.Message); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); UpdateLddEnvironment(); LoadLocalizationFiles(); LoadAvailableLanguages(); GenerateLanguageColumns(); LoadLocalizations(Languages.FirstOrDefault(x => x.AppFileExist)); }
private void EditCurrentRow() { Customer customer = blCustomers.FirstOrDefault(cust => cust.CustomerIdentifier == bsCustomers.CustomerIdentifier()); EditorForm f = new EditorForm(customer, ContactTitles); try { if (f.ShowDialog() == DialogResult.OK) { bsCustomers.ResetCurrentItem(); } } finally { f.Dispose(); } }
private void UpdateStudConnectorList() { if (CurrentProject == null) { ConnectorList.Clear(); } else { var studConnections = CurrentProject.GetAllElements <PartConnection>() .Where(x => x.ConnectorType == ConnectorType.Custom2DField).ToList(); foreach (var studConn in studConnections) { if (string.IsNullOrEmpty(studConn.ID)) { continue; } var comboItem = ConnectorList.FirstOrDefault(x => x.ID == studConn.ID); if (comboItem == null) { comboItem = new ConnectorComboItem(studConn); comboItem.ConnTypeText = studConn.SubType == 22 ? BottomStudsLabel.Text : TopStudsLabel.Text; ConnectorList.Add(comboItem); } } var validConnectionIDs = studConnections.Select(x => x.ID).ToList(); var usedConnectionIDs = CurrentProject.GetAllElements <StudReference>() .Select(x => x.ConnectionID).Distinct().ToList(); foreach (var comboItem in ConnectorList.ToArray()) { if (!validConnectionIDs.Contains(comboItem.ID) && !usedConnectionIDs.Contains(comboItem.ID)) { ConnectorList.Remove(comboItem); } } } }
private void AddFile(string filePath) { bool copyFileToServer = true; try { Cursor = Cursors.WaitCursor; string fileName = Path.GetFileName(filePath); string repository = GlobalSettings.Items[Setting.PrintDriverConfigFileLocation]; string destinationPath = Path.Combine(repository, fileName); if (EnvironmentFileServer.FileExists(destinationPath)) { var result = MessageBox.Show( "File [{0}] already exists on the file server.\nClick \"Yes\" to overwrite, \"No\" to keep existing, or \"Cancel\"".FormatWith(fileName), "Overwrite File", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation ); switch (result) { case DialogResult.Cancel: return; case DialogResult.No: copyFileToServer = false; break; case DialogResult.Yes: copyFileToServer = true; break; } } // Copy to file server if not already exist or user has chosen to overwrite if (copyFileToServer) { EnvironmentFileServer.CopyFile(filePath, destinationPath); } // Add entry to database if it doesn't already exist PrintDriverConfig config = _configData.FirstOrDefault(e => Path.GetFileName(e.ConfigFile).Equals(fileName, StringComparison.OrdinalIgnoreCase)); if (config == null) { config = new PrintDriverConfig { PrintDriverConfigId = SequentialGuid.NewGuid(), ConfigFile = destinationPath }; _configData.Add(config); _context.PrintDriverConfigs.Add(config); } // Set the newly uploaded item as current SelectedConfig = config; } catch (Exception ex) { MessageBox.Show ( "Error communicating with remote server.{0}{1}".FormatWith(Environment.NewLine, ex.Message), "Error Adding File", MessageBoxButtons.OK, MessageBoxIcon.Error ); } finally { Cursor = Cursors.Default; } }
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(); }