コード例 #1
0
        private void buttonExport_Click(object sender, EventArgs e)
        {
            SaveFileDialog sf = new SaveFileDialog
            {
                Filter = "csv files (*.csv)|*.csv|All files (*.*)|*.*"
            };

            if (sf.ShowDialog() == DialogResult.OK)
            {
                MainView.Instance.LogMainWindow("Exporting inventory...");
                MKMCsvUtils.WriteTableAsCSV(sf.FileName, (DataTable)stockGridView.DataSource);
                MainView.Instance.LogMainWindow("Inventory exported.");
            }
        }
コード例 #2
0
ファイル: PriceExternalList.cs プロジェクト: AGougi/MKMTool
        private void buttonExport_Click(object sender, EventArgs e)
        {
            SaveFileDialog sf = new SaveFileDialog();

            sf.Filter = "csv files (*.csv)|*.csv|All files (*.*)|*.*";
            if (sf.ShowDialog() == DialogResult.OK)
            {
                MainView.Instance.LogMainWindow("Exporting external list...");
                // start with the same columns as there were in import
                DataTable export = new DataTable();
                foreach (DataColumn dc in importedColumns)
                {
                    export.Columns.Add(dc.ColumnName);
                }
                // now add additional columns based on what checkboxes are checked
                if (!checkBoxExportAll.Checked)
                {
                    if (checkBoxExportPriceGuide.Checked)
                    {
                        export.Columns.Add(MCAttribute.PriceGuideAVG);
                        export.Columns.Add(MCAttribute.PriceGuideLOW);
                        export.Columns.Add(MCAttribute.PriceGuideLOWEX);
                        export.Columns.Add(MCAttribute.PriceGuideLOWFOIL);
                        export.Columns.Add(MCAttribute.PriceGuideSELL);
                        export.Columns.Add(MCAttribute.PriceGuideTREND);
                        export.Columns.Add(MCAttribute.PriceGuideTRENDFOIL);
                    }
                    if (checkBoxExportToolPrices.Checked)
                    {
                        export.Columns.Add(MCAttribute.MKMToolPrice);
                        export.Columns.Add(MCAttribute.PriceCheapestSimilar);
                    }
                }
                foreach (MKMMetaCard mc in importedAll)
                {
                    if (checkBoxExportOnlyAppraised.Checked)
                    {
                        // price guides are not generated or the card does not have them or the user does not want them
                        bool priceGuidesSkip = (!checkBoxExportPriceGuide.Checked || !priceGuidesGenerated || !mc.HasPriceGuides);
                        if (toolPriceGenerated)
                        {
                            if ((mc.GetAttribute(MCAttribute.MKMToolPrice) == "" && mc.GetAttribute(MCAttribute.PriceCheapestSimilar) == "") && // toolPrices not present for this card
                                priceGuidesSkip)
                            {
                                continue;
                            }
                        }
                        else if (priceGuidesSkip)
                        {
                            continue;
                        }
                    }
                    mc.WriteItselfIntoTable(export, checkBoxExportAll.Checked,
                                            checkBoxExportFormatDeckbox.Checked ? MCFormat.Deckbox : MCFormat.MKM, false);
                }

                MKMCsvUtils.WriteTableAsCSV(sf.FileName, export);

                MainView.Instance.LogMainWindow("Exporting finished.");
            }
        }