/// <summary> /// Handles the Click event of the button1 control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private void Send_Mail_Btn_Click(object sender, RoutedEventArgs e) { // MessageBox.Show("!לפני בדיקת מייל", "b4 if", MessageBoxButton.OK); if ((Regex.IsMatch(this.Email_box.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"))) { // MessageBox.Show("!לאחר בדיקת מייל", "b4 try", MessageBoxButton.OK); // MessageBox.Show(this.to_txt.Text,"the mail"); if (!string.IsNullOrWhiteSpace(ID_box.Text)) { try { int testid = Convert.ToInt32(ID_box.Text); } catch { MessageBox.Show("תעודת הזהות לא כוללת רק מספרים" ,"!שים לב" ,MessageBoxButton.OK ,MessageBoxImage.Error); return; } } else { MessageBox.Show("אנא הכנס תעודת זהות", "!שים לב", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (string.IsNullOrWhiteSpace(school_textBox.Text)) { MessageBox.Show("אנא הכנס שם בית ספר יסודי", "!שים לב", MessageBoxButton.OK, MessageBoxImage.Error); return; } try { // MessageBox.Show("!ניסיון התחברות למסד", "נתונים", MessageBoxButton.OK); string Connectionstring = " Server=localhost;Database=project; UId=root;Password=1234;"; MySqlConnection objc = new MySqlConnection(Connectionstring); objc.Open(); // MessageBox.Show("!לאחר התחברות למסד", "נתונים", MessageBoxButton.OK); string Query = "select * from users where email='" + this.Email_box.Text + "'and empid='" + this.ID_box.Text + "' and rec_answer='" + this.school_textBox.Text + "' "; MySqlCommand crcommand = new MySqlCommand(Query, objc); // MessageBox.Show("!לפני ביצוע שאילתה ", "נתונים", MessageBoxButton.OK); crcommand.ExecuteNonQuery(); // MessageBox.Show("!לאחר ביצוע שאילתה ", "נתונים", MessageBoxButton.OK); MySqlDataReader dr = crcommand.ExecuteReader(); // MessageBox.Show("הכנסת הסיסמה (במידה וקיימת) למשתנה"); int count = 0; while (dr.Read()) { count++; username = dr.GetString(0); userpass = dr.GetString(1); mail_body = "סיסמתך היא: " + userpass + " \nעבור תעודת הזהות: " + username + ""; } // MessageBox.Show(this.to_txt.Text, " "+userpass); // MessageBox.Show("בדיקה האם המייל קיים במערכת"); if (count == 1) { string ress = "false"; // this func will send an EMail in the form of (all must be Strings): (Email Address to send,EMail Title,Email Body) /Shuki Porat if (ress != SendEmail(this.Email_box.Text, "שיחזור סיסמא למערכת קרוסר", mail_body)) { MessageBox.Show("!שם המשתמש והסיסמא נשלחו לכתובת האימייל", "!הפעולה הושלמה", MessageBoxButton.OK); Login window = new Login(); window.Show(); this.Close(); } else { MessageBox.Show(".כישלון בשליחה - לא ניתן להתחבר לשרת האימייל\n\n (? האם קיים חיבור פעיל ותקין לאינטרנט)", "!שים לב", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show(" כתובת האימייל ו/או תעודת הזהות\n !ו/או התשובה לשאלה שהוזנו לא נמצאים במאגר \n\n .פנה בבקשה למנהל המערכת", "!הפעולה נכשלה", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else MessageBox.Show("!כתובת המייל לא הוזנה כהלכה! אנא נסה שנית", "!הפעולה נכשלה",MessageBoxButton.OK ,MessageBoxImage.Error); }
/// <summary> /// Handles the Click event of the exit_button control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private void exit_button_Click(object sender, RoutedEventArgs e) { Console.WriteLine("" + Login.close + " כפתור התנתקות"); if (Login.close == 0) // then the user want to exit. { if (MessageBox.Show("?האם אתה בטוח שברצונך לצאת מהמערכת ", "וידוא יציאה", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No) { return; //don't exit. } else // if the user clicked on "Yes" so he wants to Update. { // logoff user try { string empid1 = Login.empid; MySqlConnection MySqlConn = new MySqlConnection(Login.Connectionstring); MySqlConn.Open(); string Query1 = "update users set connected='לא מחובר' where empid='" + empid1 + "' "; MySqlCommand MSQLcrcommand1 = new MySqlCommand(Query1, MySqlConn); MSQLcrcommand1.ExecuteNonQuery(); MySqlDataAdapter mysqlDAdp = new MySqlDataAdapter(MSQLcrcommand1); MySqlConn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } MessageBox.Show(" נותקת בהצלחה מהמערכת\n תודה שהשתמשת במערכת קרוסר\n !להתראות", "!הצלחה", MessageBoxButton.OK, MessageBoxImage.Information); Login LI = new Login(); LI.Show(); Login.close = 1; this.Close(); } } else { } Login.close = 0; }
private void exit_clicked(object sender, CancelEventArgs e) { Console.WriteLine("" + Login.close); if (Login.close == 0) // then the user want to exit. { } else { Login window = new Login(); window.Show(); } Login.close = 0; }