partial void DeleteUserActivity(UserActivity instance);
        private void button1_Click_1(object sender, EventArgs e)
        {
            if (!Validation(Container))
            {
                MessageBox.Show("All data must be filled");
                return;
            }

            db = new DataClasses1DataContext();

            if (nFault == 3)
            {
                MessageBox.Show($"You have entered 3 times incorrect account, please wait {second} seconds");
                label3.Text = $"{second} seconds left";
                timer1.Start();
                return;
            }

            var q = db.Users.Where(x => x.Email == textBox1.Text && x.Password == Hash(textBox2.Text)).FirstOrDefault();

            if (q == null)
            {
                MessageBox.Show("Username and password incorrect");
                nFault += 1;
                return;
            }


            if (!q.Active.Value)
            {
                MessageBox.Show("Your account has been disabled");
                return;
            }

            currentUser = q;
            formLogin   = this;

            UserActivity ua = new UserActivity()
            {
                UserID = currentUser.ID,
                Login  = DateTime.Now
            };

            currentUserActivity = ua;
            db.UserActivities.InsertOnSubmit(ua);
            db.SubmitChanges();


            var check = db.UserActivities.Where(x => x.UserID == currentUser.ID &&
                                                x.ID != currentUserActivity.ID
                                                ).OrderByDescending(x => x.Login).FirstOrDefault();

            if (check != null)
            {
                if (!check.Logout.HasValue)
                {
                    // No Logout Detected
                    NoLogoutDetected form = new NoLogoutDetected(check);
                    this.Hide();
                    form.Show();
                }
                else
                {
                    DoLogin(currentUser);
                }
            }
            else
            {
                DoLogin(currentUser);
            }
        }
 partial void UpdateUserActivity(UserActivity instance);
 partial void InsertUserActivity(UserActivity instance);
 private void detach_UserActivities(UserActivity entity)
 {
     this.SendPropertyChanging();
     entity.User = null;
 }
 private void attach_UserActivities(UserActivity entity)
 {
     this.SendPropertyChanging();
     entity.User = this;
 }
Пример #7
0
 public NoLogoutDetected(UserActivity ua)
 {
     InitializeComponent();
     this.ua = ua;
 }