示例#1
0
 private void RgsPasswordtb_Enter(object sender, EventArgs e)
 {
     try
     {
         if (RgsPasswordtb.Text == "admin")
         {
             RgsPasswordtb.Text = String.Empty;
         }
         var item = userContext.Users.SingleOrDefault(x => x.Email == RgsEmailtb.Text);
         if (item != null)
         {
             ErrorEmailLabel           = new Label();
             ErrorEmailLabel.Size      = new Size(230, 30);
             ErrorEmailLabel.Location  = new Point(280, 212);
             ErrorEmailLabel.Text      = $"{RgsEmailtb.Text} is already exist";
             ErrorEmailLabel.ForeColor = Color.Red;
             ErrorEmailLabel.Font      = new Font("Comic Sans MS", 8, FontStyle.Regular);
             this.Controls.Add(ErrorEmailLabel);
             RgsPasswordtb.Enabled = false;
         }
         else
         {
             if (ErrorEmailLabel != null)
             {
                 ErrorEmailLabel.Dispose();
             }
             RgsPasswordtb.Enabled = true;
         }
     }
     catch (Exception)
     {
     }
 }
示例#2
0
 private void LoginButton_Click(object sender, EventArgs e)
 {
     //Check in datebase and cross to EasyQuiz system . . .
     /////////load ProgramIntroduction
     try
     {
         if (regex.IsMatch(Emailtxb.Text))
         {
             var item1 = userContext.Users.SingleOrDefault(x => x.Email == Emailtxb.Text);
             Emailtxb.ForeColor = Color.Green;
             if (item1 != null)
             {
                 if (item1.Password == Passwordtxb.Text)
                 {
                     Passwordtxb.ForeColor = Color.Green;
                     for (int i = 0; i < 4; i++)
                     {
                         foreach (var item in this.Controls)
                         {
                             if (item is Label lb)
                             {
                                 lb.Dispose();
                             }
                             else if (item is Button bt)
                             {
                                 bt.Dispose();
                             }
                             else if (item is PictureBox pb)
                             {
                                 pb.Dispose();
                             }
                             else if (item is TextBox tb)
                             {
                                 tb.Dispose();
                             }
                             else if (item is Panel pn)
                             {
                                 pn.Dispose();
                             }
                         }
                     }
                     LoadProgramIntroduction();
                     form = new Form1();
                     Timer timer = new Timer();
                     timer.Interval = 1000;
                     timer.Tick    += Timer_Tick; timer.Start();
                     Timer timer2 = new Timer();
                     timer2.Interval = 100;
                     timer2.Tick    += Timer2_Tick;
                     timer2.Start();
                 }
                 else
                 {
                     Passwordtxb.ForeColor = Color.Red;//password is not correct
                     if (ErrorEmailLabel != null)
                     {
                         ErrorEmailLabel.Dispose();                              //MessageBox.Show("password is not correct");
                     }
                     ErrorPasswordLabel           = new Label();
                     ErrorPasswordLabel.Size      = new Size(230, 30);
                     ErrorPasswordLabel.Location  = new Point(250, 262);
                     ErrorPasswordLabel.Text      = "Password is not correct";
                     ErrorPasswordLabel.ForeColor = Color.Red;
                     ErrorPasswordLabel.Font      = new Font("Comic Sans Ms", 10, FontStyle.Regular);
                     this.Controls.Add(ErrorPasswordLabel);
                 }
             }
             else
             {
                 Emailtxb.ForeColor = Color.Red;//i did not find item but regex is correct . . .
                 //MessageBox.Show("I did not find item but regex is correct");
                 ErrorEmailLabel           = new Label();
                 ErrorEmailLabel.Size      = new Size(400, 30);
                 ErrorEmailLabel.Location  = new Point(250, 212);
                 ErrorEmailLabel.Text      = $"{Emailtxb.Text} didn't find write correct email or register.";
                 ErrorEmailLabel.ForeColor = Color.Red;
                 ErrorEmailLabel.Font      = new Font("Comic Sans MS", 8, FontStyle.Regular);
                 this.Controls.Add(ErrorEmailLabel);
             }
         }
         else
         {
             Emailtxb.ForeColor        = Color.Red;//regex is not correct
             ErrorEmailLabel           = new Label();
             ErrorEmailLabel.Size      = new Size(260, 30);
             ErrorEmailLabel.Location  = new Point(250, 212);
             ErrorEmailLabel.Text      = $"Email is not correct";
             ErrorEmailLabel.ForeColor = Color.Red;
             ErrorEmailLabel.Font      = new Font("Comic Sans MS", 9, FontStyle.Regular);
             this.Controls.Add(ErrorEmailLabel);
             //MessageBox.Show("Regex is not correct");
         }
     }
     catch (Exception)
     {
     }
 }