Ejemplo n.º 1
0
        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));
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        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);
                        }
                    }
                }
            }
        }