Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                List <TimeDistribution> tmp = new List <TimeDistribution>();
                TimeDistribution        TimeDistr = new TimeDistribution();
                float prob = 0, sum = 0, minrange = 0, maxrange = 0;
                for (int i = 0; i < ServiceTimeDGV.RowCount - 1; ++i)
                {
                    TimeDistr = new TimeDistribution();

                    prob = float.Parse(ServiceTimeDGV[1, i].Value.ToString());
                    if (i == 0)
                    {
                        ServiceTimeDGV[2, 0].Value = ServiceTimeDGV[1, 0].Value;
                        sum      = float.Parse(ServiceTimeDGV[2, 0].Value.ToString());
                        minrange = 1;
                        maxrange = float.Parse(ServiceTimeDGV[2, 0].Value.ToString());
                        ServiceTimeDGV[3, 0].Value = minrange;
                        ServiceTimeDGV[4, 0].Value = maxrange * 100;
                    }
                    else
                    {
                        ServiceTimeDGV[2, i].Value = sum + prob;

                        minrange = float.Parse(ServiceTimeDGV[2, i - 1].Value.ToString()) * 100 + 1;
                        sum     += prob;
                        maxrange = sum * 100;
                        ServiceTimeDGV[3, i].Value = minrange;
                        ServiceTimeDGV[4, i].Value = maxrange;
                    }
                    TimeDistr.Time            = int.Parse(ServiceTimeDGV[0, i].Value.ToString());
                    TimeDistr.Probability     = prob;
                    TimeDistr.MinRange        = minrange;
                    TimeDistr.MaxRange        = maxrange;
                    TimeDistr.CummProbability = sum;
                    tmp.Add(TimeDistr);
                }
                DataBase.ServiceTimeDistribution.Add(tmp);
                this.Hide();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataBase.InterArrivalDistribution = new List <TimeDistribution>();
            DataBase.CustomerNumbers          = 0;


            try
            {
                DataBase.Servernumber = (int)ServerNum.Value;
                DataBase.ServerMethod = ServermethodChoice.SelectedItem.ToString();
                if (radioButton1.Checked)
                {
                    DataBase.StoppingCondition = true;
                }

                else
                {
                    DataBase.StoppingCondition = false;
                }
                DataBase.StoppingNumber = int.Parse(textBox1.Text);
                float prob = 0, sum = 0, minrange = 0, maxrange = 0;


                for (int i = 0; i < dataGridView1.RowCount - 1; ++i)
                {
                    TimeDistribution TimeDistr1 = new TimeDistribution();
                    prob = float.Parse((string)dataGridView1[1, i].Value);
                    if (i == 0)
                    {
                        dataGridView1[2, 0].Value = dataGridView1[1, 0].Value;

                        sum      = float.Parse(dataGridView1[2, 0].Value.ToString());
                        minrange = 1;
                        maxrange = float.Parse(dataGridView1[2, 0].Value.ToString());
                        dataGridView1[3, 0].Value = minrange;
                        dataGridView1[4, 0].Value = maxrange * 100;
                    }
                    else
                    {
                        dataGridView1[2, i].Value = sum + prob;

                        minrange = float.Parse(dataGridView1[2, i - 1].Value.ToString()) * 100 + 1;
                        sum     += prob;
                        maxrange = sum * 100;
                        dataGridView1[3, i].Value = minrange;
                        dataGridView1[4, i].Value = maxrange;
                    }
                    TimeDistr1.CummProbability = sum;
                    TimeDistr1.Probability     = prob;
                    TimeDistr1.MaxRange        = maxrange;
                    TimeDistr1.MinRange        = minrange;
                    TimeDistr1.Time            = int.Parse(dataGridView1[0, i].Value.ToString());
                    // server1.ServiceTimeDistribution.Add(TimeDistr1);
                    DataBase.InterArrivalDistribution.Add(TimeDistr1);
                }

                ServiceTimeDistributionForm ServiceTimeForm = new ServiceTimeDistributionForm();
                DataBase.ServiceTimeDistribution = new List <List <TimeDistribution> >();
                for (int i = 0; i < DataBase.Servernumber; ++i)
                {
                    DataBase.ServerIndex = i + 1;
                    ServiceTimeForm      = new ServiceTimeDistributionForm();
                    ServiceTimeForm.ShowDialog();
                    i = DataBase.ServerIndex - 1;
                }
                ServiceTimeForm.Close();
                Results ResultsForm = new Results();
                ResultsForm.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }