コード例 #1
0
 partial void DeleteUserActivity(UserActivity instance);
コード例 #2
0
        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);
            }
        }
コード例 #3
0
 partial void UpdateUserActivity(UserActivity instance);
コード例 #4
0
 partial void InsertUserActivity(UserActivity instance);
コード例 #5
0
 private void detach_UserActivities(UserActivity entity)
 {
     this.SendPropertyChanging();
     entity.User = null;
 }
コード例 #6
0
 private void attach_UserActivities(UserActivity entity)
 {
     this.SendPropertyChanging();
     entity.User = this;
 }
コード例 #7
0
 public NoLogoutDetected(UserActivity ua)
 {
     InitializeComponent();
     this.ua = ua;
 }