protected override void ImportData() { var msg = string.Empty; if (txtPath.Text.Length == 0) { MsgHelper.MsgWarning("Lokasi dan nama file Excel belum dipilih."); return; } IImportExportDataBll <Supplier> importDataBll = new ImportExportDataSupplierBll(txtPath.Text, _log); if (importDataBll.IsOpened()) { msg = "Maaf file master {0} sedang dibuka, silahkan ditutup terlebih dulu."; MsgHelper.MsgWarning(string.Format(msg, ImportTitle)); return; } if (!importDataBll.IsValidFormat(cmbWorksheet.Text)) { msg = "Maaf format file master {0} tidak valid, proses import tidak bisa dilanjutkan."; MsgHelper.MsgWarning(string.Format(msg, ImportTitle)); return; } if (MsgHelper.MsgKonfirmasi("Apakah proses ingin dilanjutkan ?")) { using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { var rowCount = 0; var result = importDataBll.Import(cmbWorksheet.Text, ref rowCount); if (result) { msg = "Import data master {0} berhasil."; MsgHelper.MsgInfo(string.Format(msg, ImportTitle)); Listener.Ok(this, null); this.Close(); } else { if (rowCount == 0) { msg = "Data file master {0} masih kosong.\n" + "Silahkan diisi terlebih dulu."; MsgHelper.MsgInfo(string.Format(msg, ImportTitle)); } } } } }
protected override void ImportData() { var msg = string.Empty; var fileMaster = Utils.GetAppPath() + @"\File Import Excel\Master Data\data_supplier.xlsx"; IImportExportDataBll _importDataBll = new ImportExportDataSupplierBll(fileMaster, _log); if (_importDataBll.IsOpened()) { msg = "Maaf file master Supplier sedang dibuka, silahkan ditutup terlebih dulu."; MsgHelper.MsgWarning(msg); return; } if (!_importDataBll.IsValidFormat()) { msg = "Maaf format file master Supplier tidak valid, proses import tidak bisa dilanjutkan."; MsgHelper.MsgWarning(msg); return; } if (MsgHelper.MsgKonfirmasi("Apakah proses ingin dilanjutkan ?")) { using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { var rowCount = 0; var result = _importDataBll.Import(ref rowCount); if (result) { msg = "Import data master Supplier berhasil."; MsgHelper.MsgInfo(msg); LoadData(); } else { if (rowCount == 0) { msg = "Data file master Supplier masih kosong.\n" + "Silahkan diisi terlebih dulu."; MsgHelper.MsgInfo(msg); } } } } }
protected override void ExportData() { using (var dlgSave = new SaveFileDialog()) { dlgSave.Filter = "Microsoft Excel files (*.xlsx)|*.xlsx"; dlgSave.Title = "Export Data Supplier"; var result = dlgSave.ShowDialog(); if (result == DialogResult.OK) { using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { IImportExportDataBll <Supplier> _importDataBll = new ImportExportDataSupplierBll(dlgSave.FileName, _log); _importDataBll.Export(_listOfSupplier); } } } }
protected override void BrowseFileExcel() { cmbWorksheet.Items.Clear(); using (var dlgOpen = new OpenFileDialog()) { // Excel file only dlgOpen.Filter = "Microsoft Excel files (*.xlsx)|*.xlsx"; dlgOpen.Title = string.Format("Import data master {0}", ImportTitle); var result = dlgOpen.ShowDialog(); if (result == DialogResult.OK) { txtPath.Text = dlgOpen.FileName; IImportExportDataBll <Supplier> importDataBll = new ImportExportDataSupplierBll(txtPath.Text, _log); if (importDataBll.IsOpened()) { var msg = "Maaf file master {0} sedang dibuka, silahkan ditutup terlebih dulu."; MsgHelper.MsgWarning(string.Format(msg, ImportTitle)); txtPath.Clear(); return; } var listOfWorksheet = importDataBll.GetWorksheets(); if (listOfWorksheet.Count > 0) { foreach (var workSheet in listOfWorksheet) { cmbWorksheet.Items.Add(workSheet); } cmbWorksheet.SelectedIndex = 0; } } } }