Ejemplo n.º 1
0
 public frmAdmin()
 {
     dbh = new DatabaseHandler();
     table = new DataTable();
     this.ControlBox = false;
     InitializeComponent();
 }
Ejemplo n.º 2
0
 public frmLogin()
 {
     InitializeComponent();
     dbh = new DatabaseHandler();
     frmAdmin = new frmAdmin();
     //frmPlayer = new frmPlayer(frmRanking);
 }
Ejemplo n.º 3
0
 public frmRanking()
 {
     this.ControlBox = false;
     dbh = new DatabaseHandler();
     InitializeComponent();
     SetListColumnWidth();
     ShowScore();
 }
Ejemplo n.º 4
0
        //List<TextBox> txtBoxList;
        public frmPlayer(Form frm, string un, Form frmlog, int userId)
        {
            this.ControlBox = false;
            frmRanking = frm;
            frmlogin = frmlog;
            dbh = new DatabaseHandler();
            userID = userId;

            InitializeComponent();
            if (DisableEditButton())
            {
                btnEditPrediction.Enabled = false;
            }
            ShowResults();
            ShowScoreCard();
            this.Text = "Welcome " + un;
        }
Ejemplo n.º 5
0
        public frmGames()

        {
            dbh = new DatabaseHandler();
            InitializeComponent();
        }
Ejemplo n.º 6
0
        public frmPlayer(Form frm, string un)
        {
            // This is letting the user to see the preditions, result and scorecard. We need an dbh to excute sqls.

            int amount = dbh.DTInt("SELECT COUNT(*) FROM TblGames");

            rowLeft  = new NumericUpDown[amount];
            rowRight = new NumericUpDown[amount];

            this.ControlBox = false;

            frmRanking = frm;

            this.counter--;

            dbh = new DatabaseHandler();

            InitializeComponent();

            // Disables buttons if its passed it expire date.

            if (DisableEditButton())
            {
                btnClearPrediction.Enabled = false;
                btnSaveButton.Enabled      = false;
            }

            this.Text = un;

            // Checks if some preditions already has been saved.

            DataTable tblUsers = dbh.FillDT("SELECT * FROM TblUsers WHERE (Username='******')");

            dbh.TestConnection();
            dbh.OpenConnectionToDB();

            using (SqlCommand cmd = new SqlCommand("SELECT id FROM TblUsers WHERE Username =  @Username", dbh.GetCon()))
            {
                cmd.Parameters.AddWithValue("Username", this.Text);

                string sql = Convert.ToString(cmd.ExecuteScalar());

                int.TryParse(sql, out this.resultId);
            }

            int userId = resultId;

            using (SqlCommand cmd = new SqlCommand("SELECT COUNT(*) FROM [tblPredictions] WHERE User_id = @User_id AND Saved = 1", dbh.GetCon()))
            {
                cmd.Parameters.AddWithValue("User_id", userId);
                saved = (int)cmd.ExecuteScalar() > 0;
            }

            dbh.CloseConnectionToDB();

            if (saved)
            {
                btnSaveButton.Enabled = false;
            }
            else
            {
                btnClearPrediction.Enabled = false;
            }

            ShowResults();
            ShowScoreCard();
            ShowPredictions(userId);
        }