private void TextUsername_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { TextPassword.Focus(); } }
private void ButtonLogin_Click(object sender, EventArgs e) { if (mydb.Checkusername(TextUsername.Text.Trim())) { if (mydb.Login(TextUsername.Text.Trim(), TextShowPassword.Text.Trim(), CbAuthorize.Text)) { if (CbAuthorize.SelectedIndex != 1) { administratorlogin = true; } Loginghlobal = true; this.Close(); } else { MessageBox.Show("Password is wrong!!!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Hand); if (CBpassword.Checked) { TextShowPassword.Focus(); TextShowPassword.SelectAll(); } else { TextPassword.Focus(); TextPassword.SelectAll(); } } } else { MessageBox.Show("User name was not registered in database. Please get Administrator to create new user. Thank you", "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public PasswordDialog() { InitializeComponent(); TextPassword.Text = ""; TextPassword.Focus(); }
protected void Btt1_Click(object sender, EventArgs e) { if (TextPassword.Text == TxtRePassword.Text) { ExecuteInsert(TxtName.Text, TxtUserName.Text, TxtEMAIL.Text, TextPassword.Text, TxtTelephone.Text, DropDownList1.SelectedItem.Text, TxtAge.Text, TxtAddress.Text); Response.Write("Record Was Successfully added"); ClearControls(Page); } else { Response.Write("Password Did Not Match"); TextPassword.Focus(); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["USER_NAME"] != null) { string requestedFile = Path.GetFileName(Request.Path); OracleConnection conn = new OracleConnection(strConnString); conn.Open(); string makeSQL = " SELECT NUPP.IS_PAGE_ACTIVE, NUPP.IS_ADD_ACTIVE, NUPP.IS_EDIT_ACTIVE, NUPP.IS_DELETE_ACTIVE, NUPP.IS_VIEW_ACTIVE FROM NRC_USER_PAGE_PERMISSION NUPP LEFT JOIN NRC_USER_PAGES NUP ON NUP.USER_PAGE_ID = NUPP.USER_PAGE_ID WHERE NUPP.USER_ID = '" + Session["USER_ID"] + "' AND NUP.IS_ACTIVE = 'Enable' AND NUP.PAGE_URL = '" + requestedFile + "' "; cmdl = new OracleCommand(makeSQL); oradata = new OracleDataAdapter(cmdl.CommandText, conn); dt = new DataTable(); oradata.Fill(dt); RowCount = dt.Rows.Count; for (int i = 0; i < RowCount; i++) { IS_PAGE_ACTIVE = dt.Rows[i]["IS_PAGE_ACTIVE"].ToString(); IS_ADD_ACTIVE = dt.Rows[i]["IS_ADD_ACTIVE"].ToString(); IS_EDIT_ACTIVE = dt.Rows[i]["IS_EDIT_ACTIVE"].ToString(); IS_DELETE_ACTIVE = dt.Rows[i]["IS_DELETE_ACTIVE"].ToString(); IS_VIEW_ACTIVE = dt.Rows[i]["IS_VIEW_ACTIVE"].ToString(); } // if (IS_PAGE_ACTIVE == "Enable") // { if (!IsPostBack) { TextPassword.Focus(); TextPassword.TextMode = TextBoxMode.Password; TextPasswordConfirm.Text = ""; alert_box.Visible = false; } IsLoad = false; // } // else // { // Response.Redirect("~/PagePermissionError.aspx"); // } } else { Response.Redirect("~/Default.aspx"); } }
public Login() { InitializeComponent(); _userRepository = UnityInit.UnitOfWork.GetRepository <UserRepository>(); _systemSettingRepository = UnityInit.UnitOfWork.GetRepository <SystemSettingRepository>(); TxtVersion.Text = string.Format("当前版本号 : V{0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()); CheckBoxLogin.IsChecked = !string.IsNullOrEmpty(Settings.Default.Login); TextLogin.Text = Settings.Default.Login; if (string.IsNullOrEmpty(TextLogin.Text)) { TextLogin.Focus(); } else { TextPassword.Focus(); } }
private void CreateNewAdministrator(object sender, EventArgs e) { if (TextLogin.Text == "") { MessageBox.Show("Введите логин!"); TextLogin.Focus(); } else if (TextPassword.Text == "") { MessageBox.Show("Введите пароль!"); TextPassword.Focus(); } else { conn.Open(); sql = "SELECT COUNT(*) FROM INFO WHERE INFO_LOGIN = '******'"; MySqlCommand querycheckadm = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(querycheckadm.ExecuteScalar()); if (COUNT == 0) { sql = "INSERT INTO INFO (INFO_LOGIN, INFO_PASSWORD) VALUES ('" + TextLogin.Text + "','" + TextPassword.Text + "')"; MySqlCommand cmd = new MySqlCommand(sql, conn); if (cmd.ExecuteNonQuery() == 1) { MessageBox.Show("Пользователь успешно создан!"); this.Close(); AdminMainForm amf = new AdminMainForm(); amf.Show(); conn.Close(); } else { MessageBox.Show("Запись не удалась"); conn.Close(); } } else { MessageBox.Show("Такой пользователь уже существует!"); conn.Close(); } } }
private async void Ingresar_Clicked(object sender, EventArgs e) { if (string.IsNullOrEmpty(TextUsuario.Text)) { await DisplayAlert("Validación", "El_nombre_de_usuario_es_requerido", "OK"); TextUsuario.Focus(); return; } if (string.IsNullOrEmpty(TextPassword.Text)) { await DisplayAlert("Validación", "La_contraseña_es_requerida", "OK"); TextPassword.Focus(); return; } await Navigation.PushAsync(new DomicilioPage()); }
public FilePasswordDialog(MarkdownDocument document, bool decrypt) { this.document = document; InitializeComponent(); DataContext = this; mmApp.SetThemeWindowOverride(this); if (decrypt) { ButtonLabel.Text = "Decrypt"; Title = "Decrypt file: " + document.FilenamePathWithIndicator; } else { Title = "Encrypt file: " + document.FilenamePathWithIndicator; } TextPassword.Focus(); }
public FilePasswordDialog(MarkdownDocument document, bool decrypt) { Document = document; InitializeComponent(); DataContext = this; mmApp.SetThemeWindowOverride(this); if (decrypt) { ButtonLabel.Text = "Decrypt"; Title = "Decrypt Password Protected File"; TextEncryptDecrypt.Text = "Decrypt file:"; } TextFilename.Text = System.IO.Path.GetFileName(document.Filename); TextPath.Text = System.IO.Path.GetDirectoryName(document.Filename); TextPassword.Focus(); }
protected void Button_Click_Login(object sender, EventArgs e) { try { string UserName = TextUserName.Text.Trim(); string Password = TextPassword.Text.Trim(); OracleConnection conn = new OracleConnection(strConnString); conn.Open(); if (conn.State.ToString() == "Open") { string checkuser = "******" + UserName + "'"; com = new OracleCommand(checkuser); oradata = new OracleDataAdapter(com.CommandText, conn); dt = new DataTable(); oradata.Fill(dt); RowCount = dt.Rows.Count; string temp = ""; for (int i = 0; i < RowCount; i++) { temp = dt.Rows[i]["temp"].ToString(); } conn.Close(); if (temp == "1") { conn.Open(); OracleCommand cmd = new OracleCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT NU.USER_ID, NU.PASSWORD, NUR.USER_ROLE_SHORT_NAME, NUR.USER_ROLE_NAME, NU.CREATE_DATE, HE.EMP_FNAME || ' ' || HE.EMP_LNAME AS EMP_NAME, nvl(NU.IS_PASSWORD_CHANGE,0), HD.DIVISION_NAME, HD.DIV_SHORT_NAME from NRC_USER NU LEFT JOIN HR_EMPLOYEES HE ON HE.EMP_ID = NU.EMP_ID LEFT JOIN HR_EMP_DIVISIONS HD ON HD.DIVISION_ID = HE.DIVISION_ID LEFT JOIN NRC_USER_ROLE NUR ON NUR.USER_ROLE_ID = NU.USER_ROLE_ID WHERE NU.USER_NAME = '" + UserName + "'"; cmd.CommandType = CommandType.Text; OracleDataReader dr = cmd.ExecuteReader(); int userID = 0, NrcIsPasswordChange = 0; string passDB = "", NrcUserSrole = "", NrcUserRoleName = "", NrcUserName = "", HrDivisionName = "", HrDivShortName = ""; DateTime NrcUserCdate = DateTime.Today; while (dr.Read()) { if (!dr.IsDBNull(0)) { userID = dr.GetInt32(0); passDB = dr.GetString(1); NrcUserSrole = dr.GetString(2); NrcUserRoleName = dr.GetString(3); NrcUserCdate = dr.GetDateTime(4); NrcUserName = dr.GetString(5); NrcIsPasswordChange = dr.GetInt32(6); HrDivisionName = dr.GetString(7); HrDivShortName = dr.GetString(8); } } string pass_add = "1234567891234560"; OracleCommand cmdep = new OracleCommand(); cmdep.Connection = conn; cmdep.CommandText = " SELECT get_dec_val ('" + passDB + "','" + pass_add + "') FROM dual"; cmdep.CommandType = CommandType.Text; OracleDataReader dre = cmdep.ExecuteReader(); string EncryptoPassword = ""; while (dre.Read()) { if (!dre.IsDBNull(0)) { EncryptoPassword = dre.GetString(0); } } if (EncryptoPassword == Password) { Session["USER_NAME"] = UserName; Session["USER_ID"] = userID; Session["NRC_USER_ROLE_NAME"] = NrcUserRoleName; Session["EMP_NAME"] = NrcUserName; Session["NRC_USER_SROLE"] = NrcUserSrole; Session["NRC_USER_C_DATE"] = NrcUserCdate.ToLongDateString(); Session["NRC_DIVISION_NAME"] = HrDivisionName; Session["NRC_DIV_SHORT_NAME"] = HrDivShortName; string Emp_name_temp = Convert.ToString(Session["EMP_NAME"]); string[] EmpName = Emp_name_temp.Split(' '); Session["EMP_NAME_TWO"] = EmpName[0] + " " + EmpName[1]; if (NrcIsPasswordChange > 0) { Response.Redirect("Dashboard.aspx"); } else { Response.Redirect("NRC/NrcUserChangePassword.aspx"); } } else { TextPassword.Focus(); LabelUserName.Text = "<p class='text-green'>User Name is correct!</p>"; LabelPassword.Text = ("<p class='text-red'>Password is not correct!</p>"); } conn.Close(); } else { LabelUserName.Text = "<p class='text-red'>User Name is not correct!</p>"; } } else { Response.Redirect("~/ParameterError.aspx"); } } catch (System.Data.SqlClient.SqlException ex) { Response.Redirect("~/ParameterError.aspx"); } }
private async void ButtonSend_Click(object sender, RoutedEventArgs e) { _total = 0; _success = 0; _failed = 0; if (TextFrom.Text.Trim().Length == 0) { MessageDialog dlg = new MessageDialog("Please input from address!"); await dlg.ShowAsync(); TextFrom.Text = ""; TextFrom.Focus(Windows.UI.Xaml.FocusState.Programmatic); return; } if (TextTo.Text.Trim("\r\n \t".ToCharArray()).Length == 0) { MessageDialog dlg = new MessageDialog("Please input a recipient at least!"); await dlg.ShowAsync(); TextTo.Text = ""; TextTo.Focus(Windows.UI.Xaml.FocusState.Programmatic); return; } if (TextServer.Text.Trim().Length == 0) { MessageDialog dlg = new MessageDialog("Please input server address!"); await dlg.ShowAsync(); TextServer.Text = ""; TextServer.Focus(Windows.UI.Xaml.FocusState.Programmatic); return; } bool isUserAuthencation = CheckAuthentication.IsOn; if (isUserAuthencation) { if (TextUser.Text.Trim().Length == 0) { MessageDialog dlg = new MessageDialog("Please input user name!"); await dlg.ShowAsync(); TextUser.Text = ""; TextUser.Focus(Windows.UI.Xaml.FocusState.Programmatic); return; } if (TextPassword.Password.Trim().Length == 0) { MessageDialog dlg = new MessageDialog("Please input password!"); await dlg.ShowAsync(); TextPassword.Password = ""; TextPassword.Focus(Windows.UI.Xaml.FocusState.Programmatic); return; } } ButtonSend.IsEnabled = false; ButtonSend.Visibility = Visibility.Collapsed; ButtonCancel.Visibility = Visibility.Visible; ButtonCancel.IsEnabled = true; ButtonClose.Visibility = Visibility.Collapsed; ButtonClose.IsEnabled = false; ButtonAttach.Visibility = Visibility.Collapsed; ListRecipients.Items.Clear(); PageViewer.Visibility = Visibility.Collapsed; StatusViewer.Visibility = Visibility.Visible; _cancellationToken = new CancellationTokenSource(); List <Task> tasks = new List <Task>(); string[] toLines = TextTo.Text.Trim("\r\n \t".ToCharArray()).Split("\n".ToCharArray()); List <string> recipients = new List <string>(); for (int i = 0; i < toLines.Length; i++) { string address = toLines[i].Trim("\r\n \t".ToCharArray()); if (address.Length > 0) { recipients.Add(address); } } int n = recipients.Count; toLines = recipients.ToArray(); _total = n; TextStatus.Text = string.Format("Total {0}, success: {1}, failed {2}", _total, _success, _failed); ButtonCancel.IsEnabled = true; n = 0; ListRecipients.Items.Add(new RecipientData("Email", "Status", 0)); n++; for (int i = 0; i < toLines.Length; i++) { int maxThreads = (int)WorkerThreads.Value; while (tasks.Count >= maxThreads) { Task[] currentTasks = tasks.ToArray(); Task taskFinished = await Task.WhenAny(currentTasks); tasks.Remove(taskFinished); TextStatus.Text = string.Format( "Total {0}, success: {1}, failed {2}", _total, _success, _failed ); } string addr = toLines[i]; int index = n; ListRecipients.Items.Add(new RecipientData(addr, "Queued", n)); if (_cancellationToken.Token.IsCancellationRequested) { n++; UpdateRecipientItem(index, "Operation was cancelled!"); continue; } SmtpServer server = new SmtpServer(TextServer.Text); int[] ports = new int[] { 25, 587, 465 }; server.Port = ports[ListPorts.SelectedIndex]; bool isSslConnection = CheckSsl.IsOn; if (isSslConnection) { // use SSL/TLS based on server port server.ConnectType = SmtpConnectType.ConnectSSLAuto; } else { // Most mordern SMTP servers require SSL/TLS connection now // ConnectTryTLS means if server supports SSL/TLS connection, SSL/TLS is used automatically server.ConnectType = SmtpConnectType.ConnectTryTLS; } server.Protocol = (ServerProtocol)ListProtocols.SelectedIndex; if (isUserAuthencation) { server.User = TextUser.Text; server.Password = TextPassword.Password; } // For evaluation usage, please use "TryIt" as the license code, otherwise the // "Invalid License Code" exception will be thrown. However, the trial object only can be used // with developer license // For licensed usage, please use your license code instead of "TryIt", then the object // can used with published windows store application. SmtpMail mail = new SmtpMail("TryIt"); mail.From = new MailAddress(TextFrom.Text); // If your Exchange Server is 2007 and used Exchange Web Service protocol, please add the following line; // oMail.Headers.RemoveKey("From"); mail.To = new AddressCollection(addr); mail.Subject = TextSubject.Text; string bodyText = ""; bool htmlBody = false; if (CheckHtml.IsOn) { bodyText = await HtmlEditor.InvokeScriptAsync("getHtml", null); htmlBody = true; } else { bodyText = TextEditor.Text; } int count = _attachments.Count; string[] attachments = new string[count]; for (int x = 0; x < count; x++) { attachments[x] = _attachments[x]; } Task task = Task.Factory.StartNew(() => SubmitMail(server, mail, attachments, bodyText, htmlBody, index).Wait() ); tasks.Add(task); n++; } if (tasks.Count > 0) { await Task.WhenAll(tasks.ToArray()); } TextStatus.Text = string.Format("Total {0}, success: {1}, failed {2}", _total, _success, _failed); ButtonSend.IsEnabled = false; ButtonSend.Visibility = Visibility.Collapsed; ButtonCancel.Visibility = Visibility.Collapsed; ButtonCancel.IsEnabled = false; ButtonClose.Visibility = Visibility.Visible; ButtonClose.IsEnabled = true; ButtonAttach.Visibility = Visibility.Collapsed; }
private void ButtonLogin_Click(object sender, EventArgs e) { if (TextName.Text.Trim() == "" && TextPassword.Text.Trim() == "") { labelNameNull.Text = "账号不能为空"; labelPasswordNull.Text = "密码不能为空"; TextName.Focus(); } else if (TextName.Text.Trim() == "") { labelNameNull.Text = "账号不能为空"; labelPasswordNull.Text = " "; TextName.Focus(); } else if (TextPassword.Text.Trim() == "") { labelNameNull.Text = " "; labelPasswordNull.Text = "密码不能为空"; TextPassword.Focus(); } else { labelNameNull.Text = " "; labelPasswordNull.Text = " "; string identify = ComboBox.SelectedItem.ToString(); switch (identify) { case "总管理员": { if (TextName.Text.Trim() != "admin" && TextPassword.Text.Trim() != PublicValue.ADMINPASWRD) { labelNameNull.Text = "账号输入错误"; labelPasswordNull.Text = "密码输入错误"; TextName.Focus(); } else if (TextName.Text.Trim() != "admin") { labelNameNull.Text = "账号输入错误"; labelPasswordNull.Text = " "; TextName.Focus(); } else if (TextPassword.Text.Trim() != PublicValue.ADMINPASWRD) { labelNameNull.Text = " "; labelPasswordNull.Text = "密码输入错误"; TextName.Focus(); } else { MessageBox.Show("登录成功!", "提示"); this.Hide(); Admin admin = new Admin(); admin.Show(); } break; } case "公寓管理员": { int flag = 0; MySQLConnection SQLconnection = new MySQLConnection(new MySQLConnectionString ("localhost", "DormitoryManage", "root", "123456").AsString); string SQLstr = "SELECT managerNumber, managerPassword FROM manager_info"; SQLconnection.Open(); MySQLCommand SQLcommand = new MySQLCommand(SQLstr, SQLconnection); MySQLDataReader SQLreader = (MySQLDataReader)SQLcommand.ExecuteReader(); while (SQLreader.Read()) { string tempa = SQLreader["managerNumber"].ToString(); string tempb = SQLreader["managerPassword"].ToString(); if (TextName.Text.Trim() != tempa && TextPassword.Text.Trim() != tempb) { flag = 0; } else if (TextName.Text.Trim() != tempa) { flag = 1; } else if (TextPassword.Text.Trim() != tempb) { flag = 2; } else { flag = 3; break; } } SQLconnection.Close(); if (flag == 0) { labelNameNull.Text = "账号输入错误"; labelPasswordNull.Text = "密码输入错误"; TextName.Focus(); } else if (flag == 1) { labelNameNull.Text = "账号输入错误"; labelPasswordNull.Text = " "; TextName.Focus(); } else if (flag == 2) { labelNameNull.Text = " "; labelPasswordNull.Text = "密码输入错误"; TextName.Focus(); } else if (flag == 3) { MessageBox.Show("登录成功!", "提示"); PublicValue.MAGNUM = TextName.Text; this.Hide(); ManagerHost managerhost = new ManagerHost(); managerhost.Show(); } break; } case "学生": { int flag = 0; MySQLConnection SQLconnection = new MySQLConnection(new MySQLConnectionString ("localhost", "DormitoryManage", "root", "123456").AsString); string SQLstr = "SELECT studentNumber, studentPassword FROM student_info"; SQLconnection.Open(); MySQLCommand SQLcommand1 = new MySQLCommand("SET NAMES GB2312", SQLconnection); SQLcommand1.ExecuteNonQuery(); MySQLCommand SQLcommand2 = new MySQLCommand(SQLstr, SQLconnection); MySQLDataReader SQLreader = (MySQLDataReader)SQLcommand2.ExecuteReader(); while (SQLreader.Read()) { string tempa = SQLreader["studentNumber"].ToString(); string tempb = SQLreader["studentPassword"].ToString(); if (TextName.Text.Trim() != tempa && TextPassword.Text.Trim() != tempb) { flag = 0; } else if (TextName.Text.Trim() != tempa) { flag = 1; } else if (TextPassword.Text.Trim() != tempb) { flag = 2; } else { flag = 3; break; } } SQLconnection.Close(); if (flag == 0) { labelNameNull.Text = "账号输入错误"; labelPasswordNull.Text = "密码输入错误"; TextName.Focus(); } else if (flag == 1) { labelNameNull.Text = "账号输入错误"; labelPasswordNull.Text = " "; TextName.Focus(); } else if (flag == 2) { labelNameNull.Text = " "; labelPasswordNull.Text = "密码输入错误"; TextName.Focus(); } else if (flag == 3) { MessageBox.Show("登录成功!", "提示"); PublicValue.STUNUM = TextName.Text; this.Hide(); StudentHost studenthost = new StudentHost(); studenthost.Show(); } break; } } } }
private void CreateNewDoctor(object sender, EventArgs e) { Messages msg = new Messages(); if (TextLastName.Text == "") { msg.DataError("Введите фамилию!"); TextLastName.Focus(); } else if (TextFirstName.Text == "") { msg.DataError("Введите имя!"); TextFirstName.Focus(); } else if (TextIIN.Text.Length != 12) { msg.DataError("Введите корректный ИИН!"); TextIIN.Focus(); } else if (TextEmail.Text == "") { msg.DataError("Введите адрес электронной почты!"); TextEmail.Focus(); } else if (TextPhone.Text == "") { msg.DataError("Введите номер телефона!"); TextPhone.Focus(); } else if (TextPassword.Text == "") { msg.DataError("Введите пароль!"); TextPassword.Focus(); } else if (TextPassword.Text != TextRepPassword.Text) { msg.DataError("Пароли не совпадают!"); TextPassword.Focus(); } else if (CBSetSpec.Text == "") { msg.DataError("Выберите специализацию!"); CBSetSpec.Focus(); } else { conn.Open(); sql = "SELECT COUNT(*) FROM DOCTOR WHERE DOC_EMAIL = '" + TextEmail.Text + "'"; MySqlCommand checkEmail = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(checkEmail.ExecuteScalar()); if (COUNT == 0) { sql = "SELECT COUNT(*) FROM DOCTOR WHERE DOC_IIN = '" + TextIIN.Text + "'"; MySqlCommand checkIIN = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(checkIIN.ExecuteScalar()); if (COUNT == 0) { sql = "INSERT INTO DOCTOR (DOC_LASTNAME, " + "DOC_FIRSTNAME, " + "DOC_PATRONYMIC, " + "DOC_IIN, " + "DOC_EMAIL, " + "DOC_PHONE, " + "DOC_PASSWORD, " + "SPECIALISATION_ID_SPEC) " + "VALUES ('" + TextLastName.Text + "', " + "'" + TextFirstName.Text + "', " + "'" + TextPatronymic.Text + "', " + "'" + TextIIN.Text + "', " + "'" + TextEmail.Text + "', " + "'" + TextPhone.Text + "', " + "'" + TextPassword.Text + "', " + "" + idspec + ")"; MySqlCommand insdoc = new MySqlCommand(sql, conn); if (insdoc.ExecuteNonQuery() == 1) { msg.WriteSuccess(); this.Close(); AdminMainForm amf = new AdminMainForm(); amf.Show(); conn.Close(); } else { msg.WriteError(); conn.Close(); } } else { msg.DataError("ИИН уже существует в системе!"); conn.Close(); } } else { msg.DataError("Электронный адрес уже существует в системе!"); conn.Close(); } } }
private async void ButtonSend_Click(object sender, RoutedEventArgs e) { if (TextFrom.Text.Trim().Length == 0) { MessageDialog dlg = new MessageDialog("Please input from address!"); await dlg.ShowAsync(); TextFrom.Text = ""; TextFrom.Focus(FocusState.Programmatic); return; } if (TextTo.Text.Trim().Length == 0 && TextCc.Text.Trim().Length == 0) { MessageDialog dlg = new MessageDialog("Please input a recipient at least!"); await dlg.ShowAsync(); TextTo.Text = ""; TextCc.Text = ""; TextTo.Focus(FocusState.Programmatic); return; } if (TextServer.Text.Trim().Length == 0) { MessageDialog dlg = new MessageDialog("Please input server address!"); await dlg.ShowAsync(); TextServer.Text = ""; TextServer.Focus(FocusState.Programmatic); return; } bool isAuthenticationRequired = CheckAuthentication.IsOn; if (isAuthenticationRequired) { if (TextUser.Text.Trim().Length == 0) { MessageDialog dlg = new MessageDialog("Please input user name!"); await dlg.ShowAsync(); TextUser.Text = ""; TextUser.Focus(FocusState.Programmatic); return; } if (TextPassword.Password.Trim().Length == 0) { MessageDialog dlg = new MessageDialog("Please input password!"); await dlg.ShowAsync(); TextPassword.Password = ""; TextPassword.Focus(FocusState.Programmatic); return; } } ButtonSend.IsEnabled = false; ProgressBarSending.Value = 0; ProgressBarSending.Visibility = Visibility.Visible; pageViewer.ChangeView(0, pageViewer.ScrollableHeight, 1); this.Focus(FocusState.Programmatic); try { var smtp = new SmtpClient(); // add event handler smtp.Authorized += OnAuthorized; smtp.Connected += OnConnected; smtp.Securing += OnSecuring; smtp.SendingDataStream += OnSendingDataStream; var server = new SmtpServer(TextServer.Text); int[] ports = { 25, 587, 465 }; server.Port = ports[ListPorts.SelectedIndex]; bool useSslConnection = CheckSsl.IsOn; if (useSslConnection) { // use SSL/TLS based on server port server.ConnectType = SmtpConnectType.ConnectSSLAuto; } else { // Most mordern SMTP servers require SSL/TLS connection now // ConnectTryTLS means if server supports SSL/TLS connection, SSL/TLS is used automatically server.ConnectType = SmtpConnectType.ConnectTryTLS; } server.Protocol = (ServerProtocol)ListProtocols.SelectedIndex; if (isAuthenticationRequired) { server.User = TextUser.Text; server.Password = TextPassword.Password; } // For evaluation usage, please use "TryIt" as the license code, otherwise the // "Invalid License Code" exception will be thrown. However, the trial object only can be used // with developer license // For licensed usage, please use your license code instead of "TryIt", then the object // can used with published windows store application. var mail = new SmtpMail("TryIt"); mail.From = new MailAddress(TextFrom.Text); // If your Exchange Server is 2007 and used Exchange Web Service protocol, please add the following line; // oMail.Headers.RemoveKey("From"); mail.To = new AddressCollection(TextTo.Text); mail.Cc = new AddressCollection(TextCc.Text); mail.Subject = TextSubject.Text; if (!CheckHtml.IsOn) { mail.TextBody = TextEditor.Text; } else { string html = await HtmlEditor.InvokeScriptAsync("getHtml", null); html = "<html><head><meta charset=\"utf-8\" /></head><body style=\"font-family:Calibri;font-size: 15px;\">" + html + "<body></html>"; await mail.ImportHtmlAsync(html, Windows.ApplicationModel.Package.Current.InstalledLocation.Path, ImportHtmlBodyOptions.ErrorThrowException | ImportHtmlBodyOptions.ImportLocalPictures | ImportHtmlBodyOptions.ImportHttpPictures | ImportHtmlBodyOptions.ImportCss); } int count = _attachments.Count; for (int i = 0; i < count; i++) { await mail.AddAttachmentAsync(_attachments[i]); } ButtonCancel.IsEnabled = true; TextStatus.Text = string.Format("Connecting {0} ...", server.Server); // You can genereate a log file by the following code. // smtp.LogFileName = "ms-appdata:///local/smtp.txt"; _asyncCall = smtp.SendMailAsync(server, mail); await _asyncCall; TextStatus.Text = "Completed"; } catch (Exception ep) { TextStatus.Text = "Error: " + ep.Message.TrimEnd("\r\n".ToArray()); } ProgressBarSending.Visibility = Visibility.Collapsed; _asyncCall = null; ButtonSend.IsEnabled = true; ButtonCancel.IsEnabled = false; }
private void WindowLoadedHandler(object sender, RoutedEventArgs e) { TextPassword.Focus(); }
private void CreateNewPerson(object sender, EventArgs e) { Messages msg = new Messages(); if (TextLastName.Text == "") { msg.DataError("Введите фамилию!"); TextLastName.Focus(); } else if (TextFirstName.Text == "") { msg.DataError("Введите имя!"); TextFirstName.Focus(); } else if (SexSet.Text == "") { msg.DataError("Выберите пол!"); SexSet.Focus(); } else if (TextIIN.Text.Length != 12) { msg.DataError("Введите корректный ИИН!"); TextIIN.Focus(); } else if (TextEmail.Text == "") { msg.DataError("Введите адрес электронной почты!"); TextEmail.Focus(); } else if (TextPhone.Text == "") { msg.DataError("Введите номер телефона!"); TextPhone.Focus(); } else if (TextPassword.Text == "") { msg.DataError("Введите пароль!"); TextPassword.Focus(); } else if (TextPassword.Text != TextRepPassword.Text) { msg.DataError("Пароли не совпадают!"); TextPassword.Focus(); } else { conn.Open(); sqlins = "INSERT INTO PERSON (PERSON_LASTNAME, " + "PERSON_FIRSTNAME, " + "PERSON_PATRONYMIC, " + "PERSON_BIRTHDAY, " + "PERSON_IIN, " + "PERSON_PASSWORD, " + "PERSON_EMAIL, " + "PERSON_SEX, " + "PERSON_PHONE) " + "VALUES ('" + TextLastName.Text + "', " + "'" + TextFirstName.Text + "', " + "'" + TextPatronymic.Text + "', " + "'" + this.BirthdaySet.Text + "', " + "'" + TextIIN.Text + "', " + "'" + TextPassword.Text + "', " + "'" + TextEmail.Text + "', " + "'" + SexSet.Text + "'," + "'" + TextPhone.Text + "')"; sql = "SELECT COUNT(*) FROM PERSON WHERE PERSON_EMAIL = '" + TextEmail.Text + "'"; MySqlCommand checkEmail = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(checkEmail.ExecuteScalar()); if (COUNT == 0) { sql = "SELECT COUNT(*) FROM PERSON WHERE PERSON_IIN = '" + TextIIN.Text + "'"; MySqlCommand checkIIN = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(checkIIN.ExecuteScalar()); if (COUNT == 0) { MySqlCommand cmd = new MySqlCommand(sqlins, conn); if (cmd.ExecuteNonQuery() == 1) { msg.WriteSuccess(); this.Close(); AdminMainForm amf = new AdminMainForm(); amf.Show(); conn.Close(); } else { msg.WriteError(); conn.Close(); } } else { msg.DataError("Номер документа уже существует в системе!"); conn.Close(); COUNT = 0; } } } }