public PrintDataForm(DataCentreClass importeddata)
        {
            data = importeddata;
            var file = File.AppendText("~Optical Measurements.txt");

            file.WriteLine("Digital Projection Optical Performance Report");
            file.WriteLine();
            file.WriteLine();

            file.WriteLine($"Date/Time:              {data.date} {data.time} ");
            file.WriteLine($"Name:                   {data.name}");
            file.WriteLine($"Projector ID:           {data.projectorID}");
            file.WriteLine($"Lamp Type:              {data.lampType} ");
            file.WriteLine();

            file.WriteLine($"Format:                 {data.resolution}");
            file.WriteLine($"Area:                   {data.area.ToString("F2")} m" + "\x00B2");


            file.WriteLine();

            file.WriteLine($"ANSI Lumens:            {data.ansiLumens.ToString("#")} Lumens ");
            file.WriteLine($"ANSI Uniformity:        {data.ansiUniformity.ToString("#")}%");
            file.WriteLine($"DP Uniformity:          {data.dpUniformity.ToString("#")}%");
            file.WriteLine($"Full Screen Contrast:   {data.fullScreenContrast.ToString("#")}:1");

            file.WriteLine();

            file.WriteLine($"Centre Lumens:          {data.centreLumens.ToString("#")} Lumens");
            file.WriteLine($"Centre Contrast:        {data.centreContrast.ToString("#")}:1");

            file.Close();
        }
        public static bool saveData(DataCentreClass data)
        {
            string userID   = "userid";
            string password = "******";
            string server   = @"UKMANNB017\SQLEXPRESS";
            string database = "Projector Optical Measurements";
            string timeout  = "30";
            bool   success  = false;

            SqlConnection connection = new SqlConnection($"user id={userID}; password={password}; server={server};"
                                                         + $"Trusted_Connection=Yes; database={database}; connection timeout={timeout}");

            try
            {
                connection.Open();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            SqlCommand mycommand = new SqlCommand();


            mycommand.Connection  = connection;
            mycommand.CommandText = "INSERT INTO [Light Data]([Date],[Projector ID],[Operator ID],[Lamp ID],[Resolution], " +
                                    "[ANSI Lumens],[ANSI Uniformity], [DP Uniformity], [Full Screen Contrast], [Centre Lumens], [Centre Contrast], " +
                                    "[White Sensor01], [White Sensor02],[White Sensor03], [White Sensor04], [White Sensor05],[White Sensor06], " +
                                    "[White Sensor07], [White Sensor08], [White Sensor09], [White Sensor10], [White Sensor11], [White Sensor12], " +
                                    "[White Sensor13], [Black Sensor01], [Black Sensor02], [Black Sensor03], [Black Sensor04], [Black Sensor05], [Black Sensor06], " +
                                    "[Black Sensor07],[Black Sensor08], [Black Sensor09], [Dark Sensor01], [Dark Sensor02], [Dark Sensor03], [Dark Sensor04], " +
                                    "[Dark Sensor05], [Dark Sensor06], [Dark Sensor07], [Dark Sensor08], [Dark Sensor09]) " +
                                    $"VALUES ('{data.date}', '{data.projectorID}', '{data.name}', '{data.lampType}', '{data.resolution}', {data.ansiLumens}, " +
                                    $"{data.ansiUniformity}, {data.dpUniformity}, {data.fullScreenContrast}, {data.centreLumens}, {data.centreContrast}, " +
                                    $"{Math.Round(data.whiteNinePoint[0], 2)}, {Math.Round(data.whiteNinePoint[1], 2)}, {Math.Round(data.whiteNinePoint[2], 2)}, " +
                                    $"{Math.Round(data.whiteNinePoint[3], 2)}, {Math.Round(data.whiteNinePoint[4], 2)}, {Math.Round(data.whiteNinePoint[5], 2)}, " +
                                    $"{Math.Round(data.whiteNinePoint[6], 2)}, {Math.Round(data.whiteNinePoint[7], 2)}, {Math.Round(data.whiteNinePoint[8], 2)}, " +
                                    $"{Math.Round(data.whiteCorners[0], 2)}, {Math.Round(data.whiteCorners[1], 2)}, {Math.Round(data.whiteCorners[2], 2)}, " +
                                    $"{Math.Round(data.whiteCorners[3], 2)}, {Math.Round(data.blackNinePoint[0], 2)}, {Math.Round(data.blackNinePoint[1], 2)}, " +
                                    $"{Math.Round(data.blackNinePoint[2], 2)}, {Math.Round(data.blackNinePoint[3], 2)}, {Math.Round(data.blackNinePoint[4], 2)}, " +
                                    $"{Math.Round(data.blackNinePoint[5], 2)}, {Math.Round(data.blackNinePoint[6], 2)}, {Math.Round(data.blackNinePoint[7], 2)}, " +
                                    $"{Math.Round(data.blackNinePoint[8], 2)}, {Math.Round(data.darkNinePoint[0], 2)}, {Math.Round(data.darkNinePoint[1], 2)}, " +
                                    $"{Math.Round(data.darkNinePoint[2], 2)}, {Math.Round(data.darkNinePoint[3], 2)}, {Math.Round(data.darkNinePoint[4], 2)}, " +
                                    $"{Math.Round(data.darkNinePoint[5], 2)}, {Math.Round(data.darkNinePoint[6], 2)}, {Math.Round(data.darkNinePoint[7], 2)}, " +
                                    $"{Math.Round(data.darkNinePoint[8], 2)})";


            mycommand.ExecuteNonQuery();


            connection.Close();
            return(success);
        }
        public static void SaveData(DataCentreClass importdata)
        {
            string currentYear  = DateTime.Now.Year.ToString();
            string currentMonth = DateTime.Now.ToString("MMM");
            string data         = $"{DateTime.Now.ToShortDateString()},{importdata.name},{importdata.projectorID},{importdata.lampType},{importdata.resolution},{importdata.ansiLumens.ToString("#")},{importdata.ansiUniformity.ToString("#00")},{importdata.dpUniformity.ToString("#00")},{importdata.fullScreenContrast.ToString("#")},{importdata.centreLumens.ToString("#")},{importdata.centreContrast.ToString("#")},{Environment.NewLine}";
            string extraData    = $"{DateTime.Now.ToShortDateString()},{importdata.name},{importdata.projectorID},{importdata.lampType},{importdata.whiteNinePoint[0]},{importdata.whiteNinePoint[1]},{importdata.whiteNinePoint[2]},{importdata.whiteNinePoint[3]},{importdata.whiteNinePoint[4]},{importdata.whiteNinePoint[5]},{importdata.whiteNinePoint[6]},{importdata.whiteNinePoint[7]},{importdata.whiteNinePoint[8]},{importdata.whiteCorners[0]},{importdata.whiteCorners[1]},{importdata.whiteCorners[2]},{importdata.whiteCorners[3]},{importdata.blackNinePoint[0]},{importdata.blackNinePoint[1]},{importdata.blackNinePoint[2]},{importdata.blackNinePoint[3]},{importdata.blackNinePoint[4]},{importdata.blackNinePoint[5]},{importdata.blackNinePoint[6]},{importdata.blackNinePoint[7]},{importdata.blackNinePoint[8]},{importdata.darkNinePoint[0]},{importdata.darkNinePoint[1]},{importdata.darkNinePoint[2]},{importdata.darkNinePoint[3]},{importdata.darkNinePoint[4]},{importdata.darkNinePoint[5]},{importdata.darkNinePoint[6]},{importdata.darkNinePoint[7]},{importdata.darkNinePoint[8]},{Environment.NewLine}";

            string directory = importdata.CSVpath + $@"\{currentYear}\{currentMonth}";

            Directory.CreateDirectory(directory);
            Console.WriteLine(directory);
            string LumensDataPath = directory + @"\LumensData.csv";
            string ExtraDataPath  = directory + @"\ExtraData.csv";


            Console.WriteLine("data" + data);



            if (!File.Exists(LumensDataPath))
            {
                string DefaultData = "Date,Name,Projector Serial Number,LampType,Resolution,ANSI Lumens,ANSI Uniformity,DP Uniformity,Full Screen Contrast,Centre Lumens,Centre Contrast,\n";

                File.WriteAllText(LumensDataPath, DefaultData);
            }

            File.AppendAllText(LumensDataPath, data);


            if (!File.Exists(ExtraDataPath))
            {
                string DefaultExtra = "Date,Name,Projector Serial Number,Lamp Type,WhiteSensor01,WhiteSensor02,WhiteSensor03,WhiteSensor04,WhiteSensor05,WhiteSensor06,WhiteSensor07,WhiteSensor08,WhiteSensor09,WhiteSensor10(TL),WhiteSensor11(TR),WhiteSensor12(BL),WhiteSensor13(BR),BlackSensor01,BlackSensor02,BlackSensor03,BlackSensor04,BlackSensor05,BlackSensor06,BlackSensor07,BlackSensor08,BlackSensor09,DarkSensor01,DarkSensor02,DarkSensor03,DarkSensor04,DarkSensor05,DarkSensor06,DarkSensor07,DarkSensor08,DarkSensor09," + Environment.NewLine;
                File.WriteAllText(ExtraDataPath, DefaultExtra);
            }

            File.AppendAllText(ExtraDataPath, extraData);
        }
 public PrintForm(DataCentreClass data)
 {
     InitializeComponent();
     currentdata = data;
 }