protected override void ImportData() { var msg = string.Empty; if (txtPath.Text.Length == 0) { MsgHelper.MsgWarning("Lokasi dan nama file Excel belum dipilih."); return; } IImportExportDataBll <Customer> importDataBll = new ImportExportDataCustomerBll(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_customer.xlsx"; IImportExportDataBll _importDataBll = new ImportExportDataCustomerBll(fileMaster, _log); if (_importDataBll.IsOpened()) { msg = "Maaf file master Customer sedang dibuka, silahkan ditutup terlebih dulu."; MsgHelper.MsgWarning(msg); return; } if (!_importDataBll.IsValidFormat()) { msg = "Maaf format file master Customer 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 Customer berhasil."; MsgHelper.MsgInfo(msg); LoadData(); } else { if (rowCount == 0) { msg = "Data file master Customer masih kosong.\n" + "Silahkan diisi terlebih dulu."; MsgHelper.MsgInfo(msg); } } } } }
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 <Customer> importDataBll = new ImportExportDataCustomerBll(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; } } } }