Beispiel #1
0
        private void radioButton2_Click_1(object sender, EventArgs e)
        {
            //cmbox_case.Items.Clear();

            dG_data.DataSource = null;
            // Create an instance of the open file dialog box.
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            // Set filter options and filter index.
            openFileDialog1.Filter      = "Text Files (.txt)|*.txt|All Files (*.*)|*.*";
            openFileDialog1.FilterIndex = 1;

            openFileDialog1.Multiselect = true;

            // Call the ShowDialog method to show the dialog box.
            DialogResult userClickedOK = openFileDialog1.ShowDialog();

            // Process input if the user clicked OK.
            if (userClickedOK.Equals(DialogResult.OK))
            {
                string url = openFileDialog1.FileName;
                // Open the selected file to read.
                System.IO.Stream fileStream = openFileDialog1.OpenFile();
                // تحميل الى datagrid
                IOCBRFile   myfile     = OCBRFileFactory.newInstance(url, true);
                ArrayList   ArrayCases = myfile.GetCases();
                string      CaseName   = myfile.GetCaseName();
                List <Case> ListCases  = myfile.GetListCases();
                mybestchoice = new BestChoice(ArrayCases, ListCases, "MN", "KPP");
                if (ArrayCases.Count != 0)
                {
                    for (int j = 0; j < ListCases[0].GetFeatures().Count; j++)
                    {
                        Feature feature = (Feature)ListCases[0].GetFeatures()[j];
                        dG_data.Columns.Add(feature.GetFeatureName().ToString(), feature.GetFeatureName().ToString());
                    }

                    dG_data.Rows.Add(ArrayCases.Count);
                }
                for (int i = 0; i < ArrayCases.Count; i++)
                {
                    Case c = (Case)ArrayCases[i];
                    for (int j = 0; j < c.GetFeatures().Count; j++)
                    {
                        Feature f = (Feature)c.GetFeatures()[j];
                        dG_data.Rows[i].Cells[j].Value = f.GetFeatureValue();
                    }
                }
            }
        }
        public bool add_file()
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                MessageBox.Show("حدد حالة للتحديث من فضلك");
                return(false);
            }
            string url       = "";
            string CaseName  = "";
            string TableName = "";

            // dataGridView_updated.Columns.Clear();
            // dataGridView_updated.DataSource = null;
            // Create an instance of the open file dialog box.
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            // Set filter options and filter index.
            openFileDialog1.Filter      = "Text Files (.txt)|*.txt|All Files (*.*)|*.*";
            openFileDialog1.FilterIndex = 1;

            openFileDialog1.Multiselect = true;

            // Call the ShowDialog method to show the dialog box.
            DialogResult userClickedOK = openFileDialog1.ShowDialog();

            // Process input if the user clicked OK.
            if (userClickedOK.Equals(DialogResult.OK))
            {
                url = openFileDialog1.FileName;
                // Open the selected file to read.
                System.IO.Stream fileStream = openFileDialog1.OpenFile();
                // تحميل الى datagrid
                IOCBRFile myfile = OCBRFileFactory.newInstance(url, true);
                ArrayCases = myfile.GetCases();
                ListCases  = myfile.GetListCases();

                CaseName  = myfile.GetCaseName();
                TableName = dataGridView1.SelectedRows[0].Cells["tbl_name"].Value.ToString();
                if (CaseName != dataGridView1.SelectedRows[0].Cells["case_name"].Value.ToString())
                {
                    MessageBox.Show("عدم تطابق بين الحالة المدخلة والمحددة");
                    return(false);
                }

                /*  if (ArrayCases.Count != 0)
                 * {
                 *
                 *    for (int j = 0; j < ListCases[0].GetFeatures().Count; j++)
                 *    {
                 *        Feature feature = (Feature)ListCases[0].GetFeatures()[j];
                 *        dataGridView_updated.Columns.Add(feature.GetFeatureName().ToString(), feature.GetFeatureName().ToString());
                 *    }
                 *    dataGridView_updated.Rows.Add(ArrayCases.Count);
                 * }
                 * for (int i = 0; i < ArrayCases.Count; i++)
                 * {
                 *    Case c = (Case)ArrayCases[i];
                 *    for (int j = 0; j < c.GetFeatures().Count; j++)
                 *    {
                 *        Feature f = (Feature)c.GetFeatures()[j];
                 *        dataGridView_updated.Rows[i].Cells[j].Value = f.GetFeatureValue();
                 *    }
                 * }*/
            }
            return(true);
        }