コード例 #1
0
        private void find(LinkListScore L)
        {
            int           id = Convert.ToInt32(txtID.Text);
            LinkListScore p  = L;

            while (p != null)
            {
                if (p.id == id)
                {
                    lbID.Text         = p.id.ToString();
                    lbMath.Text       = p.mathScore.ToString();
                    lbLiterature.Text = p.literatureScore.ToString();
                    lbEnglish.Text    = p.englishScore.ToString();
                    break;
                }
                else
                {
                    p = p.Next;
                }
            }
            if (p == null)
            {
                MessageBox.Show("Error,please check input", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
            }
        }
コード例 #2
0
        public LinkListScore loadListScore(LinkListScore L)
        {
            string        filePath = @"DiemThi.txt";
            List <string> lines    = File.ReadAllLines(filePath).ToList();

            char[]        c = new char[] { ' ' };
            List <string> datas = new List <string>();
            int           id = 0;
            double        mathScore = 0, literatureScore = 0, englishScore = 0;

            for (int i = 0; i < lines.Count; i++)
            {
                if (i >= 9)
                {
                    datas.Add(lines[i]);
                }
            }
            foreach (var data in datas)
            {
                string[]      entries = data.Split(c, StringSplitOptions.RemoveEmptyEntries);
                LinkListScore p       = new LinkListScore();
                //Ghi nho cai nay
                for (int i = 0; i < entries.Length; i++)
                {
                    id              = Convert.ToInt32(entries[i]);
                    mathScore       = Convert.ToDouble(entries[i + 1]);
                    literatureScore = Convert.ToDouble(entries[i + 2]);
                    englishScore    = Convert.ToDouble(entries[i + 3]);
                    break;
                }
                addScore(p, id, mathScore, literatureScore, englishScore);
                addS(ref L, p);
            }
            return(L);
        }
コード例 #3
0
 public Boolean addScore(LinkListScore p, int ID, double mathScore, double literatureScore, double englishScore)
 {
     p.id              = ID;
     p.mathScore       = mathScore;
     p.literatureScore = literatureScore;
     p.englishScore    = englishScore;
     return(true);
 }
コード例 #4
0
        public int count(LinkListFullInfo F, int type)
        {
            Console.OutputEncoding = Encoding.Unicode;
            LinkListStudent S = new LinkListStudent();

            S.loadListStudent(S);
            LinkListScore L = new LinkListScore();

            L.loadListScore(L);
            DateTime temp = DateTime.Now;
            int      typeset, dut;
            DateTime birthdate;
            string   rank = null;
            int      count = 0;
            double   mathScore, literatureScore, englishScore, totalScore, minScore;

            while (S != null && L != null)
            {
                typeset         = S.type;
                mathScore       = L.mathScore;
                literatureScore = L.literatureScore;
                englishScore    = L.englishScore;
                minScore        = scoreMin(L.mathScore, L.literatureScore, L.englishScore);
                if (S.type == 1)
                {
                    dut = 2;
                }
                else if (S.type == 2)
                {
                    dut = 1;
                }
                else
                {
                    dut = 3;
                }
                totalScore = L.mathScore + L.literatureScore + L.englishScore + dut;
                birthdate  = S.birthDate;
                if (mathScore == 0 || literatureScore == 0 || englishScore == 0)
                {
                    S = S.Next;
                    L = L.Next;
                    continue;
                }
                if (totalScore < 15 || minScore < 4)
                {
                    rank = "Trượt";
                    if (typeset == type)
                    {
                        count++;
                    }
                }


                S = S.Next;
                L = L.Next;
            }
            return(count);
        }
コード例 #5
0
        public LinkListFullInfo setStGioi(LinkListFullInfo F)
        {
            Console.OutputEncoding = Encoding.Unicode;
            LinkListStudent S = new LinkListStudent();

            S.loadListStudent(S);
            LinkListScore L = new LinkListScore();

            L.loadListScore(L);
            DateTime temp = DateTime.Now;
            int      ID, type, dut;
            DateTime birthdate;
            string   sex;
            string   lastName, name, rank = null;
            double   mathScore, literatureScore, englishScore, totalScore, minScore;

            while (S != null && L != null)
            {
                LinkListFullInfo p = new LinkListFullInfo();
                ID              = S.ID;
                lastName        = S.lastName;
                name            = S.name;
                sex             = S.sex;
                type            = S.type;
                mathScore       = L.mathScore;
                literatureScore = L.literatureScore;
                englishScore    = L.englishScore;
                minScore        = scoreMin(L.mathScore, L.literatureScore, L.englishScore);
                if (S.type == 1)
                {
                    dut = 2;
                }
                else if (S.type == 2)
                {
                    dut = 1;
                }
                else
                {
                    dut = 3;
                }
                totalScore = L.mathScore + L.literatureScore + L.englishScore + dut;
                birthdate  = S.birthDate;
                if (totalScore >= 24 && minScore >= 7)
                {
                    rank = "Giỏi";

                    addFullInfo(p, ID, lastName, name, sex, birthdate, mathScore, literatureScore, englishScore, minScore, totalScore, rank, type);
                    addFull(ref F, p);
                }
                S = S.Next;
                L = L.Next;
            }
            return(F);
        }
コード例 #6
0
        public List <string> changesc(LinkListScore F)
        {
            List <string> lines = new List <string>();
            LinkListScore p     = F;

            //string date = string.Format("{0:dd/MM/yyyy}", p.birthDate);
            while (p != null)
            {
                lines.Add(tabsc(p.id.ToString(), 3) + tabsc(p.mathScore.ToString(), 2) + tabsc(p.literatureScore.ToString(), 2) + tabsc(p.englishScore.ToString(), 2));
                p = p.Next;
            }
            return(lines);
        }
コード例 #7
0
 public void addS(ref LinkListScore L, LinkListScore p)
 {
     if (L == null)
     {
         L = p;
     }
     else
     {
         LinkListScore q = L;
         while (q.Next != null)
         {
             q = q.Next;
         }
         q.Next = p;
     }
 }
コード例 #8
0
        private void FrmDelete_Load(object sender, EventArgs e)
        {
            LinkListStudent temp = new LinkListStudent();

            F = temp.loadListStudent(F);
            LinkListScore tempsc = new LinkListScore();

            sc     = tempsc.loadListScore(sc);
            datas  = F.changest(F);
            datas1 = sc.changesc(sc);
            foreach (string s in datas)
            {
                txtShowStudent.Text = string.Join(Environment.NewLine, datas);
            }
            foreach (string s in datas1)
            {
                txtShowScore.Text = string.Join(Environment.NewLine, datas1);
            }
        }
コード例 #9
0
        private static List <string> Change(LinkListStudent s, LinkListScore sc)
        {
            List <string>   lines = new List <string>();
            LinkListScore   p     = sc;
            LinkListStudent k     = s;

            while (p != null && k != null)
            {
                if (p.mathScore == 0 && p.literatureScore == 0 && p.englishScore == 0)
                {
                    k = k.Next;
                    continue;
                }
                string date = string.Format("{0:dd/MM/yyyy}", k.birthDate);
                lines.Add(Tab(p.id.ToString(), 3) + Tab(k.lastName, 15) + Tab(k.name, 10) + Tab(k.sex, 3) + Tab(date, 12) + Tab(p.mathScore.ToString(), 2) + Tab(p.literatureScore.ToString(), 2) + Tab(p.englishScore.ToString(), 2));
                p = p.Next;
                k = k.Next;
            }
            return(lines);
        }
コード例 #10
0
        private void BtnInput_Click(object sender, EventArgs e)
        {
            id_delete = Convert.ToInt32(txtInput.Text);
            LinkListStudent temp = new LinkListStudent();

            F = temp.loadListStudent(F);
            LinkListScore tempsc = new LinkListScore();

            sc     = tempsc.loadListScore(sc);
            F      = Deletestudent(F, id_delete);
            sc     = Deletescore(sc, id_delete);
            datas  = F.changest(F);
            datas1 = sc.changesc(sc);
            foreach (string s in datas)
            {
                txtShowStudent.Text = string.Join(Environment.NewLine, datas);
            }
            foreach (string s in datas1)
            {
                txtShowScore.Text = string.Join(Environment.NewLine, datas1);
            }
        }
コード例 #11
0
        private LinkListScore Deletescore(LinkListScore sc, int ID)
        {
            LinkListScore L    = null;
            LinkListScore temp = new LinkListScore();

            while (sc != null && sc.id < ID)
            {
                LinkListScore k = new LinkListScore {
                    id = sc.id, mathScore = sc.mathScore, literatureScore = sc.literatureScore, englishScore = sc.englishScore
                };
                temp.addS(ref L, k);
                sc = sc.Next;
            }
            temp = sc.Next;
            while (temp != null)
            {
                LinkListScore k = new LinkListScore {
                    id = (temp.id) - 1, mathScore = temp.mathScore, literatureScore = temp.literatureScore, englishScore = temp.englishScore
                };
                temp.addS(ref L, k);
                temp = temp.Next;
            }
            return(L);
        }
コード例 #12
0
        private void BtnAddFront_Click(object sender, EventArgs e)
        {
            LinkListStudent temp = new LinkListStudent();

            F = temp.loadListStudent(F);
            LinkListStudent p          = new LinkListStudent();
            int             ID         = Convert.ToInt32(txtID.Text);
            string          lastName   = txtLastName.Text;
            string          name       = txtName.Text;
            string          sex        = txtSex.Text;
            int             type       = Convert.ToInt32(txtType.Text);
            DateTime        birthDate1 = dateTimePicker1.Value;

            LinkListStudent L = null;

            while (F != null && F.ID < ID)
            {
                LinkListStudent k = new LinkListStudent {
                    ID = F.ID, name = F.name, lastName = F.lastName, sex = F.sex, birthDate = F.birthDate, type = F.type
                };
                temp.addst(ref L, k);
                F = F.Next;
            }
            //temp.addst(ref L, F);
            temp.addStudent1(p, ID, lastName, name, sex, birthDate1, type);
            temp.addst(ref L, p);
            while (F != null)
            {
                LinkListStudent k = new LinkListStudent {
                    ID = F.ID + 1, name = F.name, lastName = F.lastName, sex = F.sex, birthDate = F.birthDate, type = F.type
                };
                temp.addst(ref L, k);
                F = F.Next;
            }

            LinkListScore tempsc = new LinkListScore();

            sc = tempsc.loadListScore(sc);
            LinkListScore P               = new LinkListScore();
            int           id              = Convert.ToInt32(txtID.Text);
            double        mathScore       = Convert.ToDouble(txtMathScore.Text);
            double        literatureScore = Convert.ToDouble(txtLiteratureScore.Text);
            double        englishScore    = Convert.ToDouble(txtEnglishScore.Text);
            LinkListScore Lsc             = null;

            while (sc != null && sc.id < id)
            {
                LinkListScore k = new LinkListScore {
                    id = sc.id, mathScore = sc.mathScore, literatureScore = sc.literatureScore, englishScore = sc.englishScore
                };
                sc.addS(ref Lsc, k);
                sc = sc.Next;
            }
            //temp.addst(ref L, F);
            sc.addScore(P, id, mathScore, literatureScore, englishScore);
            sc.addS(ref Lsc, P);
            while (sc != null)
            {
                LinkListScore k = new LinkListScore {
                    id = (sc.id) + 1, mathScore = sc.mathScore, literatureScore = sc.literatureScore, englishScore = sc.englishScore
                };
                sc.addS(ref Lsc, k);
                sc = sc.Next;
            }
            datas = Change(L, Lsc);
            foreach (string s in datas)
            {
                txtShow.Text = string.Join(Environment.NewLine, datas);
            }
        }
コード例 #13
0
 public LinkListScore()
 {
     id        = 0;
     mathScore = literatureScore = englishScore = 0;
     Next      = null;
 }
コード例 #14
0
 private void FrmScore_Load_1(object sender, EventArgs e)
 {
     L = load(L);
 }
コード例 #15
0
        public LinkListFullInfo loadStudentType(LinkListFullInfo F, int type)
        {
            Console.OutputEncoding = Encoding.Unicode;
            LinkListStudent S = new LinkListStudent();

            S.loadListStudent(S);
            LinkListScore L = new LinkListScore();

            L.loadListScore(L);
            DateTime temp = DateTime.Now;
            int      ID, type1, dut;
            string   sex;
            string   lastName, name, rank = null;
            DateTime birthdate;
            double   mathScore, literatureScore, englishScore, totalScore, minScore;

            while (S != null && L != null)
            {
                if (S.type != type)
                {
                    S = S.Next;
                    L = L.Next;
                    continue;
                }
                else
                {
                    LinkListFullInfo p = new LinkListFullInfo();
                    ID              = S.ID;
                    lastName        = S.lastName;
                    name            = S.name;
                    sex             = S.sex;
                    type1           = S.type;
                    mathScore       = L.mathScore;
                    literatureScore = L.literatureScore;
                    englishScore    = L.englishScore;
                    minScore        = scoreMin(L.mathScore, L.literatureScore, L.englishScore);

                    if (S.type == 1)
                    {
                        dut = 2;
                    }
                    else if (S.type == 2)
                    {
                        dut = 1;
                    }
                    else
                    {
                        dut = 3;
                    }
                    birthdate  = S.birthDate;
                    totalScore = L.mathScore + L.literatureScore + L.englishScore + dut;
                    if (totalScore >= 24 && minScore >= 7)
                    {
                        rank = "Giỏi";
                    }
                    if (totalScore >= 21 && totalScore < 24)
                    {
                        if (minScore >= 6)
                        {
                            rank = "Khá";
                        }
                    }
                    if (totalScore >= 15 && totalScore < 21)
                    {
                        if (minScore >= 4)
                        {
                            rank = "Trung Bình";
                        }
                    }
                    if (totalScore < 15 || totalScore < 15 && minScore < 4 || minScore < 4)
                    {
                        rank = "Trượt";
                    }
                    addFullInfo(p, ID, lastName, name, sex, birthdate, mathScore, literatureScore, englishScore, minScore, totalScore, rank, type);
                    addFull(ref F, p);
                }
                S = S.Next;
                L = L.Next;
            }
            return(F);
        }