void LoginUser(string username)
        {
            Session session = null;
            User    user    = new UsersController().Show(username);

            if (user == null)
            {
                MessageBox.Show("User not found!", "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Session lastSession = new SessionsController().GetLastLoginByUser(user);

            if (lastSession != null)
            {
                if (!lastSession.hasEndedProperly())
                {
                    DialogResult result = MessageBox.Show("Last session did not end properly, Do you want to continue with your last session?", "Unended Session Detected", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                    if (result == DialogResult.Yes)
                    {
                        session = lastSession;
                    }
                }
            }

            if (session == null)
            {
                session = new Session(user);
            }
            if (session == null)
            {
                MessageBox.Show("Session not found!", "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            session.user     = user;
            usernameTxt.Text = "";
            passwordTxt.Text = "";
            frmDashboard dashboard = new frmDashboard();

            dashboard.Show();
            dashboard.WindowState  = FormWindowState.Maximized;
            dashboard.FormClosing += new FormClosingEventHandler(this.LoggedOut);
            this.Visible           = false;
        }
Example #2
0
        public Giving(DataRow r)
        {
            try
            {
                MembersController  mc   = new MembersController();
                ServicesController sc   = new ServicesController();
                SessionsController sesC = new SessionsController();
                this.id         = Convert.ToInt32(r["givingId"]);
                this.member     = mc.Show(Convert.ToInt32(r["memberId"]));
                this.givingDate = Convert.ToDateTime(r["givingDate"]);
                this.entryDate  = Convert.ToDateTime(r["entryDate"]);
                this.service    = sc.Show(Convert.ToInt32(r["serviceId"]));

                this.session = sesC.Show(Convert.ToInt32(r["sessionId"]));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }