Ejemplo n.º 1
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            int result = Db.is_case_exist(CaseName);

            if (result != 0)
            {
                DialogResult result1 = MessageBox.Show("اسم حالة دراسة مكرر، هل تريد حذف بياناتها وادخالها من جديد ",
                                                       "بيانات مكررة",
                                                       MessageBoxButtons.YesNo);
                if (result1 == DialogResult.No)
                {
                    return;
                }
            }


            Db.del_repeated_case(CaseName);
            try
            {
                mybestchoice.LoadCases();
                string[] s = mybestchoice.get_rows_as_string(standardize_current_cases);
                Db.insert_data_to_standrize_caseTable(mybestchoice.Tablename_Standardization, s, mybestchoice.Features_without_Types);
                Db.insert_case_to_table(mybestchoice.Case_Max_Mean, mybestchoice.Tablename_Standardization);
                Db.insert_case_to_table(mybestchoice.Case_Min_SD, mybestchoice.Tablename_Standardization);
            }
            catch
            {
                MessageBox.Show("حدث خطأما");
                return;
            }

            MessageBox.Show("تم الحفظ بنجاح");
        }
Ejemplo n.º 2
0
        private void button4_Click_1(object sender, EventArgs e)
        {
            List <string> ids             = new List <string>();
            List <Case>   standrize_array = new List <Case>();

            //get ids od cases to delete
            for (int i = 0; i < dataGridView_old.SelectedRows.Count; i++)
            {
                ids.Add(dataGridView_old.SelectedRows[i].Cells["id"].Value.ToString());
            }
            // delete cases from tables
            Db.del_case_id(choice.TableName, ids);
            Db.del_case_id(choice.Tablename_Standardization, ids);
            // re_standrize all tables
            ArrayList array = Db.get_cases_as_arraylist_condition(choice.Tablename_Standardization, choice.CaseName);

            standrize_array = choice.StandardizeData(array);
            Db.del_data_table(choice.Tablename_Standardization);
            standrize_array.Add(choice.Case_Max_Mean);
            standrize_array.Add(choice.Case_Min_SD);
            int num = Convert.ToInt32(choice.Clusters_Num);

            for (int i = 0; i < num; i++) // recalc centroids
            {
                List <Case> cases_cluster = standrize_array.FindAll(
                    delegate(Case ca)
                {
                    return(ca.GetFeature("cluster").GetFeatureValue().ToString() == i.ToString());
                }
                    );
                Case centroid = Kmeans.ReCalcCentroid(cases_cluster, i);
                standrize_array.Add(centroid);
            }
            // add all after restandrize
            Db.insert_data_to_standrize_caseTable_noID(choice.Tablename_Standardization, choice.get_rows_as_string(standrize_array));
            dataGridView_old.DataSource = Db.get_table_contetnt(choice.TableName);
        }