예제 #1
0
        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);
                }
            }
        }
예제 #2
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("ניתן להגיש בחינה רק לאחר חצי שעה");
            }
        }