示例#1
0
        /// <summary>
        /// fetches all course_codes from database if regular student
        /// else it fetches all course_codes only for which exam has held
        /// </summary>
        /// <param name="stype">Regular or non-regular</param>
        /// <returns>course_code string collection</returns>
        public static List <string> getCourseCodes(StudentType stype)
        {
            List <String> ccodes = new List <String>();

            try
            {
                List <Row> rows;
                if (stype == StudentType.REGULAR)
                {
                    rows = Medatabase.fetchRecords("SELECT course_code FROM course_master");
                }
                else
                {
                    rows = Medatabase.fetchRecords("SELECT DISTINCT course_code FROM exam_master");
                }
                foreach (Row row in rows)
                {
                    ccodes.Add((string)row.column["course_code"]);
                }
            }
            catch (databaseException)
            {
                //Do something
            }
            catch (Exception ex)
            {
                //Do something
                LogWriter.WriteError("Fetching course code list from database", ex.Message);
            }
            return(ccodes);
        }
        public MainWindow()
        {
            InitializeComponent();
            Windows.setWindowChrome(this);
            Windows.loginWindow = this;

            MouseDown += login_window_MouseDown;
            try
            {
                Medatabase.OpenConnection();
            }
            catch (databaseException de)
            {
                MessageBox.Show(de.Message, "Connection Failed", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                Environment.Exit(0);
            }

            //SET APP THEME COLOR BASED ON WINDOWS ACCENT COLOR
            Brush LightBrush = (Brush)(new BrushConverter()).ConvertFromString(WindowsTheme.getHexColorFromRegistry());
            Brush DarkBrush  = (Brush)(new BrushConverter()).ConvertFromString(WindowsTheme.getHexDarkColorFromRegistry());

            Application.Current.Resources["ApplicationThemeLight"] = LightBrush;
            Application.Current.Resources["ApplicationThemeDark"]  = DarkBrush;

            //SET SOIS LABLE BACKGROUND
            System.Drawing.Color c        = WindowsTheme.getColorFromRegistry();
            LinearGradientBrush  gradient = new LinearGradientBrush();

            gradient.StartPoint        = new Point(0.5, 0);
            gradient.EndPoint          = new Point(0.5, 1);
            gradient.RelativeTransform = lblBanner.Background.RelativeTransform;
            gradient.GradientStops.Add(new GradientStop(Colors.White, 0));
            gradient.GradientStops.Add(new GradientStop(Color.FromRgb(c.R, c.G, c.B), 1));
            lblBanner.Background = gradient;
        }
示例#3
0
        /// <summary>
        /// Call this function to get subject list
        /// </summary>
        /// <param name="course_code">course code</param>
        /// <returns>SubjectCols collection</returns>
        public static List <SubjectCols> getSubjectList(string course_code)
        {
            List <SubjectCols> items = null;

            try
            {
                List <Row> rows = null;
                items = new List <SubjectCols>();;

                for (int t = 1; t <= Courses.getSemCount(course_code); t++)
                {
                    rows = Medatabase.fetchRecords("SELECT * FROM subject_master WHERE course_code='" + course_code + "' AND semester=" + t);
                    foreach (Row row in rows)
                    {
                        items.Add(new SubjectCols {
                            subject_code = (string)row.column["sub_code"],
                            subject_name = (string)row.column["name"],
                            semNo        = (semNo)row.column["semester"],
                            credits      = (int)row.column["credits"]
                        });
                    }
                }
            }
            catch (databaseException)
            {
                //do something
            }
            catch (Exception ex)
            {
                //do something
                LogWriter.WriteError("While fetching subject list from database", ex.Message);
            }
            return(items);
        }
示例#4
0
        /// <summary>
        /// For filling course data in listview
        /// </summary>
        /// <returns>CourseCols collection</returns>
        public static List <CourseCols> getCourseList()
        {
            List <CourseCols> items = null;

            try
            {
                List <Row> rows = Medatabase.fetchRecords("SELECT * FROM course_master");
                items = new List <CourseCols>();

                foreach (Row row in rows)
                {
                    items.Add(new CourseCols
                    {
                        c_code       = (string)row.column["course_code"],
                        t_semesters  = (int)row.column["total_semesters"],
                        in_semesters = (int)row.column["in_semesters"]
                    });
                }
            }
            catch (databaseException)
            {
                //Do Something
            }
            catch (Exception ex)
            {
                //Do Something
                LogWriter.WriteError("Fetching course list from database", ex.Message);
            }
            return(items);
        }
示例#5
0
        /// <summary>
        /// Returns the number of subject presents in a given course
        /// </summary>
        /// <param name="course_code">course code</param>
        /// <returns>integer</returns>
        public static int getSubjectCount(String course_code)
        {
            int        count = 0;
            List <Row> rows  = Medatabase.fetchRecords("SELECT COUNT(sub_code) AS scount FROM subject_master WHERE course_code='" + course_code + "'");

            if (rows.Count > 0)
            {
                count = Convert.ToInt16(rows[0].column["scount"]);
            }
            return(count);
        }
示例#6
0
        /// <summary>
        /// This method will return the no. of sems(in) in a particular course
        /// </summary>
        /// <param name="course_code">course for which sem count is requested</param>
        /// <returns>Total sems count</returns>
        public static int getInSemCount(string course_code)
        {
            int        scount = 0;
            List <Row> rows   = Medatabase.fetchRecords("SELECT in_semesters FROM course_master WHERE course_code='" + course_code + "'");

            foreach (Row row in rows)
            {
                scount = (int)row.column["in_semesters"];
            }
            return(scount);
        }
示例#7
0
 private void cbxAYear_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (cbxAYear.SelectedIndex != -1)
     {
         List <String> months = new List <String>();
         foreach (Row row in Medatabase.fetchRecords("SELECT DISTINCT month FROM exam_master WHERE course_code='" + (String)cbxACourse.SelectedItem + "' AND semester=" + Convert.ToInt16(cbxASem.SelectedItem)))
         {
             months.Add((String)row.column["month"]);
         }
         cbxAMonth.ItemsSource = months;
     }
 }
示例#8
0
 private void cbxASem_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (cbxASem.SelectedIndex != -1)
     {
         List <int> years = new List <int>();
         foreach (Row row in Medatabase.fetchRecords("SELECT DISTINCT year FROM exam_master WHERE course_code='" + (String)cbxACourse.SelectedItem + "' AND semester=" + Convert.ToInt16(cbxASem.SelectedItem)))
         {
             years.Add(Convert.ToInt16(row.column["year"]));
         }
         cbxAYear.ItemsSource  = years;
         cbxAYear.Text         = "-- YEAR --";
         cbxAMonth.ItemsSource = null;
         cbxAMonth.Text        = "-- MONTH --";
     }
 }
示例#9
0
        /// <summary>
        /// Returns batch years of a course
        /// </summary>
        /// <param name="course_code">course code</param>
        /// <returns>int collection</returns>
        public static List <int> getBatchList(String course_code)
        {
            List <int> list = new List <int>();

            try
            {
                List <Row> rows = Medatabase.fetchRecords("SELECT DISTINCT year FROM student_details WHERE course_code='" + course_code + "'");
                foreach (Row row in rows)
                {
                    list.Add((int)row.column["year"]);
                }
            }
            catch (Exception)
            {
                //Something went wrong
            }
            return(list);
        }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txtUsername.GetLineLength(0) == 0 || txtPassword.Password.Length == 0)
                {
                    MessageBox.Show("Please input all the fields!", "WAIT", MessageBoxButton.OK, MessageBoxImage.Stop);
                    return;
                }

                string     tmp  = null;
                List <Row> rows = Medatabase.fetchRecords("SELECT password FROM admin_login WHERE username='******'");
                foreach (Row row in rows)
                {
                    tmp = (string)row.column["password"];
                }

                if (string.Compare(tmp, txtPassword.Password) != 0 || tmp == null)
                {
                    MessageBox.Show("Invalid username or password!", "Error", MessageBoxButton.OK, MessageBoxImage.Stop);
                    return;
                }
                admin_window obj = new admin_window();
                obj.Show();
                this.Hide();
            }
            catch (databaseException de)
            {
                MessageBox.Show(de.Message, "Error Occured", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Something went wrong :(", "Error Occured", MessageBoxButton.OK, MessageBoxImage.Error);
                LogWriter.WriteError("Login button clicked", ex.Message);
            }
        }
示例#11
0
        /// <summary>
        /// Returns student details list
        /// </summary>
        /// <param name="course_code">Course code</param>
        /// <param name="year">Batch or year</param>
        /// <returns>Studentcols collection</returns>
        public static List <StudentCols> getStudentList(String course_code, int year)
        {
            List <StudentCols> items = new List <StudentCols>();

            try
            {
                List <Row> rows = Medatabase.fetchRecords("SELECT * FROM student_details WHERE course_code='" + course_code + "' AND year=" + year);

                foreach (Row row in rows)
                {
                    items.Add(new StudentCols
                    {
                        s_reg_id = (long)row.column["registration_id"],
                        s_name   = (string)row.column["name"],
                        s_month  = (string)row.column["month"]
                    });
                }
            }
            catch (Exception ex)
            {
                LogWriter.WriteError("fetching student details", ex.Message);
            }
            return(items);
        }
示例#12
0
        private void btnEvaluate_Click(object sender, RoutedEventArgs e)
        {
            bool isAllOk = true;

            //validation
            String error_message = null;

            if (System.IO.File.Exists(txtIMFile.Text) == false)
            {
                error_message = "Please select internal marksheet file" + Environment.NewLine;
            }
            if (System.IO.File.Exists(txtEMFile.Text) == false)
            {
                error_message += "Please select external marksheet file" + Environment.NewLine;
            }
            if (System.IO.File.Exists(txtCutoffFile.Text) == false)
            {
                error_message += "Please select cut off file" + Environment.NewLine;
            }
            if (cbxECourse.SelectedIndex == -1)
            {
                error_message += "Please select course" + Environment.NewLine;
            }
            if (cbxESem.SelectedIndex == -1)
            {
                error_message += "Please select semester" + Environment.NewLine;
            }
            if (cbxEMonth.SelectedIndex == -1)
            {
                error_message += "Please select month" + Environment.NewLine;
            }
            if (cbxEType.SelectedIndex == -1)
            {
                error_message += "Please select student type" + Environment.NewLine;
            }
            if (cbxEYear.SelectedIndex == -1)
            {
                error_message += "Please select year" + Environment.NewLine;
            }

            if (error_message != null)
            {
                isAllOk = false;
                MessageBox.Show("Please correct the following error(s)!" + Environment.NewLine + Environment.NewLine + error_message, "Invalid inputs", MessageBoxButton.OK, MessageBoxImage.Stop);
            }

            if (isAllOk) //Call for validation and evaluation
            {
                //get values from controls
                int    semester = (int)cbxESem.SelectedItem;
                int    year     = Convert.ToInt16(cbxEYear.SelectedItem);
                string course   = (String)cbxECourse.SelectedItem;

                string month = (cbxEMonth.SelectedItem as ComboBoxItem).Content.ToString(); //As the item is comboboxitem

                try
                {
                    List <Row> rows = Medatabase.fetchRecords("SELECT * FROM exam_master WHERE course_code='" + course + "' AND semester=" + semester + " AND year=" + year + " AND month='" + month + "'");

                    if (cbxEType.SelectedIndex == 0) //check if evaluation has already finished for given course, semester and date
                    {
                        if (rows.Count > 0)
                        {
                            MessageBox.Show("Evaluation has been finished already for semester " + semester + " of " + course + " on " + month + " " + year, "Stop", MessageBoxButton.OK, MessageBoxImage.Error);
                            return;
                        }
                    }
                    else //check if evaluation has been done or not for given course, semester and date
                    {
                        if (rows.Count == 0)
                        {
                            MessageBox.Show("No record of evaluation for semester " + semester + " of " + course + " on " + month + " " + year, "No records of exam for given values", MessageBoxButton.OK, MessageBoxImage.Error);
                            return;
                        }
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Something went wrong!");
                    return;
                }

                MessageBox.Show("Your files are going to be validated!", "Evaluator", MessageBoxButton.OK, MessageBoxImage.Information);
                tabControl.IsEnabled = false;
                this.Cursor          = Cursors.Wait;
                txtEvalOutput.Clear();

                StudentType stype = StudentType.REGULAR;
                if (String.Compare("Regular", (cbxEType.SelectedItem as ComboBoxItem).Content.ToString(), true) == 0)
                {
                    stype = StudentType.REGULAR;
                }
                else if (String.Compare("Failed", (cbxEType.SelectedItem as ComboBoxItem).Content.ToString(), true) == 0)
                {
                    stype = StudentType.FAILURE;
                }
                else
                {
                    stype = StudentType.ABSENT;
                }

                (new Evaluator(txtIMFile.Text, txtEMFile.Text, txtCutoffFile.Text)).validateWorksheets(course, semester, year, month, stype);
            }
        }
示例#13
0
        private void bgwValidate_DoWork(object sender, DoWorkEventArgs e)
        {
            //Do the validation here
            DateTime begin = DateTime.Now;

            try
            {
                excelApp = new Application();
                List <String> scodes = new List <string>();
                int           rowCount = 0, columnCount = 0, i, j = 1;

                Workbook  courseWorkbook = excelApp.Workbooks.Open(fileName, 0, true, 5, "", "", true, XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                Worksheet courseWorksheet;
                Range     courseWorksheetRange;
                isValid = true;

                tempProcessLog = ln + "Reading worksheet..." + ln + "Total sheets : " + courseWorkbook.Sheets.Count;

                foreach (Worksheet cws in courseWorkbook.Sheets)
                {
                    if (!Medatabase.isPresentLike("course_master", "course_code", cws.Name))
                    {
                        tempProcessLog += ln + "sheet with name \"" + cws.Name + "\" course code is not present in database";
                        isValid         = false;
                        invalidRows++;
                    }
                    else
                    {
                        tempProcessLog      += ln + "======== reading sheet " + cws.Name + "========" + ln;
                        courseWorksheet      = cws;
                        courseWorksheetRange = courseWorksheet.UsedRange;

                        rowCount    = courseWorksheetRange.Rows.Count;
                        columnCount = courseWorksheetRange.Columns.Count;

                        tempProcessLog += ln + "Rows " + rowCount + " | Columns " + columnCount + ln;

                        if (rowCount <= 1)
                        {
                            tempProcessLog += ln + "in sheet \"" + cws.Name + "\" There are no records to validate...";
                            isValid         = false;
                            continue; //Move to next sheet
                        }

                        if (columnCount > 5 || columnCount < 5)
                        {
                            tempProcessLog += ln + "in sheet \"" + cws.Name + "\" Expecting columns to be 5, " + columnCount + " is present." + ln + "This excelsheet is not meeting the desired format.";
                            isValid         = false;
                            continue; //Move to next sheet
                        }

                        tempProcessLog += ln + "Expecting first row to be column names. " + ln + "reading from 2nd row...";

                        for (i = 2; i <= rowCount; i++)
                        {
                            try
                            {
                                tempProcessLog += ln + ">> Sheet [" + cws.Name + "] > Processing Row: " + i + ln;

                                /** CANT CHECK FOR DUPLICATE AS ELECTIVE LAB CAN HAVE DUPLICATE SUBJECT CODE :( **/

                                //Check for duplicate subject_code in database
                                if (Medatabase.isPresent("subject_master", "sub_code", (string)courseWorksheet.Cells[i, 1].Value))
                                {
                                    tempProcessLog += ln + "duplicate subject_code '" + (string)courseWorksheet.Cells[i, 1].Value + "' already present in database in row " + i;
                                    isValid         = false;
                                    invalidRows++;
                                }

                                //if not a lab subject
                                if (String.Compare((string)courseWorksheet.Cells[i, 5].Value, "Lab", true) != 0)
                                {
                                    //Check for duplicate subject_code in the same excel sheet
                                    if (scodes.IndexOf((string)courseWorksheet.Cells[i, 1].Value) != -1)
                                    {
                                        tempProcessLog += ln + "duplicate subject_code '" + (string)courseWorksheet.Cells[i, 1].Value + "' already present in the same excel sheet in row " + i;
                                        isValid         = false;
                                        invalidRows++;
                                    }
                                    scodes.Add((string)courseWorksheet.Cells[i, 1].Value);
                                }

                                if (courseWorksheet.Cells[i, 1].Value == null)
                                {
                                    tempProcessLog += ln + "Empty value given for subject_code in row " + i;
                                    isValid         = false;
                                    invalidRows++;
                                }

                                if (courseWorksheet.Cells[i, 2].Value == null)
                                {
                                    tempProcessLog += ln + "Empty value given for subject_name in row " + i;
                                    isValid         = false;
                                    invalidRows++;
                                }

                                if ((int)courseWorksheet.Cells[i, 3].Value <= 0 || (int)courseWorksheet.Cells[i, 3].Value > Courses.getSemCount(cws.Name))
                                {
                                    tempProcessLog += ln + "Invalid semester number \"" + (int)courseWorksheet.Cells[i, 3].Value + "\" in row " + i;
                                    isValid         = false;
                                    invalidRows++;
                                }

                                if ((int)courseWorksheet.Cells[i, 4].Value <= 0)
                                {
                                    tempProcessLog += ln + "Subject credits cannot be less than or equal to 0 in row " + i;
                                    isValid         = false;
                                    invalidRows++;
                                }

                                if (courseWorksheet.Cells[i, 5].Value == null)
                                {
                                    tempProcessLog += ln + "Empty value given for subject type in row " + i;
                                    isValid         = false;
                                    invalidRows++;
                                }
                            }
                            catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException be)
                            {
                                invalidRows++;
                                isValid         = false;
                                tempProcessLog += ln + "In row [" + i + "] expecting int value, string given!";
                                LogWriter.WriteError("While validating subject details worksheet", be.Message);
                            }

                            //Update output textbox
                            App.Current.Dispatcher.Invoke(new System.Action(() =>
                            {
                                txtOutput.AppendText(tempProcessLog);
                                txtOutput.ScrollToEnd();
                            }));

                            bgwValidate.ReportProgress(Convert.ToInt16(((i * 100) / rowCount)));
                            tempProcessLog = "";
                        }
                    }
                    bgwValidate.ReportProgress(Convert.ToInt16(((j * 100) / courseWorkbook.Sheets.Count)));
                    j++;
                }
            }
            catch (System.IO.IOException ioe)
            {
                tempProcessLog += ln + "ERROR HANDLING FILE :(" + ln + "Please retry";
                LogWriter.WriteError("While validating subject details worksheet", ioe.Message);
                isValid = false;
                return;
            }
            catch (databaseException)
            {
                tempProcessLog += ln + "ERROR OCCURED IN DATABASE OPERATION :(" + ln + "Please retry.";
                isValid         = false;
                return;
            }
            catch (Exception ex)
            {
                tempProcessLog += ln + "UNEXPECTED ERROR OCCURED :(" + ln + "Please retry.";
                LogWriter.WriteError("While validating subject details worksheet", ex.Message);
                isValid = false;
                return;
            }
            finally
            {
                if (invalidRows > 0)
                {
                    tempProcessLog += ln + ln + "There are total " + invalidRows + " errors.";
                }

                //Update output textbox
                tempProcessLog += ln + "Took " + String.Format("{0:0.00}", (DateTime.Now - begin).TotalSeconds) + " seconds";
                App.Current.Dispatcher.Invoke(new System.Action(() =>
                {
                    txtOutput.AppendText(tempProcessLog);
                    txtOutput.ScrollToEnd();
                    progress.Value = 100;
                }));

                excelApp.Workbooks.Close();
            }
        }
示例#14
0
        private void bgwPush_DoWork(object sender, DoWorkEventArgs e)
        {
            DateTime begin = DateTime.Now;

            try
            {
                int    sheetCount = 0;
                int    rowCount = 0, columnCount = 0, i;
                int    credits = 0, sem = 0;
                string sCode, sName, sType;
                isValid = true;

                excelApp = new Application();
                Workbook courseWorkbook = excelApp.Workbooks.Open(fileName, 0, true, 5, "", "", true, XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                Range    courseWorksheetRange;

                sheetCount      = courseWorkbook.Sheets.Count;
                tempProcessLog  = "Database push operation...";
                tempProcessLog += ln + "Reading worksheet..." + ln + "Total sheets : " + sheetCount;

                foreach (Worksheet cws in courseWorkbook.Sheets)
                {
                    tempProcessLog += ln + ">>> Using Sheet \"" + cws.Name + "\"";

                    courseWorksheetRange = cws.UsedRange;
                    rowCount             = courseWorksheetRange.Rows.Count;
                    columnCount          = courseWorksheetRange.Columns.Count;

                    for (i = 2; i <= rowCount; i++)
                    {
                        sCode   = (string)cws.Cells[i, 1].Value;
                        sName   = (string)cws.Cells[i, 2].Value;
                        sem     = (int)cws.Cells[i, 3].Value;
                        credits = (int)cws.Cells[i, 4].Value;
                        sType   = (string)cws.Cells[i, 5].Value;

                        tempProcessLog += ln + "> Processing Row: " + i + ln;
                        tempProcessLog += ln + "PUSHING > " + sCode + " | " + sName + " | ts " + sem + " | is " + credits;
                        recordsPushed  += Medatabase.ExecuteQuery("INSERT INTO subject_master VALUES('" + cws.Name + "'," + sem + ",'" + sCode + "','" + sName + "'," + credits + ",'" + sType + "')");

                        //Update output textbox
                        App.Current.Dispatcher.Invoke(new System.Action(() =>
                        {
                            txtOutput.AppendText(tempProcessLog);
                            txtOutput.ScrollToEnd();
                        }));

                        bgwPush.ReportProgress(Convert.ToInt16(((i * 100) / rowCount)));
                        tempProcessLog = "";
                    }
                }
            }
            catch (databaseException)
            {
                tempProcessLog += ln + "ERROR OCCURED IN DATABASE OPERATION :(" + ln + "Please retry.";
                isValid         = false;
                return;
            }
            catch (System.IO.IOException ioe)
            {
                tempProcessLog += ln + "ERROR HANDLING FILE :(" + ln + "Please retry";
                LogWriter.WriteError("While pushing subject details to database", ioe.Message);
                isValid = false;
                return;
            }
            catch (Exception ex)
            {
                tempProcessLog += ln + "UNEXPECTED ERROR OCCURED :(" + ln + ex.Message + ln + "Please retry.";
                LogWriter.WriteError("While pushing subject details to database", ex.Message);
                isValid = false;
                return;
            }
            finally
            {
                //Update output textbox
                tempProcessLog += ln + "Took " + String.Format("{0:0.00}", (DateTime.Now - begin).TotalSeconds) + " seconds";
                App.Current.Dispatcher.Invoke(new System.Action(() =>
                {
                    txtOutput.AppendText(tempProcessLog);
                    txtOutput.ScrollToEnd();
                    progress.Value = 100;
                }));

                excelApp.Workbooks.Close();
            }
        }
示例#15
0
        private void bgwValidate_DoWork(object sender, DoWorkEventArgs e)
        {
            //Do the validation here
            DateTime begin = DateTime.Now;

            try
            {
                const int MAX_SEMS = 8;
                int       sheetCount = 0;
                int       rowCount = 0, columnCount = 0, i;
                int       isem = 0, tsem = 0;
                string[]  courseCodes;
                isValid = true;

                excelApp = new Application();
                Workbook  courseWorkbook       = excelApp.Workbooks.Open(fileName, 0, true, 5, "", "", true, XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                Worksheet courseWorksheet      = (Worksheet)courseWorkbook.Sheets.get_Item(1);
                Range     courseWorksheetRange = courseWorksheet.UsedRange;

                sheetCount     = courseWorkbook.Sheets.Count;
                tempProcessLog = ln + "Reading worksheet..." + ln + "Total sheets : " + sheetCount;

                tempProcessLog += ln + "Using Sheet1... ";

                rowCount    = courseWorksheetRange.Rows.Count;
                columnCount = courseWorksheetRange.Columns.Count;
                courseCodes = new string[rowCount];

                tempProcessLog += ln + "Rows " + rowCount + " | Columns " + columnCount + ln;

                if (rowCount <= 1)
                {
                    tempProcessLog += ln + "There are no records to validate...";

                    App.Current.Dispatcher.Invoke(new System.Action(() =>
                    {
                        txtOutput.AppendText(tempProcessLog);
                        txtOutput.ScrollToEnd();
                        progress.Value = 100;
                    }));

                    isValid = false;
                    return;
                }

                if (columnCount > 4 || columnCount < 4)
                {
                    tempProcessLog += ln + "Expecting columns to be 4, " + columnCount + " is present." + ln + "This excelsheet is not meeting the desired format.";

                    App.Current.Dispatcher.Invoke(new System.Action(() =>
                    {
                        txtOutput.AppendText(tempProcessLog);
                        txtOutput.ScrollToEnd();
                        progress.Value = 100;
                    }));

                    isValid = false;
                    return;
                }

                tempProcessLog += ln + "Expecting first row to be column names. " + ln + "reading from 2nd row...";

                List <String> tmpCourseCodes = new List <string>();

                for (i = 2; i <= rowCount; i++)
                {
                    try
                    {
                        tempProcessLog += ln + "> Processing Row: " + i + ln;

                        if (courseWorksheet.Cells[i, 1].Value != null)
                        {
                            //Check for duplicate course_code in database
                            if (Medatabase.isPresentLike("course_master", "course_code", (string)courseWorksheet.Cells[i, 1].Value))
                            {
                                tempProcessLog += ln + "duplicate course_code '" + (string)courseWorksheet.Cells[i, 1].Value + "' already present in database...";
                                isValid         = false;
                                invalidRows++;
                            }

                            //Check for duplicate course_code in the same excel sheet
                            if (tmpCourseCodes.IndexOf((string)courseWorksheet.Cells[i, 1].Value) != -1)
                            {
                                tempProcessLog += ln + "duplicate course_code '" + (string)courseWorksheet.Cells[i, 1].Value + "' already present in the same excel sheet...";
                                isValid         = false;
                                invalidRows++;
                            }
                            else //if not duplicate
                            {
                                tmpCourseCodes.Add((string)courseWorksheet.Cells[i, 1].Value);
                            }
                        }
                        else
                        {
                            tempProcessLog += ln + "empty course_code given...'" + ln;
                            isValid         = false;
                            invalidRows++;
                        }

                        if (courseWorksheet.Cells[i, 2].Value != null)
                        {
                            tsem = Convert.ToInt16(courseWorksheet.Cells[i, 2].Value);
                            if (tsem > MAX_SEMS || tsem < 0)
                            {
                                tempProcessLog += ln + (string)courseWorksheet.Cells[i, 1].Value + " > total semesters must be between 0 and " + MAX_SEMS + ", " + tsem + " given";
                                isValid         = false;
                                invalidRows++;
                            }
                        }
                        else
                        {
                            tempProcessLog += ln + "empty value given for total semesters...'" + ln;
                            isValid         = false;
                            invalidRows++;
                        }

                        if (courseWorksheet.Cells[i, 3].Value != null)
                        {
                            isem = Convert.ToInt16(courseWorksheet.Cells[i, 3].Value);
                            if (isem < 1)
                            {
                                tempProcessLog += ln + (string)courseWorksheet.Cells[i, 1].Value + " > in semesters must be between 0 and " + MAX_SEMS + ", " + isem + " given";
                                isValid         = false;
                                invalidRows++;
                            }

                            if (isem > tsem)
                            {
                                tempProcessLog += ln + (string)courseWorksheet.Cells[i, 1].Value + " > in semesters can't be > than total sems, " + isem + " given";
                                isValid         = false;
                                invalidRows++;
                            }

                            if (isem > MAX_SEMS)
                            {
                                tempProcessLog += ln + (string)courseWorksheet.Cells[i, 1].Value + " > max in semesters possible is " + MAX_SEMS + ", " + isem + " given";
                                isValid         = false;
                                invalidRows++;
                            }
                        }
                        else
                        {
                            tempProcessLog += ln + "empty value given for in semesters...'" + ln;
                            isValid         = false;
                            invalidRows++;
                        }
                        if (courseWorksheet.Cells[i, 4].Value != null)
                        {
                            if ((int)courseWorksheet.Cells[i, 4].Value < 1)
                            {
                                tempProcessLog += ln + "credits must be greater than 0";
                                isValid         = false;
                                invalidRows++;
                            }
                        }
                        else
                        {
                            tempProcessLog += ln + "empty value given for total credits...'" + ln;
                            isValid         = false;
                            invalidRows++;
                        }
                    }
                    catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException be)
                    {
                        invalidRows++;
                        isValid         = false;
                        tempProcessLog += ln + "In row [" + i + "] expecting numeric value, string given!";
                        LogWriter.WriteError("During course excel sheet validation", be.Message);
                    }

                    //Update output textbox
                    App.Current.Dispatcher.Invoke(new System.Action(() =>
                    {
                        txtOutput.AppendText(tempProcessLog);
                        txtOutput.ScrollToEnd();
                    }));

                    bgwValidate.ReportProgress(Convert.ToInt16(((i * 100) / rowCount)));
                    tempProcessLog = "";
                }
            }
            catch (System.IO.IOException ioe)
            {
                tempProcessLog += ln + "ERROR HANDLING FILE :(" + ln + "Please retry";
                LogWriter.WriteError("During course excel sheet validation", ioe.Message);
                isValid = false;
                return;
            }
            catch (databaseException)
            {
                tempProcessLog += ln + "ERROR OCCURED IN DATABASE OPERATION :(" + ln + "Please retry.";
                isValid         = false;
                return;
            }
            catch (Exception ex)
            {
                tempProcessLog += ln + "UNEXPECTED ERROR OCCURED :(" + ln + "Please retry.";
                LogWriter.WriteError("During course excel sheet validation", ex.Message);
                isValid = false;
                return;
            }
            finally
            {
                if (invalidRows > 0)
                {
                    tempProcessLog += ln + "There are total " + invalidRows + " errors.";
                    tempProcessLog += ln + "Took " + String.Format("{0:0.00}", (DateTime.Now - begin).TotalSeconds) + " seconds";
                    App.Current.Dispatcher.Invoke(new System.Action(() =>
                    {
                        txtOutput.AppendText(tempProcessLog);
                        txtOutput.ScrollToEnd();
                        progress.Value = 100;
                    }));
                }
                excelApp.Workbooks.Close();
            }
        }