Пример #1
0
        //CS6326Asg3 file created
        public bool writeData(string fileName, GetterSetterClass dataInstance)
        {
            try
            {
                //if fileexists then delete and proceed
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }

                using (StreamWriter writer = new StreamWriter(fileName))
                {
                    string output = "The Number of records : " + data.totalRecords + "\n"
                                    + "\n Minimum Entry Time: " + data.entryTimeMin.ToString(@"mm\:ss") + "\n"
                                    + "\n Maximum Entry Time: " + data.entryTimeMax.ToString(@"mm\:ss") + "\n"
                                    + "\n Average Entry Time: " + data.entryTimeAvg.ToString(@"mm\:ss") + "\n"
                                    + "\n Minimum Between Time: " + data.betweenTimeMin.ToString(@"mm\:ss") + "\n"
                                    + "\n Maximum Between Time: " + data.betweenTimeMax.ToString(@"mm\:ss") + "\n"
                                    + "\n Average Between Time: " + data.betweenTimeAvg.ToString(@"mm\:ss") + "\n"
                                    + "\n Total Time: " + data.timeTotal.ToString(@"mm\:ss") + "\n"
                                    + "\n Total backspaces Count: " + data.backSpaceCount + "\n";

                    writer.Write(output);
                }



                return(true);
            }
            catch
            {
                return(false);
            }
        }
        //evaluate button click
        private void button1_Click(object sender, EventArgs e)
        {
            //evaluate btn
            if (filePathBox.Text == "")
            {
                MessageBox.Show("Please Select File and Proceed");
            }
            else
            {
                //evaluate data andwrite it into the data
                GetterSetterClass data = dataOperate.evaluateFile(filePath);
                bool isWritten         = false;
                isWritten = dataOperate.writeFile("CS6326Asg3.txt", data);
                if (isWritten)
                {
                    string output = "The Number of records : " + data.totalRecords + "\n"
                                    + "\n Minimum Entry Time: " + data.entryTimeMin.ToString(@"mm\:ss") + "\n"
                                    + "\n Maximum Entry Time: " + data.entryTimeMax.ToString(@"mm\:ss") + "\n"
                                    + "\n Average Entry Time: " + data.entryTimeAvg.ToString(@"mm\:ss") + "\n"
                                    + "\n Minimum Between Time: " + data.betweenTimeMin.ToString(@"mm\:ss") + "\n"
                                    + "\n Maximum Between Time: " + data.betweenTimeMax.ToString(@"mm\:ss") + "\n"
                                    + "\n Average Between Time: " + data.betweenTimeAvg.ToString(@"mm\:ss") + "\n"
                                    + "\n Total Time: " + data.timeTotal.ToString(@"mm\:ss") + "\n"
                                    + "\n Total backspaces Count: " + data.backSpaceCount + "\n";

                    evaluationBox.Text     = output;
                    messageLabel.Text      = "data Evaluated successfully!";
                    messageLabel.ForeColor = Color.Green;
                }
                else
                {
                    messageLabel.Text      = "Error writing data into File. Try again";
                    messageLabel.ForeColor = Color.Red;
                }
            }
        }
Пример #3
0
 public bool writeFile(String fname, GetterSetterClass dataInstance)
 {
     return(data.writeData(fname, dataInstance));
 }