private void barButtonItem27_ItemClick(object sender, ItemClickEventArgs e) { var select = new frmSubmitText("Serial Number search", "Serial Number Search:\r\nPlease enter serial number"); select.ShowDialog(); if (select.Selection == "***") { return; } try { var row = Database.Row("enrollmentcomponents a, enrollments b, learner_details c, components d, division e", "a.idEnrollments = b.idEnrollments AND b.LearnerKey = c.LearnerKey and serialNumber = '" + select.Selection + "' AND a.idCourseComponents = d.idCourseComponents AND e.DivisionAbrev = division"); MessageBox.Show("Serial number is booked out for " + Convert.ToString(row["Name1"]) + "\r\nCollege: " + Convert.ToString(row["division"]) + "\r\nLearner Number: " + Convert.ToString(row["LearnerNumber"]) + "\r\nPlease Contact " + Convert.ToString(row["Tel"]), "Serial Number"); } catch { MessageBox.Show("Serial number not in database", "Serial Number Not Found"); return; } select.Dispose(); }
private void listView3_DoubleClick(object sender, EventArgs e) { var splitter = clsFunctions.SplitByString(listView1.SelectedItems[0].SubItems[1].Text, "-"); try { if (headOfficeCheck.Checked == false && Database.Retrieve("enrollmentcomponents", "idEnrollments = '" + splitter[1] + "' AND idCourseComponents = '" + listView2.SelectedItems[0].Text + "'", "moderated") == "yes") return; } catch { }; var select = new frmSubmitText("Learner Marks", "Enter Learner Mark:"); select.ShowDialog(); if (select.Selection == "***") { select.Close(); return; } try { while (!clsFunctions.IsNumeric(select.Selection)) { MessageBox.Show("Please enter valid score."); if (select.Selection == "***") return; select.ShowDialog(); } while (!clsFunctions.IsNumeric(select.Selection) || Convert.ToDouble(select.Selection) > Convert.ToDouble(listView3.FocusedItem.SubItems[2].Text)) { MessageBox.Show("Please enter valid score."); select.ShowDialog(); } } catch { MessageBox.Show("Error in input format. Please try again."); return; } var mark = select.Selection; select.Close(); select.Dispose(); if (listView3.FocusedItem.SubItems[7].Text == "FASS") { //mark = Convert.ToString(Math.Round(Convert.ToDouble(mark), MidpointRounding.AwayFromZero)); try { if ( Convert.ToDouble(Database.Retrieve("results", "idEnrollments = '" + splitter[1] + "' and idCourseComponents = '" + listView3.SelectedItems[0].Text + "'", "attempt")) >= 3) { if (MessageBox.Show("Number of attempts exceeds 3. Do you want to enter a correction?", "Too Many Attempts",MessageBoxButtons.YesNo,MessageBoxIcon.Question) == DialogResult.No) return; } } catch (Exception) {} var date = new frmSubmitDate("Date", "Please select date for this attempt:"); date.ShowDialog(); if (date.Selection.ToString("dd/MM/yyyy") == "01/01/0001") { MessageBox.Show("Process Aborted"); return; } try { if (Convert.ToDouble(Database.Retrieve("results", "idEnrollments = '" + splitter[1] + "' and idCourseComponents = '" + listView3.SelectedItems[0].Text +"'","attempt")) > 0 && MessageBox.Show("Is this a correction of an old mark?", "Attempt or Correction", MessageBoxButtons.YesNo) == DialogResult.No) { Database.Command("UPDATE results SET result = '" + mark + "', attempt = attempt + 1, capturedDate = '" + date.Selection.ToString("yyyyMMdd") + "', date = '" + DateTime.Now.ToString("yyyyMMdd") + "', serialNumber = '" + textBox2.Text + "' WHERE idEnrollments = '" + splitter[1] + "' and idCourseComponents = '" + listView3.SelectedItems[0].Text + "'"); } else { Database.Command("UPDATE results SET result = '" + mark + "', capturedDate = '" + date.Selection.ToString("yyyyMMdd") + "', date = '" + DateTime.Now.ToString("yyyyMMdd") + "', serialNumber = '" + textBox2.Text + "' WHERE idEnrollments = '" + splitter[1] + "' and idCourseComponents = '" + listView3.SelectedItems[0].Text + "'"); } //var update = Database.Query("results", // "idEnrollments = '" + splitter[1] + "' and idCourseComponents = '" + // listView3.SelectedItems[0].Text + "'"); //update.Tables[0].Rows[0]["result"] = mark; //update.Tables[0].Rows[0]["attempt"] = Convert.ToString(Convert.ToDouble(Database.Retrieve("results", // "idEnrollments = '" + // splitter[1] + // "' and idCourseComponents = '" + // listView3. // SelectedItems // [0]. // Text + // "'", // "attempt")) + // 1); //update.Tables[0].Rows[0]["date"] = date.Selection; //update.Tables[0].Rows[0]["serialNo"] = textBox2.Text; //Database.Update(update, "results", // "idEnrollments = '" + splitter[1] + "' and idCourseComponents = '" + // listView3.SelectedItems[0].Text + "'"); } catch { string[] columns = { "idEnrollments", "idCourseComponents", "Result", "Attempt", "capturedDate","Date", "serialNumber" }; try { string[] values = { splitter[1], listView3.SelectedItems[0].Text, mark, Convert.ToString(Convert.ToDouble(Database.Retrieve("results", "idEnrollments = '" + splitter[1] + "' and idCourseComponents = '" + listView3. SelectedItems [0]. Text + "'", "attempt")) + 1), date.Selection.ToString("yyyyMMdd"), DateTime.Now.ToString("yyyyMMdd"), textBox2.Text }; Database.Insert("results", columns, values); } catch { string[] values = { splitter[1], listView3.SelectedItems[0].Text, mark, "1", date.Selection.ToString("yyyyMMdd"), DateTime.Now.ToString("yyyyMMdd"), textBox2.Text }; Database.Insert("results", columns, values); } } listView3.FocusedItem.SubItems[3].Text = mark; listView3.FocusedItem.SubItems[5].Text = Convert.ToString(Convert.ToDouble(Database.Retrieve("results", "idEnrollments = '" + splitter[1] + "' and idCourseComponents = '" + listView3. SelectedItems [0]. Text + "'", "attempt"))) ; listView3.FocusedItem.SubItems[6].Text = date.Selection.ToString("dd/MM/yyyy"); if (System.Text.RegularExpressions.Regex.IsMatch(listView3.FocusedItem.SubItems[1].Text, ".*Theory.*")) { if (Math.Round(Convert.ToDouble(listView3.FocusedItem.SubItems[3].Text) / Convert.ToDouble(listView3.FocusedItem.SubItems[2].Text) * 100) >= 60) { listView3.FocusedItem.SubItems[4].Text = "3 - Requirements have been met"; listView3.FocusedItem.ForeColor = Color.Blue; } else if (Math.Round(Convert.ToDouble(listView3.FocusedItem.SubItems[3].Text) / Convert.ToDouble(listView3.FocusedItem.SubItems[2].Text) * 100) <= 59) { listView3.FocusedItem.SubItems[4].Text = "2 - Some requirements have been met"; listView3.FocusedItem.ForeColor = Color.Red; } else if (Math.Round(Convert.ToDouble(listView3.FocusedItem.SubItems[3].Text) / Convert.ToDouble(listView3.FocusedItem.SubItems[2].Text) * 100) <= 49) { listView3.FocusedItem.SubItems[4].Text = "1 - Requirements have not been met"; listView3.FocusedItem.ForeColor = Color.Red; } } else if (System.Text.RegularExpressions.Regex.IsMatch(listView3.FocusedItem.SubItems[1].Text, ".*Skills.*")) { if (Math.Round(Convert.ToDouble(listView3.FocusedItem.SubItems[3].Text) / Convert.ToDouble(listView3.FocusedItem.SubItems[2].Text) * 100) >= 85) { listView3.FocusedItem.SubItems[4].Text = "3 - Requirements have been met"; listView3.FocusedItem.ForeColor = Color.Blue; } else if (Math.Round(Convert.ToDouble(listView3.FocusedItem.SubItems[3].Text) / Convert.ToDouble(listView3.FocusedItem.SubItems[2].Text) * 100) <= 84) { listView3.FocusedItem.SubItems[4].Text = "2 - Some requirements have been met"; listView3.FocusedItem.ForeColor = Color.Red; } else if (Math.Round(Convert.ToDouble(listView3.FocusedItem.SubItems[3].Text) / Convert.ToDouble(listView3.FocusedItem.SubItems[2].Text) * 100) <= 59) { listView3.FocusedItem.SubItems[4].Text = "1 - Requirements have not been met"; listView3.FocusedItem.ForeColor = Color.Red; } } date.Dispose(); if (listView3.FocusedItem.Index < listView3.Items.Count - 1) { listView3.Items[listView3.FocusedItem.Index + 1].Selected = true; listView3.Items[listView3.FocusedItem.Index + 1].Focused = true; } var requirements = true; foreach (ListViewItem theItem in listView3.Items) { if (theItem.ForeColor != Color.Blue) requirements = false; } if (!requirements) { label11.Text = "1 - Requirements have not been met"; label11.Visible = true; //button3.Enabled = false; } else { label11.Visible = false; button3.Enabled = true; } return; } Database.Command("UPDATE results SET result = '" + mark + "', serialNumber = '" + textBox2.Text + "'WHERE idEnrollments = '" + splitter[1] + "' and idCourseComponents = '" + listView3.SelectedItems[0].Text + "'"); if (Database.Count("results", "idEnrollments = '" + splitter[1] + "' and idCourseComponents = '" + listView3.SelectedItems[0].Text + "'") == 0) { string[] columns2 = {"idEnrollments", "idCourseComponents", "Result", "serialNumber"}; string[] values2 = { splitter[1], listView3.SelectedItems[0].Text, mark, textBox2.Text }; Database.Insert("results", columns2, values2); } listView3.FocusedItem.SubItems[3].Text = mark; if (listView3.FocusedItem.SubItems[7].Text == "PRAC" || listView3.FocusedItem.SubItems[7].Text == "ASS") { //try //{ // while (!clsFunctions.IsNumeric(select.Selection)) // { // MessageBox.Show("Please enter valid score."); // select.ShowDialog(); // } // while (!clsFunctions.IsNumeric(select.Selection) || // Convert.ToDouble(select.Selection) > Convert.ToDouble(listView3.FocusedItem.SubItems[2].Text)) // { // MessageBox.Show("Please enter valid score."); // select.ShowDialog(); // } //} //catch //{ // MessageBox.Show("Error in input format. Please try again."); // return; //} if (Convert.ToDouble(listView3.FocusedItem.SubItems[3].Text) >= 0.5 * Convert.ToDouble(listView3.FocusedItem.SubItems[2].Text)) { listView3.FocusedItem.SubItems[4].Text = "Competent"; listView3.FocusedItem.ForeColor = Color.Blue; } else { listView3.FocusedItem.SubItems[4].Text = "N.Y.C"; listView3.FocusedItem.ForeColor = Color.Red; } } else if (listView3.FocusedItem.SubItems[7].Text == "ASS") { if (Convert.ToDouble(listView3.FocusedItem.SubItems[3].Text) >= 0.5 * Convert.ToDouble(listView3.FocusedItem.SubItems[2].Text)) { listView3.FocusedItem.SubItems[4].Text = "Competent"; listView3.FocusedItem.ForeColor = Color.Blue; } else { listView3.FocusedItem.SubItems[4].Text = "N.Y.C"; listView3.FocusedItem.ForeColor = Color.Red; } } if (listView3.FocusedItem.Index < listView3.Items.Count - 1) { listView3.Items[listView3.FocusedItem.Index + 1].Selected = true; listView3.Items[listView3.FocusedItem.Index + 1].Focused = true; } var allBlue2 = true; foreach (ListViewItem item in listView3.Items) { if (item.ForeColor != Color.Blue) allBlue2 = false; } if (allBlue2) { cboExams.Enabled = true; cboExams.BackColor = Color.White; listView4.BackColor = Color.White; var exams = Database.Query("components", "myParent = '" + listView2.SelectedItems[0].Text + "' AND ComponentAbrev = 'EXV'"); cboExams.Items.Clear(); foreach (DataRow newRow in exams.Tables[0].Rows) { cboExams.Items.Add(Convert.ToString(newRow["myParent"]) + " - " + Convert.ToString(newRow["Name"])); } if (exams.Tables[0].Rows.Count > 0) cboExams.Text = (string)cboExams.Items[0]; label11.Visible = false; button3.Enabled = true; } else { cboExams.Enabled = false; cboExams.BackColor = Color.Lavender; cboExams.Items.Clear(); listView4.BackColor = Color.Lavender; label11.Text = "Not all practicals are competent"; label11.Visible = true; //button3.Enabled = false; } }