コード例 #1
0
 private void txtMatkhau_Leave(object sender, EventArgs e)
 {
     if (txtMatkhau.Text != "")
     {
         if (Ctrl.CheckMK(txtMatkhau) == 1)
         {
             erp.SetError(txtMatkhau, "Mật khẩu phải chứa ít nhất 6 ký tự!");
             txtnhaplaimatkhau.Text = "";
         }
         else if (Ctrl.CheckMK(txtMatkhau) == 2)
         {
             erp.Clear();
             lblmatkhau.Text      = "Yếu!";
             lblmatkhau.ForeColor = Color.Gray;
         }
         else if (Ctrl.CheckMK(txtMatkhau) == 3)
         {
             erp.Clear();
             lblmatkhau.Text      = "Trung bình!";
             lblmatkhau.ForeColor = Color.YellowGreen;
         }
         else if (Ctrl.CheckMK(txtMatkhau) == 4)
         {
             erp.Clear();
             lblmatkhau.Text      = "Mạnh!";
             lblmatkhau.ForeColor = Color.Green;
         }
     }
     else
     {
         erp.SetError(txtMatkhau, "Mật khẩu không được để trống!");
         lblmatkhau.Text = "";
     }
 }
コード例 #2
0
 private void txtmkmoi_TextChanged(object sender, EventArgs e)
 {
     if (txtmkmoi.Text != "")
     {
         if (Ctrl.CheckMK(txtmkmoi) == 1)
         {
             erp.SetError(txtmkmoi, "Mật khẩu phải chứa ít nhất 6 ký tự!");
             txtnhaplaimk.Text    = "";
             txtnhaplaimk.Enabled = false;
             lblmatkhau.Text      = "";
             btnok.Enabled        = false;
         }
         else
         {
             if (txtmkcu.Text != txtmkmoi.Text)
             {
                 if (Ctrl.CheckMK(txtmkmoi) == 2)
                 {
                     erp.Clear();
                     lblmatkhau.Text      = "Yếu!";
                     lblmatkhau.ForeColor = Color.Gray;
                     txtnhaplaimk.Enabled = true;
                 }
                 else if (Ctrl.CheckMK(txtmkmoi) == 3)
                 {
                     erp.Clear();
                     lblmatkhau.Text      = "Trung bình!";
                     lblmatkhau.ForeColor = Color.YellowGreen;
                     txtnhaplaimk.Enabled = true;
                 }
                 else if (Ctrl.CheckMK(txtmkmoi) == 4)
                 {
                     erp.Clear();
                     lblmatkhau.Text      = "Mạnh!";
                     lblmatkhau.ForeColor = Color.Green;
                     txtnhaplaimk.Enabled = true;
                 }
             }
             else
             {
                 erp.SetError(txtmkmoi, "Mật khẩu mới không được trùng với mật khẩu cũ!");
                 txtnhaplaimk.Text    = "";
                 txtnhaplaimk.Enabled = false;
                 lblmatkhau.Text      = "";
                 btnok.Enabled        = false;
             }
         }
     }
     else
     {
         erp.SetError(txtmkmoi, "Mật khẩu mới không được để trống!");
         lblmatkhau.Text      = "";
         txtnhaplaimk.Enabled = false;
         txtnhaplaimk.Text    = "";
         btnok.Enabled        = false;
     }
 }