private void ImportData() { if (Company_Info.DataPath != null) { if (Directory.Exists(Company_Info.DataPath)) { ofdAttachment.InitialDirectory = Company_Info.DataPath; } } ofdAttachment.FileName = ""; ofdAttachment.Filter = "txt files (*.txt)|*.txt|csv files (*.csv)|*.csv|dat files (*.dat)|*.dat|all files (*.*)|*.*"; ofdAttachment.FilterIndex = 0; ofdAttachment.RestoreDirectory = true; DialogResult result = ofdAttachment.ShowDialog(); if (result == DialogResult.OK) // Test result. { ExternalDataManager externalDataManager = new ExternalDataManager(); if (radFixedSizeImport.Checked) { externalDataManager.ImportInboxHaklada(ofdAttachment.FileName, Company_Info, dblayer); } else { string delimiter = ""; if (radTabImport.Checked) { delimiter = "\t"; } if (radPipeImport.Checked) { delimiter = "|"; } if (radCommaImport.Checked) { delimiter = ","; } if (radOtherImport.Checked) { delimiter = txtDelimiterImport.Text; } //is space can be a delimiter? externalDataManager.ImportInboxHaklada(ofdAttachment.FileName, Company_Info, dblayer, delimiter); } dblayer.ReadShuratHakladaInboxList(lvwOutbox, Company_Info.CompanyCountryID.ToString(), Company_Info.CompanyVAT, ActionsListDictionary); CleanForm(); companyIDComboBox.Focus(); } grpImport.Visible = false; }
private void btnSelectionImport_Click(object sender, EventArgs e) { try { if (Company_Info.DataPath != null) { if (Directory.Exists(Company_Info.DataPath)) { ofdAttachment.InitialDirectory = Company_Info.DataPath; } } ofdAttachment.FileName = ""; ofdAttachment.Filter = "txt files (*.txt)|*.txt|csv files (*.csv)|*.csv|dat files (*.dat)|*.dat|all files (*.*)|*.*"; ofdAttachment.FilterIndex = 0; ofdAttachment.RestoreDirectory = true; DialogResult result = ofdAttachment.ShowDialog(); if (result == DialogResult.OK) // Test result. { ExternalDataManager externalDataManager = new ExternalDataManager(); if (radFixedSizeImport.Checked) { externalDataManager.ImportCompanies(ofdAttachment.FileName, Company_Info, dblayer); } else { string delimiter = ""; if (radTabImport.Checked) { delimiter = "\t"; } if (radPipeImport.Checked) { delimiter = "|"; } if (radCommaImport.Checked) { delimiter = ","; } if (radOtherImport.Checked) { delimiter = txtDelimiterImport.Text; } //is space can be a delimiter? externalDataManager.ImportCompanies(ofdAttachment.FileName, Company_Info, dblayer, delimiter); } dblayer.ReadBusinessList(lvwBusinessList, "", Company_Info); } } catch (Exception ex) { MessageBox.Show("File structure error!" + Environment.NewLine + "OR" + Environment.NewLine + "Directory not decleared!", "Import Buisness", MessageBoxButtons.OK, MessageBoxIcon.Stop); } grpImport.Visible = false; }