private void tsbRemoveDuplItem_Click(object sender, EventArgs e) { DialogResult MsgBoxResult = MessageBox.Show( "Are you sure you want to delete duplicated keywords in the list?", "Delete duplicated keywords", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); if (MsgBoxResult == DialogResult.Yes) { entryList = new BindingList <Entry>(entryList.Distinct().ToList()); lstEntry.DataSource = entryList; } }
public MainModel() { DataContext = new DiaryDataContext(ConnectionString); tableDiary = DataContext.Diary; listTime.Add("所有"); foreach (Diary diary in tableDiary) { listId.Add(diary.Id); listTime.Add(diary.time); listTitle.Add(diary.title); listContent.Add(diary.content); listWeather.Add(diary.weather); listCurrentTime.Add(diary.time); } listTime = new BindingList <string>(listTime.Distinct().ToList()); }
private void button_New_Click(object sender, EventArgs e) { List_of_what_is_Mapped.Add(new Mapped { Receipt_Name = textBox_Receipt_name.Text, AutoTask_Name = textBox_AT_name.Text }); dataGridView1.DataSource = null;////nblIAM RESET DATASOUCE!!!!!!! var source = List_of_what_is_Mapped; bool isUnique = List_of_what_is_Mapped.Distinct().Count() == List_of_what_is_Mapped.Count(); if (isUnique == false) { MessageBox.Show("Error Duplictes"); } dataGridView1.DataSource = source; DataGridViewColumn column = dataGridView1.Columns[0]; column.Width = 430; DataGridViewColumn columns = dataGridView1.Columns[1]; columns.Width = 430; dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.RowCount - 1; dataGridView1.Rows[dataGridView1.RowCount - 1].Selected = true; using (StreamWriter sw = new StreamWriter(@"Mapping_dgv_Entries.txt")) { foreach (Mapped item in List_of_what_is_Mapped) { sw.WriteLine(item.Receipt_Name + "," + item.AutoTask_Name ); } } Logwriter.writelog("#NEW MAPPING:Time,>>>>>Item Updated:Receipt Name, AT Name<<<<<"); Logwriter.writelog("NEW MAPPING:" + current_timestamp + "," + ">>>>>" + textBox_Receipt_name.Text + "," + textBox_AT_name.Text); }
private void InitializeViewModel(int selectedOrderId) { var order = _orderRepository.Get(selectedOrderId); CustomerType = order.Customer.CustomerType.Id; var coldWeightEntry = order.ColdWeightEntries.FirstOrDefault(); if (coldWeightEntry != null) { var boxes_ = new BindingList <CaseSize>(); var bags = new BindingList <CaseSize>(); foreach (var orderDetail in order.OrderDetail) { CaseSize bag = orderDetail.Product.BagSizeEntity; CaseSize box = orderDetail.Product.BoxSizeEntity; var customerProductData = orderDetail.Product.CustomerProductData.FirstOrDefault(x => x.CustomerId == order.CustomerId); if (customerProductData != null && orderDetail.Product != null && orderDetail.Product.CustomerProductData != null && orderDetail.Product.CustomerProductData.Any(x => x.CustomerId == order.CustomerId)) { if (customerProductData.BagSizeId.HasValue) { bag = customerProductData.BagSizeEntity; } if (customerProductData.BoxSizeId.HasValue) { box = customerProductData.BoxSizeEntity; } } bags.Add(bag); boxes_.Add(box); } var coldWeightId = coldWeightEntry.Id; BagsTab.Visibility = order.BagEnable ? Visibility.Visible : Visibility.Collapsed; _viewModel.IsCustomOwner = order.Customer.CustomerTypeId == OmsCustomerType.Custom; if (_viewModel.IsCustomOwner) { _viewModel.CustomBagGridViewModel = new CustomBagGridViewModel() { AnimalNumbers = _labelService.GetAnimalNumbers(selectedOrderId), BagsTareWeights = new BindingList <CaseSize>(bags.Distinct().ToList()) }; _viewModel.CustomBoxGridViewModel = new CustomBoxGridViewModel() { BoxesCustomList = _labelService.GetBoxesCustomList(selectedOrderId), BoxesTareWeights = new BindingList <CaseSize>(boxes_.Distinct().ToList()) }; _viewModel.CustomTrayGridViewModel = new CustomBoxGridViewModel() { BoxesCustomList = _labelService.GetTraysCustomList(selectedOrderId), BoxesTareWeights = new BindingList <CaseSize>(boxes_.Distinct().ToList()) }; } else { _viewModel.UnitListViewModel = new UnitListViewModel(); var qualities = _qualityGradeRepository.GetAll().ToList().Select(x => new QualityGrade() { Name = x.Name, Id = x.Id }).ToList(); var animalLabels = _animalLabelRepository.GetAll().ToList(); var animalNames = animalLabels.Where( x => x.ColdWeightEntryDetails.ToList().Select(v => v.ColdWeightEntry.Id).Contains(coldWeightId)) .ToList() .Select(x => new AnimalLabelsViewModel() { Name = x.Name, IsOrganic = x.IsOrganic, Id = x.Id, Species = new SpeciesViewModel() { Name = x.Species.Name } }); _viewModel.UnitListViewModel.QualityGrades = new BindingList <QualityGrade>(qualities); _viewModel.UnitListViewModel.AnimalLabels = new BindingList <AnimalLabelsViewModel>(animalNames.ToList()); var labelGridItems = _labelService.GetLabelGridItems(selectedOrderId, !order.BagEnable); _viewModel.UnitListViewModel.BoxesList = new BindingList <LabelGridItem>(labelGridItems.Item1.OrderBy(x => x.ProductId).ToList()); foreach (var item in _viewModel.UnitListViewModel.BoxesList) { item.ItemColumn = _viewModel.UnitListViewModel.BoxesList.IndexOf(item); } //_viewModel.UnitListViewModel.TraysList = // new BindingList<LabelGridItem>(labelGridItems.Item3.OrderBy(x => x.ProductId).ToList()); //foreach (var item in _viewModel.UnitListViewModel.TraysList) //{ // item.ItemColumn = _viewModel.UnitListViewModel.TraysList.IndexOf(item); //} if (order.BagEnable) { _viewModel.UnitListViewModel.BagsList = new BindingList <LabelGridItem>(labelGridItems.Item2.OrderBy(x => x.ProductId).ToList()); } _viewModel.UnitListViewModel.BoxesTareWeights = new BindingList <CaseSize>(boxes_.Distinct().ToList()); _viewModel.UnitListViewModel.BagsTareWeights = new BindingList <CaseSize>(bags.Distinct().ToList()); } } if (!order.BagEnable) { BoxTab.IsSelected = true; } BtnEditLabels.IsEnabled = !_viewModel.IsCustomOwner; GridBags.Visibility = GetVisibility(!_viewModel.IsCustomOwner); GridBoxes.Visibility = GetVisibility(!_viewModel.IsCustomOwner); GridTray.Visibility = GetVisibility(!_viewModel.IsCustomOwner); GridCustomBags.Visibility = GetVisibility(_viewModel.IsCustomOwner); GridCustomBoxes.Visibility = GetVisibility(_viewModel.IsCustomOwner); GridCustomTray.Visibility = GetVisibility(_viewModel.IsCustomOwner); _viewModel.SpecialInstructions = order.SpecialInstructions; _viewModel.CustomerComments = order.CustomerComments; _viewModel.CombosSource = GetCombosSource(order); _viewModel.OffalsSource = GetOffalsSource(order); _viewModel.OrderSummary = GetOrderSummary(selectedOrderId); _viewModel.ProcessDate = order.ProcessDate; DisplayScaleOutput(string.Empty); }
private async void Submit() { try { bool splitSpectra = checkBox1.Checked; int spectraToSplit = (int)numericUpDown1.Value; submitToolStripMenuItem.Enabled = false; dataGridView1.Enabled = false; string jobName = textBox1.Text; if (DtaFiles.Count == 0) { throw new ArgumentNullException("DTA Files", "Please supply at least one DTA file for the submission"); } if (string.IsNullOrWhiteSpace(jobName)) { throw new ArgumentNullException("Job Name", "Please supply a job name for the submission"); } DatabaseFile[] dataBases = checkedListBox1.CheckedItems.Cast <DatabaseFile>().ToArray(); if (dataBases.Length == 0) { throw new ArgumentNullException("Database", "Please selected at least one database for the submission"); } UserModFile userModFile = null; string userModFilePath = textBox2.Text; if (!string.IsNullOrWhiteSpace(userModFilePath)) { if (!System.IO.File.Exists(userModFilePath)) { throw new FileNotFoundException("Unable to locate user mod file", userModFilePath); } userModFile = new UserModFile(userModFilePath); } string remoteJobDirectory = _connection.CreateDirectory(_connection.CondorFolder + jobName); if (userModFile != null) { SetStatusLabel("Uploading User Mod File..."); await _connection.PutFileAsync(userModFile, remoteJobDirectory); } List <DtaFile> dtaFiles = new List <DtaFile>(); if (splitSpectra) { SetStatusLabel("Splitting Dta Files to contain " + spectraToSplit + " spectra each..."); Task t = new Task(() => { foreach (DtaFile dtaFile in DtaFiles.Distinct()) { dtaFiles.AddRange(dtaFile.Split(spectraToSplit)); } }); t.Start(); await t; } else { dtaFiles = DtaFiles.ToList(); } SetStatusLabel("Uploading Files to " + remoteJobDirectory + "..."); await _connection.PutFilesAsync(dtaFiles.Distinct(), remoteJobDirectory); SetStatusLabel("Uploading Submit File..."); CondorSubmitFile submitFile = new CondorSubmitFile(dtaFiles, userModFile, dataBases); submitFile.WriteToDisk(); await _connection.PutFileAsync(submitFile, remoteJobDirectory, "submitFile.condor"); if (splitSpectra) { foreach (DtaFile dtaFile in dtaFiles) { System.IO.File.Delete(dtaFile.FilePath); } } System.IO.File.Delete(submitFile.FilePath); string result = _connection.RunSubmission(remoteJobDirectory, "submitFile.condor"); SetStatusLabel(result.Replace("\n", " ")); } catch (Exception e) { MessageBox.Show(e.Message, "Error Submitting Job", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); SetStatusLabel("Error"); } finally { dataGridView1.Enabled = true; toolStripStatusLabel1.Text = ""; submitToolStripMenuItem.Enabled = true; UpdateProgress(0); } }