private void toilet_CheckedChanged(object sender, EventArgs e)
        {
            if (toilet.Checked == true)
            {
                if (!Main_Screen.log_table.Rows[0][12].ToString().Equals("00:00:00"))
                {
                    int startHour    = Main_Screen.GetHoures(Main_Screen.log_table.Rows[0][12].ToString(), Main_Screen.getTime());
                    int startMinutes = Main_Screen.GetMinutes(Main_Screen.log_table.Rows[0][12].ToString(), Main_Screen.getTime());
                    int endtHour     = Main_Screen.GetHoures(Main_Screen.getTime(), Main_Screen.ChangeEndTime());
                    int endMinutes   = Main_Screen.GetMinutes(Main_Screen.getTime(), Main_Screen.ChangeEndTime());
                    if (startHour != 0 && startMinutes != 0 || endtHour != 0 && endMinutes != 0)
                    {
                        if (startHour >= 1 || startMinutes >= 30)
                        {
                            if (endtHour >= 1 || endMinutes >= 30)
                            {
                                string query2 = "SELECT * FROM report WHERE exam_id = @exam_id AND type = 'toilet' AND end = ''";

                                MySqlConnection conn2 = new MySqlConnection("server=localhost;user id=root;database=easytest");
                                conn2.Open();

                                MySqlCommand cmd2 = new MySqlCommand(query2, conn2);

                                cmd2.Parameters.AddWithValue("@exam_id", Login.exam_table.Rows[0].ItemArray[0].ToString());
                                cmd2.Parameters.AddWithValue("@student_id", IDAnsLABEL.Text);
                                //cmd.Parameters.AddWithValue("@start_time", ExitTimeLBL.Text);

                                MySqlDataAdapter da2 = new MySqlDataAdapter(cmd2);
                                DataTable        dt2 = new DataTable();

                                da2.Fill(dt2);

                                if (dt2.Rows.Count > 0)
                                {
                                    if (dt2.Rows[0][2].ToString().Equals(IDAnsLABEL.Text))
                                    {
                                        ContentNote.Visible  = false;
                                        comboBox.Visible     = false;
                                        TimerBTN.Enabled     = true;
                                        ReturnBTN2.Visible   = true;
                                        ExitTimeLBL2.Visible = true;
                                        button1.Visible      = false;

                                        ExitTimeLBL.Text    = dt2.Rows[0].ItemArray[4].ToString().Substring(0, 5);
                                        ExitTimeLBL.Visible = true;
                                        TimerBTN.Text       = "סיים טיימר";
                                        TimerClick          = true; ClickCount++;
                                        //Main_Screen.StudentInToilet = true;

                                        /*string query = "SELECT report_id, start FROM report WHERE exam_id = @exam_id AND student_id = @student_id AND type = 'toilet' AND end = ''";
                                         *
                                         * MySqlConnection conn = new MySqlConnection("server=localhost;user id=root;database=easytest");
                                         * conn.Open();
                                         *
                                         * MySqlCommand cmd = new MySqlCommand(query, conn);
                                         *
                                         * cmd.Parameters.AddWithValue("@exam_id", Login.exam_table.Rows[0].ItemArray[0].ToString());
                                         * cmd.Parameters.AddWithValue("@student_id", IDAnsLABEL.Text);
                                         * //cmd.Parameters.AddWithValue("@start_time", ExitTimeLBL.Text);
                                         *
                                         * MySqlDataAdapter da = new MySqlDataAdapter(cmd);
                                         *
                                         * da.Fill(report_dt);
                                         *
                                         * if (report_dt.Rows.Count > 0)
                                         * {*/


                                        //}
                                        //conn.Close();
                                    }
                                    else
                                    {
                                        MessageBox.Show("קיים סטודנט בשירותים", "הודעה");
                                    }
                                    conn2.Close();
                                }
                                else
                                {
                                    ContentNote.Visible  = false;
                                    comboBox.Visible     = false;
                                    TimerBTN.Enabled     = true;
                                    ReturnBTN2.Visible   = true;
                                    ExitTimeLBL2.Visible = true;
                                    button1.Visible      = false;
                                }
                            }
                            else
                            {
                                MessageBox.Show("!היציאה לשירותים אסורה", "הודעה", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        else
                        {
                            MessageBox.Show("!היציאה לשירותים אסורה", "הודעה", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        MessageBox.Show("!היציאה לשירותים אסורה", "הודעה", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("!היציאה לשירותים אסורה", "הודעה", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
        private void button10_Click(object sender, EventArgs e)
        {
            if (!lastBTN.Equals(""))
            {
                string query = "";
                if (Main_Screen.EmptyClass && !Main_Screen.TestBegin)
                {
                    Main_Screen.EmptyClass = false;
                    Main_Screen.BeginBTN   = true;
                    Main_Screen.first      = false;
                    /////////////////////////////////////////////////////
                }
                if (Main_Screen.TestBegin)
                {
                    query = "INSERT INTO `examination_log` (`exam_id`, `student_id`," +
                            " `lecturer_id`, `proctor_id`, `report_id`, `course_id`, `class_num`," +
                            " `notebook_num`, `table_num`, `start_time`, `end_time`," +
                            " `extra_time`, `class_start_time`) VALUES (@exam_id, @student_id, @lecturer_id, @proctor_id, ''," +
                            " @course_id, @class_num, @notebook_num, @table_num, @startTime, '', '',@class_start_time)";
                }
                else
                {
                    query = "INSERT INTO `examination_log` (`exam_id`, `student_id`," +
                            " `lecturer_id`, `proctor_id`, `report_id`, `course_id`, `class_num`," +
                            " `notebook_num`, `table_num`, `start_time`, `end_time`," +
                            " `extra_time`, `class_start_time`) VALUES (@exam_id, @student_id, @lecturer_id, @proctor_id, ''," +
                            " @course_id, @class_num, @notebook_num, @table_num, '', '', '','')";
                }



                MySqlConnection conn = new MySqlConnection("server=localhost;user id=root;database=easytest");
                conn.Open();

                MySqlCommand cmd = new MySqlCommand(query, conn);

                cmd.Parameters.AddWithValue("@exam_id", Login.exam_table.Rows[0].ItemArray[0].ToString());
                cmd.Parameters.AddWithValue("@student_id", Add_Student.StudentID);
                cmd.Parameters.AddWithValue("@lecturer_id", Login.exam_table.Rows[0].ItemArray[2].ToString());
                cmd.Parameters.AddWithValue("@proctor_id", Login.exam_table.Rows[0].ItemArray[1].ToString());
                cmd.Parameters.AddWithValue("@course_id", Login.exam_table.Rows[0].ItemArray[3].ToString());
                cmd.Parameters.AddWithValue("@class_num", Login.exam_table.Rows[0].ItemArray[4].ToString());
                cmd.Parameters.AddWithValue("@notebook_num", NoteBook_Num.notebookNum);
                cmd.Parameters.AddWithValue("@table_num", lastBTN);
                cmd.Parameters.AddWithValue("@startTime", Main_Screen.getTime());
                cmd.Parameters.AddWithValue("@class_start_time", Main_Screen.class_start_time);


                cmd.ExecuteNonQuery();

                conn.Close();
                //////////////////////////////////////////////////////////////
                ///בודק כל הזמן המעדכן אם הכיתה התחילה בחינה - עבור הציאה לשירותים
                string          Query1 = "SELECT * FROM examination_log WHERE exam_id = @exam_id";
                MySqlConnection conn1  = new MySqlConnection("server=localhost;user id=root;database=easytest");
                conn1.Open();

                MySqlCommand cmd1 = new MySqlCommand(Query1, conn1);
                cmd1.Parameters.AddWithValue("@exam_id", Login.exam_table.Rows[0].ItemArray[0].ToString());
                MySqlDataAdapter da1 = new MySqlDataAdapter(cmd1);

                da1.Fill(Main_Screen.log_table);
                conn1.Close();



                // sending the result to main screen //

                for (int i = 0; i < Int32.Parse(Main_Screen.map_row); i++)
                {
                    for (int j = 0; j < Int32.Parse(Main_Screen.map_collumn); j++)
                    {
                        if (cards[j, i].BackColor == Color.Green)
                        {
                            Main_Screen.mainMap[j, i].BackColor = Color.Green;
                            Main_Screen.mainMap[j, i].Enabled   = true;
                        }
                    }
                }



                Add_Student.student_table.Clear();
                Login.main_screen.Show();
                Hide();
            }
            else
            {
                MessageBox.Show("נא לבחור מס' שולחן", "הודעה", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!Main_Screen.log_table.Rows[0][12].ToString().Equals("00:00:00"))
            {
                int startHour    = Main_Screen.GetHoures(Main_Screen.log_table.Rows[0][12].ToString(), Main_Screen.getTime());
                int startMinutes = Main_Screen.GetMinutes(Main_Screen.log_table.Rows[0][12].ToString(), Main_Screen.getTime());
                if (startHour >= 1 || startMinutes >= 30)
                {
                    string query = "UPDATE `examination_log` SET `end_time` = @endTime WHERE exam_id = @exam_id AND student_id = @student_id";

                    MySqlConnection conn = new MySqlConnection("server=localhost;user id=root;database=easytest");
                    conn.Open();

                    MySqlCommand cmd = new MySqlCommand(query, conn);
                    cmd.Parameters.AddWithValue("@endTime", Main_Screen.getTime());
                    cmd.Parameters.AddWithValue("@exam_id", Login.exam_table.Rows[0].ItemArray[0].ToString());
                    cmd.Parameters.AddWithValue("@student_id", idLBL.Text);

                    int flg = cmd.ExecuteNonQuery();
                    //MySqlDataReader dr = cmd.ExecuteReader();
                    conn.Close();
                    if (flg > 0)
                    {
                        Main_Screen.tableForIcone = tableBTN.Text;
                        Main_Screen.typeForIcone  = "finish";
                        Main_Screen.newFinished   = true;
                        MessageBox.Show("סטודנט הגיש בחינה");


                        string query4 = "SELECT course_name FROM course WHERE course_id = @courseId";

                        MySqlConnection conn4 = new MySqlConnection("server=localhost;user id=root;database=easytest");
                        conn4.Open();

                        MySqlCommand cmd4 = new MySqlCommand(query4, conn4);
                        cmd4.Parameters.AddWithValue("@courseId", Login.exam_table.Rows[0][3].ToString());

                        MySqlDataAdapter da4 = new MySqlDataAdapter(cmd4);
                        DataTable        dt4 = new DataTable();
                        da4.Fill(dt4);

                        try
                        {
                            SmtpClient clientDetails = new SmtpClient();
                            clientDetails.Port                  = 587;
                            clientDetails.Host                  = "smtp.gmail.com";
                            clientDetails.EnableSsl             = true;
                            clientDetails.DeliveryMethod        = SmtpDeliveryMethod.Network;
                            clientDetails.UseDefaultCredentials = false;
                            clientDetails.Credentials           = new NetworkCredential("*****@*****.**", "Project1234");

                            MailMessage mailDetails = new MailMessage();
                            mailDetails.From = new MailAddress("*****@*****.**");
                            mailDetails.To.Add(student_table.Rows[0][3].ToString());
                            mailDetails.Subject    = nameLBL.Text + " להלן פרטי הבחינה  בקורס " + dt4.Rows[0][0].ToString();
                            mailDetails.IsBodyHtml = false;
                            mailDetails.Body       = " הודעה אטומטית ממערכת EasyTest:" + " מספר מחברת - " + examination_log_table.Rows[0][7].ToString();
                            clientDetails.Send(mailDetails);
                            MessageBox.Show("מייל נשלח בהצלחה", "הודעה", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            conn4.Close();
                        }
                        catch
                        {
                            MessageBox.Show("שגיאה בשליחת מייל", "שגיאה", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("ניתן להגיש בחינה רק לאחר חצי שעה");
                }
            }
            else
            {
                MessageBox.Show("ניתן להגיש בחינה רק לאחר חצי שעה");
            }
        }