コード例 #1
0
ファイル: FillBlankForm.cs プロジェクト: ltk84/Vocabulary-Up
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            txtAnswer.Text = txtAnswer.Text.ToLower();
            userChoices[currentQuiz].CorrectAns = questions[currentQuiz].GetFlashCard().Eng;
            userChoices[currentQuiz].Correct    = 0;
            if (txtAnswer.Text != null && txtAnswer.Text.Length != 0)
            {
                bool isCorrect = true;
                if (txtAnswer.Text != questions[currentQuiz].GetFlashCard().Eng)
                {
                    lbWrong.Visible = true;
                    isCorrect       = false;
                    userChoices[currentQuiz].Selected = -1;
                }

                lbCorrectAnswer.Text            = questions[currentQuiz].GetFlashCard().Eng;
                lbCorrectAnswer.Visible         = true;
                userChoices[currentQuiz].IsDone = true;
                btnNext.Enabled = true;
                userChoices[currentQuiz].Answer = txtAnswer.Text;
                userChoices[currentQuiz].IsDone = true;
                txtAnswer.Enabled = false;

                if (isCorrect == true)
                {
                    FlashCard fl = questions[currentQuiz].GetFlashCard();
                    if (!ManageUserAction.IsFlashCardExist(0, fl.IdCard))
                    {
                        AddFlashCard(fl);
                    }
                    wrongAns--;
                    userChoices[currentQuiz].Selected = 0;
                }
            }
        }
コード例 #2
0
        public static List <FlashCard> UpdateFlashCardOfCollection(int idCollection)
        {
            List <FlashCard> flashCards = new List <FlashCard>();
            SqlConnection    connection = new SqlConnection(constr);

            try
            {
                connection.Open();

                //Chuan bi cau lenh query viet bang SQL
                String sqlQuery = "select id_card, eng, vie, pronunciation, field from USER_FLASHCARD, flashcard where USER_FLASHCARD.ID_CARD = FLASHCARD.ID and ID_USER = "******" and id_collection = " + idCollection.ToString();
                //Tao mot Sqlcommand de thuc hien cau lenh truy van da chuan bi voi ket noi hien tai
                SqlCommand command = new SqlCommand(sqlQuery, connection);

                //Thuc hien cau truy van va nhan ve mot doi tuong reader ho tro do du lieu
                SqlDataReader reader = command.ExecuteReader();

                //Su dung reader de doc tung dong du lieu va cho vao list allFlashCards
                while (reader.HasRows)
                {
                    if (reader.Read() == false)
                    {
                        break;
                    }
                    FlashCard f = new FlashCard(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4));

                    flashCards.Add(f);
                }
                return(flashCards);
            }
            finally
            {
                connection.Close();
            }
        }
コード例 #3
0
 public CollectionLib(CollectionForm collectionTab, int idCollection)
 {
     InitializeComponent();
     darkMode = ManageUserAction.GetDarkMode();
     //
     if (darkMode)
     {
         UpdateTheme();
     }
     //
     this.collectionTab = collectionTab;
     this.KeyPreview    = true;
     //
     index = 0;
     this.curCollection = ManageUserAction.GetItemOfAllCollection(idCollection);
     if (idCollection == 0)
     {
         btnRemoveFromCollection.Visible = false;
     }
     else
     {
         btnRemoveFromCollection.Visible = true;
     }
     lbCollectionName.Text = curCollection.NameCollection;
     curFlashCard          = curCollection.ListFL[index];
     ChangeFlashCard(curFlashCard.Eng, curFlashCard.IdCard);
     InitAutoCompleteTextBox();
 }
コード例 #4
0
        private void ReloadButton()
        {
            btnA.FillColor = primary;
            btnB.FillColor = primary;
            btnC.FillColor = primary;
            btnD.FillColor = primary;
            bool isCorrect = true;

            if (userChoices[currentQuiz].Selected != userChoices[currentQuiz].Correct)
            {
                isCorrect = false;
                switch (userChoices[currentQuiz].Selected)
                {
                case 1:
                    btnA.FillColor = Color.FromArgb(224, 92, 92);
                    break;

                case 2:
                    btnB.FillColor = Color.FromArgb(224, 92, 92);
                    break;

                case 3:
                    btnC.FillColor = Color.FromArgb(224, 92, 92);
                    break;

                case 4:
                    btnD.FillColor = Color.FromArgb(224, 92, 92);
                    break;
                }
            }
            switch (userChoices[currentQuiz].Correct)
            {
            case 1:
                btnA.FillColor = Color.FromArgb(108, 255, 125);
                break;

            case 2:
                btnB.FillColor = Color.FromArgb(108, 255, 125);
                break;

            case 3:
                btnC.FillColor = Color.FromArgb(108, 255, 125);
                break;

            case 4:
                btnD.FillColor = Color.FromArgb(108, 255, 125);
                break;
            }

            if (isCorrect == true)
            {
                FlashCard fl = questions[currentQuiz].GetFlashCard();
                if (!ManageUserAction.IsFlashCardExist(0, fl.IdCard))
                {
                    AddFlashCard(fl);
                }
                wrongAns--;
            }
        }
コード例 #5
0
 private void lvWrongWord_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
 {
     curFlashCard = ManageSystem.SearchFlashCardEng(e.Item.SubItems[1].Text);
     if (curFlashCard != null)
     {
         ChangeFlashCard(curFlashCard.Eng, curFlashCard.IdCard);
     }
 }
コード例 #6
0
 private void ToTheLeft()
 {
     if (index > 0)
     {
         index--;
     }
     else
     {
         index = curCollection.ListFL.Count - 1;
     }
     curFlashCard = curCollection.ListFL[index];
     ChangeFlashCard(curFlashCard.Eng, curFlashCard.IdCard);
 }
コード例 #7
0
ファイル: LibraryForm.cs プロジェクト: ltk84/Vocabulary-Up
 private void btnRight_Click(object sender, EventArgs e)
 {
     if (index < ManageSystem.CountAllFlashCards() - 1)
     {
         index++;
     }
     else
     {
         index = 0;
     }
     curFlashCard = ManageSystem.GetFlashCard(index);
     ChangeFlashCard(curFlashCard.Eng, curFlashCard.IdCard);
 }
コード例 #8
0
 private void ToTheRight()
 {
     if (index < curCollection.ListFL.Count - 1)
     {
         index++;
     }
     else
     {
         index = 0;
     }
     curFlashCard = curCollection.ListFL[index];
     ChangeFlashCard(curFlashCard.Eng, curFlashCard.IdCard);
 }
コード例 #9
0
ファイル: LibraryForm.cs プロジェクト: ltk84/Vocabulary-Up
 private void btnLeft_Click(object sender, EventArgs e)
 {
     if (index > 0)
     {
         index--;
     }
     else
     {
         index = ManageSystem.CountAllFlashCards() - 1;
     }
     curFlashCard = ManageSystem.GetFlashCard(index);
     ChangeFlashCard(curFlashCard.Eng, curFlashCard.IdCard);
 }
コード例 #10
0
ファイル: LibraryForm.cs プロジェクト: ltk84/Vocabulary-Up
 public LibraryForm()
 {
     InitializeComponent();
     darkMode = ManageUserAction.GetDarkMode();
     if (darkMode)
     {
         UpdateTheme();
     }
     this.KeyPreview = true;
     ManageSystem.InitLibrary();
     curFlashCard = ManageSystem.GetFlashCard(index);
     ChangeFlashCard(curFlashCard.Eng, curFlashCard.IdCard);
     InitAutoCompleteTextBox();
 }
コード例 #11
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            int iTemp = SearchFlashCardEng(txtSearching.Text);

            if (iTemp >= 0)
            {
                index = iTemp;
            }
            else
            {
                iTemp = SearchFlashCardVie(txtSearching.Text);
                if (iTemp >= 0)
                {
                    index = iTemp;
                }
            }

            curFlashCard = curCollection.ListFL[index];
            ChangeFlashCard(curFlashCard.Eng, curFlashCard.IdCard);
        }
コード例 #12
0
ファイル: ManageSystem.cs プロジェクト: ltk84/Vocabulary-Up
        // KHỞI TẠO THƯ VIỆN CÁC FLASHCARDS
        public static void InitLibrary()
        {
            if (CheckForInternetConnection())
            {
                allFlashCards.Clear();
                SqlConnection connection = new SqlConnection(connString);
                try
                {
                    connection.Open();

                    //Chuan bi cau lenh query viet bang SQL
                    String sqlQuery = "select * from FLASHCARD";
                    //Tao mot Sqlcommand de thuc hien cau lenh truy van da chuan bi voi ket noi hien tai
                    SqlCommand command = new SqlCommand(sqlQuery, connection);

                    //Thuc hien cau truy van va nhan ve mot doi tuong reader ho tro do du lieu
                    SqlDataReader reader = command.ExecuteReader();

                    //Su dung reader de doc tung dong du lieu va cho vao list allFlashCards
                    while (reader.HasRows)
                    {
                        if (reader.Read() == false)
                        {
                            break;
                        }
                        FlashCard f = new FlashCard(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4));
                        allFlashCards.Add(f);
                    }
                }
                finally
                {
                    connection.Close();
                }
            }
            else
            {
                MessageBox.Show("Kết nối có vấn đề!");
            }
        }
コード例 #13
0
        // CONNECT ĐẾN DATABASE ĐỂ LOAD REVISE FLASHCARD
        public static void UpdateReFlashCard(int idUser)
        {
            SqlConnection connection = new SqlConnection(constr);

            try
            {
                //Mo ket noi
                connection.Open();
                //Chuan bi cau lenh query viet bang SQL
                String sqlQuery = "select fl.ID, fl.ENG, fl.VIE, fl.PRONUNCIATION, fl.FIELD from FLASHCARD fl, USER_FLASHCARD u_fl where u_fl.ID_CARD = fl.ID and u_fl.ID_USER = "******"Ket noi xay ra loi hoac doc du lieu bi loi");
            }
            finally
            {
                //Dong ket noi sau khi thao tac ket thuc
                connection.Close();
            }
        }
コード例 #14
0
ファイル: LibraryForm.cs プロジェクト: ltk84/Vocabulary-Up
        private void btnSearch_Click(object sender, EventArgs e)
        {
            FlashCard fl = ManageSystem.SearchFlashCardEng(txtSearching.Text);

            if (fl != null)
            {
                index = fl.IdCard;
            }
            else
            {
                fl = ManageSystem.SearchFlashCardVie(txtSearching.Text);
                if (fl != null)
                {
                    index = fl.IdCard;
                }
                else
                {
                    return;
                }
            }
            curFlashCard = ManageSystem.GetFlashCard(index);
            ChangeFlashCard(curFlashCard.Eng, curFlashCard.IdCard);
        }
コード例 #15
0
        public static void DeleteFlashCardFromDatabase(int idCollection, FlashCard fl)
        {
            SqlConnection connection = new SqlConnection(constr);

            try
            {
                //Mo ket noi
                connection.Open();
                //Chuan bi cau lenh query viet bang SQL
                String sqlQuery = "delete from USER_FLASHCARD where ID_CARD = @ID_CARD and ID_USER = @ID_USER and ID_COLLECTION = @ID_COLLECTION";
                //Tao mot Sqlcommand de thuc hien cau lenh truy van da chuan bi voi ket noi hien tai
                SqlCommand command = new SqlCommand(sqlQuery, connection);
                command.Parameters.AddWithValue("@ID_CARD", fl.IdCard);
                command.Parameters.AddWithValue("@ID_USER", currentUser.IdUser);
                command.Parameters.AddWithValue("@ID_COLLECTION", idCollection);

                //Thuc hien cau truy van va nhan ve mot doi tuong reader ho tro do du lieu
                int rs = command.ExecuteNonQuery();
                //Su dung reader de doc tung dong du lieu
                //va thuc hien thao tac xu ly mong muon voi du lieu doc len
                if (rs != 1)
                {
                    throw new Exception("Failed Query");
                }
            }
            catch (InvalidCastException)
            {
                //xu ly khi ket noi co van de
                MessageBox.Show("Ket noi xay ra loi hoac doc du lieu bi loi");
            }
            finally
            {
                //Dong ket noi sau khi thao tac ket thuc
                connection.Close();
            }
        }
コード例 #16
0
        // CONNECT ĐẾN DATABASE ĐỂ LOAD MAIN FLASHCARD
        public static int UpdateMainFlashCard(int currentTopic)
        {
            mainFlashCard.Clear();
            string nameTopic = null;

            switch (currentTopic)
            {
            case 1:
                nameTopic = "Animals";     //
                break;

            case 2:
                nameTopic = "Plants";
                break;

            case 3:
                nameTopic = "Fruits";
                break;

            case 4:
                nameTopic = "Job";
                break;

            case 5:
                nameTopic = "Food and Drinks";     // khac
                break;

            case 6:
                nameTopic = "Sport";     // khac
                break;

            case 7:
                nameTopic = "Clothing";     //
                break;

            case 8:
                nameTopic = "Technology";     //
                break;
            }
            SqlConnection connection = new SqlConnection(constr);

            try
            {
                //Mo ket noi
                connection.Open();
                //Chuan bi cau lenh query viet bang SQL
                String sqlQuery = "select top 10 * from FLASHCARD fl_m where not exists(select fl.ID from FLASHCARD fl, USER_FLASHCARD u_fl where u_fl.ID_CARD = fl.ID and fl.ID = fl_m.ID and u_fl.ID_USER = "******" and u_fl.ID_COLLECTION = 0) and fl_m.FIELD = '" + nameTopic + "' order by NEWID()";
                //Tao mot Sqlcommand de thuc hien cau lenh truy van da chuan bi voi ket noi hien tai
                SqlCommand command = new SqlCommand(sqlQuery, connection);


                //Thuc hien cau truy van va nhan ve mot doi tuong reader ho tro do du lieu
                SqlDataReader reader = command.ExecuteReader();

                //Su dung reader de doc tung dong du lieu //va thuc hien thao tac xu ly mong muon voi du lieu doc len
                while (reader.HasRows)
                {
                    if (reader.Read() == false)
                    {
                        break;
                    }
                    FlashCard fl = new FlashCard(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4));
                    mainFlashCard.Add(fl);
                }
            }
            catch (InvalidCastException)
            {
                //xu ly khi ket noi co van de
                MessageBox.Show("Ket noi xay ra loi hoac doc du lieu bi loi");
            }
            finally
            {
                //Dong ket noi sau khi thao tac ket thuc
                connection.Close();
            }

            if (mainFlashCard.Count == 0)
            {
                return(0);
            }
            return(1);
        }
コード例 #17
0
ファイル: Quiz.cs プロジェクト: ltk84/Vocabulary-Up
 public Quiz(FlashCard fl)
 {
     this.fl = fl;
 }
コード例 #18
0
ファイル: FillBlankForm.cs プロジェクト: ltk84/Vocabulary-Up
 private void AddFlashCard(FlashCard fl)
 {
     ManageUserAction.AddFlashCardToCollection(0, fl);
     ManageUserAction.AddFlashCardToDatabase(0, ManageUserAction.GetItemOfAllCollection(0).NameCollection, fl);
 }
コード例 #19
0
 public static void AddFlashCardToCollection(int idCollection, FlashCard fl)
 {
     allCollections[idCollection].ListFL.Add(fl);
 }
コード例 #20
0
 public static void RemoveFlashCardFromCollection(int idCollection, FlashCard fl)
 {
     allCollections[idCollection].ListFL.Remove(fl);
 }