예제 #1
0
 private void RecoveryPassword_FormClosing(object sender, FormClosingEventArgs e)
 {
     Hide();
     var frm = new frmLogin();
     frm.txtUserName.Text = string.Empty;
     frm.txtPassword.Text = string.Empty;
     frm.txtUserName.Focus();
     frm.Show();
 }
예제 #2
0
        private void Button1_Click(object sender, EventArgs e)
        {
            if (txtEmail.Text == string.Empty)
            {
                MessageBox.Show("ระบุอีเมล์", "ล้มเหลว", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEmail.Focus();
                return;
            }
            try
            {
                Cursor = Cursors.WaitCursor;
                timer1.Enabled = true;
                var ds = new DataSet();
                var con = new OleDbConnection(cs);
                con.Open();
                var cmd = new OleDbCommand("SELECT User_Password FROM Registration Where Email = '" + txtEmail.Text + "'", con);

                var da = new OleDbDataAdapter(cmd);
                da.Fill(ds);
                con.Close();
                if (ds.Tables[0].Rows.Count > 0)
                {
                    var Msg = new MailMessage();

                    Msg.From = new MailAddress("*****@*****.**");

                    Msg.To.Add(txtEmail.Text);
                    Msg.Subject = "ข้อมูลรหัสผ่านของคุณ";
                    Msg.Body = "รหัสผ่านของคุณ: " + Convert.ToString(ds.Tables[0].Rows[0]["user_Password"]) + string.Empty;
                    Msg.IsBodyHtml = true;

                    var smtp = new SmtpClient();
                    smtp.Host = "smtp.gmail.com";
                    smtp.Port = 587;
                    smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "abcd");
                    smtp.EnableSsl = true;
                    smtp.Send(Msg);
                    MessageBox.Show(("รหัสผ่านได้ถูกส่งไปที่อีเมล์คุณแล้ว " + ("\r\n" + "กรุณาตรวจสอบอีเมล์ของท่าน")), "ขอบคุณ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Hide();
                    var LoginForm1 = new frmLogin();
                    LoginForm1.Show();
                    LoginForm1.txtUserName.Text = string.Empty;
                    LoginForm1.txtPassword.Text = string.Empty;
                    LoginForm1.ProgressBar1.Visible = false;
                    LoginForm1.txtUserName.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ล้มเหลว", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
파일: frmSplash.cs 프로젝트: epiczeth/SAIS
        private void timer1_Tick(object sender, EventArgs e)
        {
            var frm = new frmLogin();
            progressBar1.Visible = true;

            progressBar1.Value = progressBar1.Value + 2;
            if (progressBar1.Value == 10)
            {
                label3.Text = "กำลังอ่านโมดูล..";
            }
            else
            {
                if (progressBar1.Value == 20)
                {
                    label3.Text = "กำลังเปิดโมดูล..";
                }
                else
                {
                    if (progressBar1.Value == 40)
                    {
                        label3.Text = "กำลังเริ่มการทำงานโมดูล..";
                    }
                    else
                    {
                        if (progressBar1.Value == 60)
                        {
                            label3.Text = "กำลังโหลดโมดูล..";
                        }
                        else
                        {
                            if (progressBar1.Value == 80)
                            {
                                label3.Text = "โหลดโมดูลสำเร็จ.";
                            }
                            else
                            {
                                if (progressBar1.Value == 100)
                                {
                                    frm.Show();
                                    timer1.Enabled = false;
                                    Hide();
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
 private void logOutToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Hide();
     var frm = new frmLogin();
     frm.Show();
     frm.txtUserName.Text = string.Empty;
     frm.txtPassword.Text = string.Empty;
     frm.ProgressBar1.Visible = false;
     frm.txtUserName.Focus();
 }
예제 #5
0
        private void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                var RowsAffected = 0;
                if ((txtUserName.Text.Trim().Length == 0))
                {
                    MessageBox.Show("กรุณาระบุชื่อผู้ใช้", "ล้มเหลว", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtUserName.Focus();
                    return;
                }
                if ((txtOldPassword.Text.Trim().Length == 0))
                {
                    MessageBox.Show("กรุณาระบุรหัสผ่านเก่า", "ล้มเหลว", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtOldPassword.Focus();
                    return;
                }
                if ((txtNewPassword.Text.Trim().Length == 0))
                {
                    MessageBox.Show("กรุณาระบุรหัสผ่านใหม่", "ล้มเหลว", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtNewPassword.Focus();
                    return;
                }
                if ((txtConfirmPassword.Text.Trim().Length == 0))
                {
                    MessageBox.Show("กรุณาระบุรหัสผ่านใหม่อีกครั้ง", "ล้มเหลว", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtConfirmPassword.Focus();
                    return;
                }
                if ((txtNewPassword.TextLength < 5))
                {
                    MessageBox.Show("รหัสผ่านใหม่ต้องมีความยาม 5 ตัวอักษรขึ้นไป", "ล้มเหลว", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtNewPassword.Text = string.Empty;
                    txtConfirmPassword.Text = string.Empty;
                    txtNewPassword.Focus();
                    return;
                }
                else
                {
                    if ((txtNewPassword.Text != txtConfirmPassword.Text))
                    {
                        MessageBox.Show("รหัสผ่านไม่ตรงกัน", "ล้มเหลว", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtNewPassword.Text = string.Empty;
                        txtOldPassword.Text = string.Empty;
                        txtConfirmPassword.Text = string.Empty;
                        txtOldPassword.Focus();
                        return;
                    }
                    else
                    {
                        if ((txtOldPassword.Text == txtNewPassword.Text))
                        {
                            MessageBox.Show("รหัสผ่านใหม่และเก่าเหมือนกัน", "ล้มเหลว", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtNewPassword.Text = string.Empty;
                            txtConfirmPassword.Text = string.Empty;
                            txtNewPassword.Focus();
                            return;
                        }
                    }
                }
                con = new OleDbConnection(cs);
                con.Open();
                var co = "Update Users set User_Password = '******'where UserName='******' and user_Password = '******'";

                cmd = new OleDbCommand(co);
                cmd.Connection = con;
                RowsAffected = cmd.ExecuteNonQuery();
                if ((RowsAffected > 0))
                {
                    MessageBox.Show("เปลี่ยนสำเร็จ", "รหัสผ่าน", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Hide();
                    txtUserName.Text = string.Empty;
                    txtNewPassword.Text = string.Empty;
                    txtOldPassword.Text = string.Empty;
                    txtConfirmPassword.Text = string.Empty;
                    var LoginForm1 = new frmLogin();
                    LoginForm1.Show();
                    LoginForm1.txtUserName.Text = string.Empty;
                    LoginForm1.txtPassword.Text = string.Empty;
                    LoginForm1.ProgressBar1.Visible = false;
                    LoginForm1.txtUserName.Focus();
                }
                else
                {
                    MessageBox.Show("invalid user name or password", "ล้มเหลว", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtUserName.Text = string.Empty;
                    txtNewPassword.Text = string.Empty;
                    txtOldPassword.Text = string.Empty;
                    txtConfirmPassword.Text = string.Empty;
                    txtUserName.Focus();
                }
                if ((con.State == ConnectionState.Open))
                {
                    con.Close();
                }
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ล้มเหลว", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #6
0
 private void ChangePassword_FormClosing(object sender, FormClosingEventArgs e)
 {
     Hide();
     var frm = new frmLogin();
     frm.txtUserName.Text = string.Empty;
     frm.txtPassword.Text = string.Empty;
     frm.ProgressBar1.Visible = false;
     frm.txtUserName.Focus();
     frm.Show();
 }