private void cmb_MemberNumber_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmb_MemberNumber.Text != "")
            {
                string strMemberNumber = cmb_MemberNumber.Text;

                SqlConnection SQL = SQL_Commands.Connect();
                SQL.Open();
                using (SQL)
                {
                    SqlCommand    SQLCommand = new SqlCommand("SELECT DISTINCT First_Name, Last_Name, Hometown FROM tbl_Driver WHERE Member_Number = '" + strMemberNumber + "'", SQL);
                    SqlDataReader SQLReader  = SQLCommand.ExecuteReader();

                    {
                        while (SQLReader.Read())
                        {
                            cmb_FirstName.Text = SQLReader.GetString(0);
                            cmb_LastName.Text  = SQLReader.GetString(1);
                            cmb_Hometown.Text  = SQLReader.GetString(2);
                        }
                        SQLReader.Close();
                    }
                }
                SQL.Close();
            }
        }
예제 #2
0
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            if (Resources.Confirm_Delete() == false)
            {
                return;
            }

            //Delete row
            SqlConnection SQL = SQL_Commands.Connect();

            SQL.Open();
            using (SQL)
            {
                foreach (DataGridViewRow tempRow in dgv_TimeEntry.SelectedRows)
                {
                    using (var transaction = SQL.BeginTransaction())
                    {
                        try
                        {
                            int intID;
                            intID = Convert.ToInt32(tempRow.Cells[0].Value);

                            string strQuery = "DELETE FROM tbl_Time WHERE Time_ID = @ID";

                            SqlCommand Command = new SqlCommand(strQuery, SQL, transaction);
                            Command.Parameters.AddWithValue("@ID", intID);
                            Command.ExecuteNonQuery();
                            transaction.Commit();
                        }
                        catch (Exception exception)
                        {
                            MessageBox.Show(exception.ToString());
                            transaction.Rollback();
                        }
                    }
                }
            }
            SQL.Close();

            //Update Stages Completed
            SQL_Commands.Timing.Controls.Stages_Completed(dgv_Stages_Completed);

            //Update Time Datagrid
            SQL_Commands.Timing.Controls.Stage_Times(dgv_TimeEntry);

            //Update Class Results
            Reports.ExportClassResults();

            //Export Query to Wordpress
            Reports.UploadClassResults();
            Reports.UploadOverallResults();
            Reports.UploadStages();

            //Export Overall Stages
            Reports.ExportStages();

            //Upload Results to FTP
            FTP_Commands.FTP_Upload_Recent_Stages();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection SQL = SQL_Commands.Connect();

            SQL.Open();
            using (SQL)
            {
                List <Timing_Data> lst_TD = SQL_Commands.Timing.Get.DNF(SQL);

                SQL_Commands.Timing.Set.DNF(lst_TD, SQL);
            }
            SQL.Close();
        }
        private void btn_Update_Click(object sender, EventArgs e)
        {
            SqlConnection SQL = SQL_Commands.Connect();

            SQL.Open();
            using (SQL)
            {
                foreach (DataGridViewRow tempRow in dgv_Drivers.Rows)
                {
                    if (tempRow.IsNewRow == false)
                    {
                        int    intID           = Convert.ToInt32(tempRow.Cells[0].Value);
                        string strLast         = tempRow.Cells[1].Value.ToString();
                        string strFirst        = tempRow.Cells[2].Value.ToString();
                        string strMemberNumber = tempRow.Cells[3].Value.ToString();
                        string strHometown     = tempRow.Cells[4].Value.ToString();
                        string strEmail        = tempRow.Cells[5].Value.ToString();


                        using (var dbTransaction = SQL.BeginTransaction())
                        {
                            try
                            {
                                string strQuery = "UPDATE tbl_Driver " +
                                                  "SET Last_Name = @LN, First_Name = @FN, Member_Number = @MN, Hometown = @H, Email = @E " +
                                                  "WHERE Driver_ID = @T";
                                SqlCommand dbCommand = new SqlCommand(strQuery, SQL, dbTransaction);
                                dbCommand.Parameters.AddWithValue("@T", intID);
                                dbCommand.Parameters.AddWithValue("@LN", strLast);
                                dbCommand.Parameters.AddWithValue("@FN", strFirst);
                                dbCommand.Parameters.AddWithValue("@MN", strMemberNumber);
                                dbCommand.Parameters.AddWithValue("@H", strHometown);
                                dbCommand.Parameters.AddWithValue("@E", strEmail);
                                dbCommand.ExecuteNonQuery();
                                dbTransaction.Commit();
                            }
                            catch (Exception exception)
                            {
                                dbTransaction.Rollback();
                                MessageBox.Show(exception.ToString());
                            }
                        }
                    }
                }
            }
            SQL.Close();

            SQL_Commands.Drivers.Controls.Update_DataGridView(dgv_Drivers);
        }
        public frm_Main_Menu()
        {
            InitializeComponent();


            if (SQL_Commands.IsServerConnected() == false)
            {
                MessageBox.Show("SQL Server is not currently online." + Environment.NewLine + "All data will be locally cached until server returns online.");
                tslbl_SQLStatus.BackColor = Color.OrangeRed;
            }
            else
            {
                tslbl_SQLStatus.BackColor = Color.Green;
            }
        }
        private void btn_Remove_Click(object sender, EventArgs e)
        {
            //Cancel Delete if selected as NO
            if (Resources.Confirm_Delete() == false)
            {
                return;
            }

            //Delete row
            SqlConnection SQL = SQL_Commands.Connect();

            SQL.Open();
            using (SQL)
            {
                using (var transaction = SQL.BeginTransaction())
                {
                    foreach (DataGridViewRow tempRow in dgv_Registration.SelectedRows)
                    {
                        try
                        {
                            int intRegistrationID;
                            intRegistrationID = Convert.ToInt32(tempRow.Cells[0].Value);

                            string strQuery = "DELETE FROM tbl_Registration WHERE Registration_ID = @ID";

                            SqlCommand Command = new SqlCommand(strQuery, SQL, transaction);
                            Command.Parameters.AddWithValue("@ID", intRegistrationID);
                            Command.ExecuteNonQuery();
                        }
                        catch (Exception exception)
                        {
                            MessageBox.Show(exception.ToString());
                            transaction.Rollback();
                            SQL.Close();
                            return;
                        }
                    }
                    transaction.Commit();
                }
            }
            SQL.Close();

            SQL_Commands.Registration.Update.Registration(dgv_Registration);
            SQL_Commands.Registration.Get.Registration(dgv_Registration);
            Reports.ExportRegistration();
            Reports.ExportDriverReport();
            Reports.UploadDriverReport();
        }
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            if (Resources.Confirm_Delete() == false)
            {
                return;
            }

            //Delete row
            SqlConnection SQL = SQL_Commands.Connect();

            SQL.Open();
            using (SQL)
            {
                foreach (DataGridViewRow tempRow in dgv_Drivers.SelectedRows)
                {
                    using (var transaction = SQL.BeginTransaction())
                    {
                        try
                        {
                            int intID;
                            intID = Convert.ToInt32(tempRow.Cells[0].Value);

                            string strQuery = "DELETE FROM tbl_Driver WHERE Driver_ID = @ID";

                            SqlCommand Command = new SqlCommand(strQuery, SQL, transaction);
                            Command.Parameters.AddWithValue("@ID", intID);
                            Command.ExecuteNonQuery();
                            transaction.Commit();
                        }
                        catch (Exception exception)
                        {
                            MessageBox.Show(exception.ToString());
                            transaction.Rollback();
                        }
                    }
                }
            }
            SQL.Close();

            SQL_Commands.Drivers.Controls.Update_DataGridView(dgv_Drivers);
        }
예제 #8
0
        private int Get_Venue_ID(string Venue)
        {
            int           tempID = 0;
            SqlConnection SQL    = SQL_Commands.Connect();

            SQL.Open();
            using (SQL)
            {
                SqlCommand    Command;
                SqlDataReader Reader;
                Command = new SqlCommand("SELECT DISTINCT Venue_ID FROM tbl_Venue WHERE Name = '" + Venue + "'", SQL);
                Reader  = Command.ExecuteReader();
                while (Reader.Read())
                {
                    tempID = Reader.GetInt32(0);
                }
                Reader.Close();
            }

            return(tempID);
        }
예제 #9
0
        private void btn_Create_Click(object sender, EventArgs e)
        {
            string   str_EventNumber = txt_Number.Text;
            int      int_VenueID     = Get_Venue_ID(cmb_Venue.Text);
            string   str_EventName   = txt_Name.Text;
            DateTime dt_Date         = Convert.ToDateTime(dt_Event_Date.Text);

            SqlConnection SQL = SQL_Commands.Connect();

            SQL.Open();
            using (var Transaction = SQL.BeginTransaction())
            {
                try
                {
                    String Query = "INSERT INTO tbl_Event " +
                                   "(Number,Name,Date,Status,Venue_ID) " +
                                   "VALUES (@Num,@N,@D,@S,@V)";
                    SqlCommand Command = new SqlCommand(Query, SQL, Transaction);
                    Command.Parameters.AddWithValue("@Num", str_EventNumber);
                    Command.Parameters.AddWithValue("@N", str_EventName);
                    Command.Parameters.AddWithValue("@D", dt_Date);
                    Command.Parameters.AddWithValue("@S", false);
                    Command.Parameters.AddWithValue("@V", int_VenueID);
                    Command.ExecuteNonQuery();
                    Transaction.Commit();
                }
                catch (Exception excepted)
                {
                    MessageBox.Show(excepted.ToString());
                    Transaction.Rollback();
                }
            }
            SQL.Close();

            //Clear Form After Event Created
            MessageBox.Show("Event Created Sucessfully");
            cmb_Venue.SelectedIndex = -1;
            txt_Name.Text           = "";
            txt_Number.Text         = "";
        }
예제 #10
0
        private void Update_Venues()
        {
            SqlConnection SQL = SQL_Commands.Connect();

            SQL.Open();
            using (SQL)
            {
                List <string> lst_Temp = new List <string>();
                SqlCommand    Command;
                SqlDataReader Reader;
                Command = new SqlCommand("SELECT DISTINCT Name FROM tbl_Venue", SQL);
                Reader  = Command.ExecuteReader();
                while (Reader.Read())
                {
                    lst_Temp.Add(Reader.GetString(0));
                }
                Reader.Close();

                lst_Temp.Sort();
                cmb_Venue.DataSource = lst_Temp.ToArray();
                cmb_Venue.Update();
            }
        }
예제 #11
0
        private void btn_Update_Click(object sender, EventArgs e)
        {
            SqlConnection SQL = SQL_Commands.Connect();

            SQL.Open();
            using (SQL)
            {
                foreach (DataGridViewRow tempRow in dgv_TimeEntry.Rows)
                {
                    int     intTimeID    = Convert.ToInt32(tempRow.Cells[0].Value);
                    int     intStage     = Convert.ToInt32(tempRow.Cells[4].Value);
                    decimal decStageTime = Convert.ToDecimal(tempRow.Cells[5].Value);
                    int     intCones     = Convert.ToInt32(tempRow.Cells[6].Value);
                    int     intGates     = Convert.ToInt32(tempRow.Cells[7].Value);
                    bool    Off_Course   = Convert.ToBoolean(tempRow.Cells[8].Value);
                    decimal decTotalTime = Resources.Caluclate_FinishTime(decStageTime, intCones, intGates, Off_Course);

                    using (var dbTransaction = SQL.BeginTransaction())
                    {
                        try
                        {
                            string strQuery = "UPDATE tbl_Time " +
                                              "SET Stage_Number = @SN, Stage_Time = @ST, Cones_Hit = @C, Gates_Missed = @G, Off_Course = @OC, Total_Time = @TT " +
                                              "WHERE Time_ID = @T";
                            SqlCommand dbCommand = new SqlCommand(strQuery, SQL, dbTransaction);
                            dbCommand.Parameters.AddWithValue("@SN", intStage);
                            dbCommand.Parameters.AddWithValue("@ST", decStageTime);
                            dbCommand.Parameters.AddWithValue("@C", intCones);
                            dbCommand.Parameters.AddWithValue("@G", intGates);
                            dbCommand.Parameters.AddWithValue("@OC", Off_Course);
                            dbCommand.Parameters.AddWithValue("@TT", decTotalTime);
                            dbCommand.Parameters.AddWithValue("@T", intTimeID);
                            dbCommand.ExecuteNonQuery();
                            dbTransaction.Commit();
                        }
                        catch (Exception exception)
                        {
                            dbTransaction.Rollback();
                            MessageBox.Show(exception.ToString());
                        }
                    }
                }
            }
            SQL.Close();

            //Update Stages Completed
            SQL_Commands.Timing.Controls.Stages_Completed(dgv_Stages_Completed);

            //Update Time Datagrid
            SQL_Commands.Timing.Controls.Stage_Times(dgv_TimeEntry);

            //Export Query to Wordpress
            Reports.UploadClassResults();
            Reports.UploadOverallResults();
            Reports.UploadStages();

            //Export Overall Stages
            Reports.ExportStages();

            //Upload Results to FTP
            FTP_Commands.FTP_Upload_Recent_Stages();
        }
        private void btn_Submit_Click(object sender, EventArgs e)
        {
            //Verify All Fields Have Data
            if (CheckSwitches() == false)
            {
                return;
            }

            //Define Variables required
            double dblEvent          = Convert.ToDouble(cmb_Event.Text);
            double dblPaymentAmount  = Convert.ToDouble(txt_PaymentAmount.Text);
            int    intEventID        = 0;
            int    intDriverID       = 0;
            int    intNumberID       = 0;
            int    intVehicleID      = 0;
            int    intClassID        = 0;
            int    intVehicleNumber  = Convert.ToInt32(txt_VehicleNumber.Text);
            int    intYear           = Convert.ToInt32(cmb_Year.Text);
            string strFirstName      = cmb_FirstName.Text;
            string strLastName       = cmb_LastName.Text;
            string strHometown       = cmb_Hometown.Text;
            string strMemberNumber   = cmb_MemberNumber.Text;
            string strClass          = cmb_Class.Text;
            string strMake           = cmb_Make.Text;
            string strModel          = cmb_Model.Text;
            string strPaymentType    = cmb_PaymentType.Text;
            bool   blPaymentReceived = Convert.ToBoolean(cmb_PaymentReceived.Text);
            bool   blCheckedIn       = Convert.ToBoolean(cmb_CheckedIn.Text);

            //Update Current Registration Data
            SQL_Commands.Registration.Update.Registration(dgv_Registration);

            //Insert New Drivers
            SqlConnection SQL = SQL_Commands.Connect();

            SQL.Open();
            using (SQL)
            {
                //Get Event_ID
                intEventID = SQL_Commands.Registration.Get.Event(dblEvent, SQL);

                //Get Driver_ID
                intDriverID = SQL_Commands.Registration.Get.Driver(strLastName, strFirstName, SQL);
                if (intDriverID == 0)
                {
                    SQL_Commands.Registration.Create.Driver(strLastName, strFirstName, strMemberNumber, strHometown, SQL);
                    intDriverID = SQL_Commands.Registration.Get.Driver(strLastName, strFirstName, SQL);
                }

                //Get Number ID
                intNumberID = SQL_Commands.Registration.Get.Number(intVehicleNumber, SQL);
                if (intNumberID == 0)
                {
                    SQL_Commands.Registration.Create.Number(intVehicleNumber, SQL);
                    intNumberID = SQL_Commands.Registration.Get.Number(intVehicleNumber, SQL);
                }
                //Get Class ID
                intClassID = SQL_Commands.Registration.Get.Class(strClass, SQL);

                //Get Vehicle ID
                intVehicleID = SQL_Commands.Registration.Get.Vehicle(intYear, strMake, strModel, SQL);
                if (intVehicleID == 0)
                {
                    SQL_Commands.Registration.Create.Vehicle(intYear, strMake, strModel, SQL);
                    intVehicleID = SQL_Commands.Registration.Get.Vehicle(intYear, strMake, strModel, SQL);
                }

                //Check for Duplicates
                if (SQL_Commands.Registration.Find_Dup_Reg(intClassID, intNumberID, SQL) == true)
                {
                    MessageBox.Show("Duplicate Number/Class Combination. Please verify registration data.");
                    SQL.Close();
                    return;
                }
                if (SQL_Commands.Registration.Find_Dup_Driver(intDriverID, SQL) == true)
                {
                    MessageBox.Show("Driver is already registered. Please verify registration data.");
                    SQL.Close();
                    return;
                }

                SQL_Commands.Registration.Submit_Registration(intEventID, intDriverID, intClassID, intVehicleID, intNumberID, strPaymentType, dblPaymentAmount, blPaymentReceived, blCheckedIn, false, SQL);
            }
            SQL.Close();

            SQL_Commands.Registration.Get.Registration(dgv_Registration);
            Reports.ExportRegistration();
            Reports.ExportDriverReport();
            Reports.UploadDriverReport();

            Clear_Form();
        }