Exemple #1
0
        //ShootingTableTableAdapter taShootingTable = new ShootingTableTableAdapter();
        //List<ShootingInfo.ShootingTableRow> lstShootingTable = new List<ShootingInfo.ShootingTableRow>();
        public bool insert(ShootingData data)
        {
            int insertSuccess = 0;

            try
            {
                connectionObj.Open();
                string query = String.Format("INSERT INTO ShootRecord VALUES('" + data.TraineeId + "','" + data.BaNo + "','" + data.ShooterName + "','" + data.Now + "','" + data.Shots + "','" + data.Hits + "','" + data.AvgAccuracy + "','" + data.AvgGrouping + "','" + data.Refex + "','" + data.Summary + "','" + data.FileName + "')");
                commandObj    = new SqlCommand(query, connectionObj);
                insertSuccess = commandObj.ExecuteNonQuery();
                connectionObj.Close();
                if (insertSuccess > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error occured! data connection is not ready", e);
            }
            finally
            {
                connectionObj.Close();
            }
        }
Exemple #2
0
        public void SaveData(ShootingData data)
        {
            DatabaseIDU db = new DatabaseIDU();

            doneSave = db.insert(data);
            saveData = false;
        }
Exemple #3
0
        public List <ShootingData> GetShootingDataTrainee(string traineeId)
        {
            List <ShootingData> allData = new List <ShootingData>();

            try
            {
                connectionObj.Open();
                string query = String.Format("SELECT * FROM ShootRecord WHERE TraineeId = '" + traineeId + "'");
                commandObj = new SqlCommand(query, connectionObj);
                SqlDataReader readerObj = commandObj.ExecuteReader();
                while (readerObj.Read())
                {
                    ShootingData data = new ShootingData();
                    data.Id          = readerObj["id"].ToString();
                    data.TraineeId   = readerObj["TraineeId"].ToString();
                    data.BaNo        = readerObj["BaNo"].ToString();
                    data.ShooterName = readerObj["ShooterName"].ToString();
                    data.Now         = readerObj["DateTime"].ToString();
                    data.Shots       = readerObj["Shots"].ToString();
                    data.Hits        = readerObj["Hits"].ToString();
                    data.AvgAccuracy = readerObj["AvgAccuracy"].ToString();
                    data.AvgGrouping = readerObj["AvgGrouping"].ToString();
                    data.Refex       = readerObj["Refex"].ToString();
                    data.Summary     = readerObj["Summary"].ToString();
                    data.FileName    = readerObj["FileName"].ToString();
                    allData.Add(data);
                }
                readerObj.Close();
                connectionObj.Close();
            }
            catch (Exception e)
            {
                throw new Exception("Error occured data connection is not ready", e);
            }
            finally
            {
                connectionObj.Close();
            }
            return(allData);
        }
Exemple #4
0
        public void calculateAverage()
        {
            hitsLabel.Text  = ShootPointController.getController().shotAffected.ToString();
            shotsLabel.Text = ShootPointController.getController().shotTaken.ToString();

            int tempPoint = 0;

            for (int i = 0; i < shotPoint.Count; i++)
            {
                tempPoint = tempPoint + (int)shotPoint[i];
            }

            //MessageBox.Show("IN One " + ShootPointController.getController().shotPoint.Count.ToString());
            if (shotPoint.Count != 0)
            {
                tempPoint     /= shotPoint.Count;
                distLabel.Text = tempPoint.ToString();
                //MessageBox.Show("IN side");
            }

            //------------------------------------------
            groupLabel.Text = groupMaxDistance.ToString();
            //------------------------------------------

            float maxTime = 0;
            float minTime = 0;

            minTime = GAYABE_NUMBER * ShootPointController.getController().shotTaken;
            maxTime = 24 * ShootPointController.getController().shotTaken;

            float difference = maxTime - minTime;
            float avgTime    = 0;

            if (difference != 0)
            {
                float tempGayabe = (((float)totalTime) - (GAYABE_NUMBER * ShootPointController.getController().shotTaken));
                avgTime = tempGayabe * (ShootPointController.getController().shotTaken / difference);
            }
            int result = arannya(avgTime);


            totalTimeLabel.Text = result.ToString();


            //-----------------------
            //  Final Average Value
            //-----------------------

            float finalAverage = ((float)(tempPoint + groupMaxDistance + result)) / 2.50F;

            summury = (short)finalAverage;

            setImageInGraph(tempPoint, false, accImg);
            setImageInGraph(groupMaxDistance, false, grpImg);
            setImageInGraph(result, true, refImg);
            avgLabel.Text = finalAverage.ToString();
            setAverageImage(finalAverage);

            if (saveData)
            {
                if (File.Exists(Login.fileName + VideoProcess.fileNameEnd + "Log.txt"))
                {
                    File.Delete(Login.fileName + VideoProcess.fileNameEnd + "Log.txt");
                }
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(Login.fileName + VideoProcess.fileNameEnd + "Log.txt", true))
                {
                    file.WriteLine("Shooter name :" + Login.ShooterName);
                    file.WriteLine("Shots taken :" + ShootPointController.getController().shotTaken.ToString());
                    //file.WriteLine("Shots taken :"+shotsTaken.ToString());
                    file.WriteLine("Hits :" + hitsTergeted.ToString());
                    file.WriteLine("Average accuracy :" + avgAccuracy.ToString());
                    file.WriteLine("Average grouping :" + avgGrouping.ToString());
                    file.WriteLine("Reflex :" + reflex.ToString());
                    file.WriteLine("Summary :" + summury.ToString());
                }
                ShootingData data = new ShootingData();
                data.BaNo        = Login.BaNo;
                data.ShooterName = Login.ShooterName;
                data.TraineeId   = Login.TraineeId;
                data.Now         = DateTime.Now.ToString();
                //data.Shots = shotsTaken.ToString();
                data.Shots         = ShootPointController.getController().shotTaken.ToString();
                data.Hits          = hitsTergeted.ToString();
                data.AvgAccuracy   = avgAccuracy.ToString();
                data.AvgGrouping   = avgGrouping.ToString();
                data.Refex         = reflex.ToString();
                data.Summary       = summury.ToString();
                data.FileName      = VideoProcess.fileNameEnd;
                VideoProcess.count = 1;

                SaveData(data);
            }
            //DatabaseIDU didu = new DatabaseIDU();
            //int inserted = didu.insert(bano, name, datetime, shotsTaken, hitsTergeted, avgAccuracy, avgGrouping, reflex, summury);

            //if (inserted > 0)
            //{
            //    MessageBox.Show("Data has been saved successfully.");
            //}
            //else
            //{
            //    MessageBox.Show("Data cannot be saved right now,Please try again later.");
            //}
        }