示例#1
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            XmlDocument Students = new XmlDocument();

            Students.Load("Students.xml");

            int N = Data.Rows.Count - 1;

            while (N > 0)
            {
                XmlElement track  = (XmlElement)(Students.GetElementsByTagName("Track")[Students.GetElementsByTagName("Track").Count - 1]);
                XmlElement sector = (XmlElement)(track.GetElementsByTagName("Sector")[track.GetElementsByTagName("Sector").Count - 1]);



                if (N != 0 && sector.GetElementsByTagName("Student").Count == Number_of_Records_per_Sector && track.GetElementsByTagName("Sector").Count < Number_of_Sectors_per_Track)
                {
                    XmlElement Sector = Students.CreateElement("Sector");
                    track.AppendChild(Sector);
                    sector = (XmlElement)(track.GetElementsByTagName("Sector")[track.GetElementsByTagName("Sector").Count - 1]);
                    Students.Save("Students.xml");
                }
                if (N != 0 && sector.GetElementsByTagName("Student").Count == Number_of_Records_per_Sector && track.GetElementsByTagName("Sector").Count == Number_of_Sectors_per_Track)
                {
                    XmlElement Track = Students.CreateElement("Track");
                    Students.DocumentElement.AppendChild(Track);
                    XmlElement Sector = Students.CreateElement("Sector");
                    Track.AppendChild(Sector);
                    track  = (XmlElement)(Students.GetElementsByTagName("Track")[Students.GetElementsByTagName("Track").Count - 1]);
                    sector = (XmlElement)(track.GetElementsByTagName("Sector")[track.GetElementsByTagName("Sector").Count - 1]);
                    Students.Save("Students.xml");
                }
                while (true)
                {
                    int Students_Counter = sector.GetElementsByTagName("Student").Count;

                    if (N == 0 || Students_Counter == Number_of_Records_per_Sector)
                    {
                        break;
                    }

                    XmlElement Student = Students.CreateElement("Student");
                    Student.SetAttribute("ID", Data.Rows[Data.Rows.Count - 1 - N].Cells[0].Value.ToString());
                    Student.SetAttribute("Name", Data.Rows[Data.Rows.Count - 1 - N].Cells[1].Value.ToString());
                    Student.SetAttribute("Address", Data.Rows[Data.Rows.Count - 1 - N].Cells[2].Value.ToString());
                    sector.AppendChild(Student);
                    Students.Save("Students.xml");


                    N--;
                }
            }

            Students.Save("Students.xml");
            Data.Rows.Clear();

            MBox m = new MBox("Data has been Successfully Added", "");

            m.Show();
        }
示例#2
0
        private void SectorButton_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "0")
            {
                textBox1.Text = null;
            }
            if (textBox2.Text == "0")
            {
                textBox2.Text = null;
            }


            if (textBox4.Text == "0")
            {
                textBox4.Text = null;
            }
            if (textBox3.Text == "0")
            {
                textBox3.Text = null;
            }
            if (textBox5.Text == "0")
            {
                textBox5.Text = null;
            }
            if (textBox1.Text == "" || textBox2.Text == "" || textBox4.Text == "" || textBox3.Text == "" || textBox5.Text == "")
            {
                MBox Message = new MBox("You Must Fill All Data!", "");
                Message.Show();
            }
            else
            {
                int sector_Size  = int.Parse(textBox1.Text);
                int cluster_Size = int.Parse(textBox2.Text);
                int track_size   = int.Parse(textBox3.Text);
                int record_size  = int.Parse(textBox4.Text);
                int number_sectors_per_cluster = int.Parse(textBox5.Text);


                int   number_of_clusters        = track_size / cluster_Size;
                int   used_space                = number_of_clusters * cluster_Size;
                float number_record_per_sector  = sector_Size / record_size;
                int   Number_record_per_sector  = (int)number_record_per_sector;
                float number_record_per_cluster = number_record_per_sector * number_sectors_per_cluster;
                int   Number_record_per_cluster = (int)number_record_per_cluster;
                int   number_of_records_track   = number_of_clusters * Number_record_per_cluster;
                int   frag = track_size - used_space;

                MBox Message = new MBox("The Amount of Fragmentation = " + frag.ToString(), "The Number of Records per Track = " + number_of_records_track.ToString());
                Message.Show();

                cStudents Simulate = new cStudents(number_of_clusters, number_sectors_per_cluster, Number_record_per_sector);
                Simulate.Show();
                this.Hide();
            }
        }
示例#3
0
        private void SimulateButton_Click(object sender, EventArgs e)
        {
            if (RecordSize.Text == "" || TrackSize.Text == "" || BlockingFactor.Text == "" || Data.Text == "")
            {
                MBox Message = new MBox("You Must Fill All Data!", "");
                Message.Show();
            }
            else
            {
                if (RecordSize.Text == "0")
                {
                    RecordSize.Text = null;
                }
                if (TrackSize.Text == "0")
                {
                    TrackSize.Text = null;
                }


                if (BlockingFactor.Text == "0")
                {
                    BlockingFactor.Text = null;
                }
                if (Data.Text == "0")
                {
                    Data.Text = null;
                }

                int Record_Size     = int.Parse(RecordSize.Text);
                int Track_Size      = int.Parse(TrackSize.Text);
                int Blocking_Factor = int.Parse(BlockingFactor.Text);
                int Non_Data        = int.Parse(Data.Text);
                int Block_Size      = (Blocking_Factor * Record_Size) + Non_Data;

                int Number_of_Blocks            = Track_Size / Block_Size;
                int Number_of_Records_per_Track = Blocking_Factor * Number_of_Blocks;
                int User_Space = Block_Size * Number_of_Blocks;
                int Fragmentation_per_Track = Track_Size - User_Space;

                MBox Message = new MBox("The Amount of Fragmentation = " + Fragmentation_per_Track.ToString(), "The Number of Records per Track = " + Number_of_Records_per_Track.ToString());
                Message.Show();
                B_AddStudent Simulate = new B_AddStudent(Blocking_Factor, Number_of_Blocks);
                Simulate.Show();
                this.Hide();
            }
        }
示例#4
0
        private void CompareButton_Click(object sender, EventArgs e)
        {
            if (RecordSize.Text == "" || SectorSize.Text == "" || FileSize.Text == "" || TrackSIze.Text == "" || BlockingFactor.Text == "" || Data.Text == "")
            {
                MBox Message = new MBox("You Must Fill All Data!", "");
                Message.Show();
            }
            else
            {
                if (RecordSize.Text == "0")
                {
                    RecordSize.Text = null;
                }

                if (SectorSize.Text == "0")
                {
                    SectorSize.Text = null;
                }

                if (TrackSIze.Text == "0")
                {
                    TrackSIze.Text = null;
                }

                if (FileSize.Text == "0")
                {
                    FileSize.Text = null;
                }

                if (BlockingFactor.Text == "0")
                {
                    BlockingFactor.Text = null;
                }

                if (Data.Text == "0")
                {
                    Data.Text = null;
                }

                CalcBlock();
                CalcSector();
                ComparisonResult c = new ComparisonResult(S_Fragmentation_per_Track, S_Number_of_Records_per_Track, B_Fragmentation_per_Track, B_Number_of_Records_per_Track, Track_Size);
                this.Hide();
                c.Show();
            }
        }
示例#5
0
        private void SimulateButton_Click(object sender, EventArgs e)
        {
            if (RecordSize.Text == "" || SectorSize.Text == "" || FileSize.Text == "" || TrackSIze.Text == "")
            {
                MBox Message = new MBox("You Must Fill All Data!", "");
                Message.Show();
            }
            else
            {
                if (RecordSize.Text == "0")
                {
                    RecordSize.Text = null;
                }

                if (SectorSize.Text == "0")
                {
                    SectorSize.Text = null;
                }

                if (TrackSIze.Text == "0")
                {
                    TrackSIze.Text = null;
                }

                if (FileSize.Text == "0")
                {
                    FileSize.Text = null;
                }



                int Sector_Size       = int.Parse(SectorSize.Text);
                int Record_Size       = int.Parse(RecordSize.Text);
                int Track_Size        = int.Parse(TrackSIze.Text);
                int Number_of_Records = int.Parse(FileSize.Text);


                int Number_of_Sectors_per_Track = Track_Size / Sector_Size;



                if (radioButton1.Checked == true)
                {
                    float Number_of_Records_per_Sector = (float)Sector_Size / Record_Size;
                    int   number_of_Records_per_Sector = (int)Number_of_Records_per_Sector;

                    float Number_of_Records_per_Track         = (float)Number_of_Records_per_Sector * Number_of_Sectors_per_Track;
                    int   Number_of_Records_per_Track_Integer = (int)Number_of_Records_per_Track;
                    float Difference = (float)Number_of_Records_per_Track - Number_of_Records_per_Track_Integer;
                    int   Fragmentation_per_Track = (int)(Difference * Record_Size);

                    MBox Message = new MBox("The Amount of Fragmentation = " + Fragmentation_per_Track.ToString(), "The Number of Records per Track = " + Number_of_Records_per_Track_Integer.ToString());;
                    Message.Show();

                    AddStudent S = new AddStudent(number_of_Records_per_Sector, Number_of_Records_per_Track_Integer, (int)Track_Size / Sector_Size);
                    S.Show();
                    this.Hide();
                }

                // if not span
                else if (radioButton2.Checked == true)
                {
                    int Number_of_Records_per_Sector = Sector_Size / Record_Size;
                    int Number_of_Records_per_Track  = Number_of_Records_per_Sector * Number_of_Sectors_per_Track;
                    int Fragmentation_per_Sector     = Sector_Size - (Number_of_Records_per_Sector * Record_Size);

                    int Fragmentation_per_Track = Fragmentation_per_Sector * (Track_Size / Sector_Size);



                    MBox Message = new MBox("The Amount of Fragmentation = " + Fragmentation_per_Track.ToString(), "The Number of Records per Track = " + Number_of_Records_per_Track.ToString());;
                    Message.Show();
                    AddStudent S = new AddStudent(Number_of_Records_per_Sector, Number_of_Records_per_Track, (int)Track_Size / Sector_Size);
                    S.Show();
                    this.Hide();
                }
                else if (radioButton1.Checked == false && radioButton2.Checked == false)
                {
                    MBox Message = new MBox("You Must Choose any of The Two Radio Buttons!", "");;
                    Message.Show();
                }
            }
        }