Esempio n. 1
0
 static void Main(string[] args)
 {
     Console.WriteLine($"Bookmanag Inciado às {Now.ToShortDateString()}");
     while (!done)
     {
         ShowMenu();
     }
 }
Esempio n. 2
0
 static void Main(string[] args)
 {
     WriteLine($"BookManager Iniciados às {Now.ToShortDateString()}");
     while (true)
     {
         ShowMenu();
     }
 }
 public static void PrintDate() => WriteLine(Now.ToShortDateString());
Esempio n. 4
0
 public static void Main()
 {
     WriteLine(Now.ToShortDateString());
     WriteLine(Now.ToLongTimeString());
 }
Esempio n. 5
0
        /// <summary>
        /// Create excel file
        /// </summary>
        /// <param name="scores">List of calculated scores</param>
        /// <param name="input">Input string</param>
        /// <param name="old">Time from when the Button was clicked</param>
        /// <param name="setChart">Display or hide chart</param>
        static void exportToExcel(List <int> scores, string input, DateTime old, bool setChart = false)
        {
            var myApp = new Microsoft.Office.Interop.Excel.Application();

            if (myApp == null)
            {
                return;
            }

            Workbook  wb;
            Worksheet ws;

            object misValue = System.Reflection.Missing.Value;

            wb = myApp.Workbooks.Add(misValue);
            ws = wb.Worksheets.get_Item(1);

            for (int i = 1; i <= scores.Count; i++)
            {
                ws.Cells[1, i] = "[" + (i + 3).ToString() + "]";
                ws.Cells[2, i] = input[i + 2].ToString();
                ws.Cells[3, i] = scores[i - 1].ToString();
            }

            if (setChart)
            {
                addChart(ws, scores, XlChartType.xlColumnStacked);
            }

            DateTime now          = Now;
            string   fileNameTime = now.Hour.ToString() + "-" + now.Minute.ToString() + "-" + now.Second.ToString();

            // Add scores folder if it doesnt exist yet:
            var path = GetCurrentDirectory();

            if (!Exists(path + @"\Scores"))
            {
                CreateDirectory((path + @"\Scores"));
            }

            // Save excel file into Scores folder:
            path = path + @"\Scores" + @"\" + Now.ToShortDateString() + "; " + fileNameTime + ".xlsx";
            wb.SaveAs(path, XlFileFormat.xlOpenXMLWorkbook,
                      misValue, misValue, misValue, misValue,
                      XlSaveAsAccessMode.xlExclusive,
                      misValue, misValue, misValue, misValue, misValue);
            wb.Close(true, misValue, misValue);
            myApp.Quit();

            // Release the file:
            ReleaseComObject(ws);
            ReleaseComObject(wb);
            ReleaseComObject(myApp);

            // Show time the program took to finish:
            MessageBox.Show("Excel Datei wurde in " +
                            string.Format("{0:0.##}", (Now - old).TotalSeconds) +
                            " Sekunden erfolgreich erstellt.");

            // Open the folder which contains the files:
            System.Diagnostics.Process.Start(GetCurrentDirectory() + @"\Scores");
        }