Exemplo n.º 1
0
        public void SaveStudent(Student st)
        {
            st.Mark1      = Convert.ToInt32(nudMark1.Value);
            st.Mark2      = Convert.ToInt32(nudMark2.Value);
            st.Mark3      = Convert.ToInt32(nudMark3.Value);
            st.ResultMark = Convert.ToInt32(nudResultMark.Value);

            XMLFileManager.SaveStudent(st, students_xml);
        }
Exemplo n.º 2
0
        public void SaveStudent(Student st)
        {
            int index = -1;

            foreach (ListViewItem item in lvResults.Items)
            {
                if (item.Text == st.FIO &&
                    item.SubItems[1].Text == st.Mark1.ToString() &&
                    item.SubItems[2].Text == st.Mark2.ToString() &&
                    item.SubItems[3].Text == st.Mark3.ToString() &&
                    item.SubItems[4].Text == st.Mark4.ToString() &&
                    item.SubItems[5].Text == st.Mark5.ToString() &&
                    item.SubItems[6].Text == st.Mark6.ToString())
                {
                    index = item.Index;
                    break;
                }
            }

            st.Mark1 = Convert.ToInt32(nudMark1.Value);
            st.Mark2 = Convert.ToInt32(nudMark2.Value);
            st.Mark3 = Convert.ToInt32(nudMark3.Value);
            st.Mark4 = Convert.ToInt32(nudMark4.Value);
            st.Mark5 = Convert.ToInt32(nudMark5.Value);
            st.Mark6 = Convert.ToInt32(nudMark6.Value);

            XMLFileManager.SaveStudent(st, students_xml);

            if (index != -1)
            {
                ListViewItem item = lvResults.Items[index];
                item.SubItems[1].Text = st.Mark1.ToString();
                item.SubItems[2].Text = st.Mark2.ToString();
                item.SubItems[3].Text = st.Mark3.ToString();
                item.SubItems[4].Text = st.Mark4.ToString();
                item.SubItems[5].Text = st.Mark5.ToString();
                item.SubItems[6].Text = st.Mark6.ToString();

                int mark1 = st.Mark1;
                int mark2 = st.Mark2;
                int mark3 = st.Mark3;
                int mark4 = st.Mark4;
                int mark5 = st.Mark5;
                int mark6 = st.Mark6;

                int count = 6;
                if (mark1 == 0)
                {
                    count--;
                }
                if (mark2 == 0)
                {
                    count--;
                }
                if (mark3 == 0)
                {
                    count--;
                }
                if (mark4 == 0)
                {
                    count--;
                }
                if (mark5 == 0)
                {
                    count--;
                }
                if (mark6 == 0)
                {
                    count--;
                }

                float middle = 0;
                if (count != 0)
                {
                    middle = (float)(mark1 + mark2 + mark3 + mark4 + mark5 + mark6) / (float)count;
                }
                item.SubItems[7].Text = middle.ToString("0.#");
            }
        }