private void LocalizeUI() { Text = string.Format("{0} {1}", GetLocalized("frmText"), ImportManager.ImportName(_ImportFormType)); btnImport.Text = GetLocalized("btnImport"); btnSaveLog.Text = GetLocalized("btnSavelog"); btnClose.Text = GetLocalized("importBtnClose"); }
void import() { bool result = true; string fileName = ""; if (_NeedFileDialog) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.CheckFileExists = true; openFileDialog.InitialDirectory = ""; openFileDialog.RestoreDirectory = true; result = openFileDialog.ShowDialog() == DialogResult.OK; fileName = openFileDialog.FileName; } if (result) { object[] services = null; ImportType importType; try { if (_NeedFileDialog) { importType = ImportManager.FileImportType(fileName); if (_ImportFormType != ImportType.All) { if (importType != _ImportFormType) { ShowMessageError(string.Format(GetLocalized("ImportFileNotContainData"), ImportManager.ImportName(_ImportFormType))); return; } } } else { importType = _ImportFormType; } ImportManager importManager = createImportManager(); switch (importType) { case ImportType.Country: case ImportType.Absence: case ImportType.Feast: case ImportType.WorkingDays: services = new object[] { _CountryService }; break; case ImportType.Region: services = new object[] { _CountryService, _RegionService }; break; case ImportType.Store: services = new object[] { _CountryService, _RegionService, _StoreService }; break; case ImportType.World: case ImportType.HWGR: case ImportType.WGR: case ImportType.ActualBusinessVolume: case ImportType.TargetBusinessVolume: case ImportType.CashRegisterReceipt: services = new object[] { _StoreService }; break; case ImportType.Employee: case ImportType.LongTimeAbsence: case ImportType.TimePlanning: case ImportType.TimeRecording: services = new object[] { _EmployeeService }; break; default: ShowMessage(string.Format(GetLocalized("msgImportTypeNotRealized"), importType.ToString())); break; } if (services != null) { _CanClose = false; enableControls(false); importManager.Import(fileName, importType, services); } } catch (SameColumnsInImportFile) { ShowMessageError(GetLocalized("msgSameColumns")); } catch (UnknownImportFile) { ShowMessageError(GetLocalized("msgImportFileUnknown")); } } }