public addAccident(string type, string carid)
        {
            InitializeComponent();

            ac = new Accident();

            ac.Type = type;
            ac.CarID = carid;
        }
Пример #2
0
        public int make_case(int how_many_months)
        {
            int case_number_per_month = random_number.Next(8);
            if (case_number_per_month == 0)
                case_number_per_month++;
            //每月有多少事件完成。
            int accident_number_per_month=random_number.Next(7);
            if (case_number_per_month == 0)
                case_number_per_month++;
            //每月有多少交通事故完成。
            int cases_in_total = case_number_per_month * how_many_months;
            int accident_in_total=accident_number_per_month*how_many_months;

            list_place = datamanager.FindAll(Publicplace.getClass());
            list_cititzen = datamanager.FindAll(Citizen.getClass());
            list_carinfo = datamanager.FindAll(Carinfo.getClass());

            for (int i = 0; i < cases_in_total; i++) //案件生成和存入数据库
            {
                one_case = new Cases();
                //得到ID值

                if (random_number.Next(100) > 50)//民事
                {
                    one_case.Casetype = "民事";
                    one_case.Casedescribe = case_describe[random_number.Next(6)];

                    //list=datamanager.FindAll(Publicplace.getClass());
                    int temp=random_number.Next(list_place.Count);

                    one_case.Caseaddress = ((Publicplace)list_place[temp]).Address;
                    one_case.Casestatus = "调查";
                }
                else
                {
                     one_case.Casetype = "刑事";
                    one_case.Casedescribe = case_penal_describe[random_number.Next(6)];

                    //list=datamanager.FindAll(Publicplace.getClass());
                    int temp=random_number.Next(list_place.Count);

                    one_case.Caseaddress = ((Publicplace)list_place[temp]).Address;
                    one_case.Casestatus = "调查";
                }
                dt=Convert.ToDateTime("2007-1-1");
                dt = dt.AddYears(random_number.Next(5));
                dt = dt.AddMonths(random_number.Next(12));
                dt = dt.AddDays(random_number.Next(30));
                one_case.Time=dt.ToString();

                datamanager.Persist(one_case);
                datamanager.exeProcessSQL(class_help_id);
                int temp_number = class_help_id.max_case_id;
                //temp_number++;//得到下一个要生成的id号。
                one_case.CaseID = temp_number;

                //得到人
                // list=datamanager.FindAll(Citizen.getClass());
                temp_number = random_number.Next(3) + 1;
                if (temp_number > list_cititzen.Count)
                    temp_number = list_cititzen.Count;

                for(int j=0;j<temp_number;j++)
                {
                    datamanager.PersistManyToManyRelation(one_case, ((Citizen)list_cititzen[random_number.Next(list_cititzen.Count)]), "case_person");
                }
            }

            for(int i=0;i<accident_in_total;i++)//生成交通事故并存入数据库
            {
                one_accident=new Accident();
                datamanager.exeProcessSQL(class_help_accident_id);
                int temp_number=class_help_accident_id.max_accident_id;
                temp_number++;//得到下一个要生成的id号。
                one_accident.AccidentID=temp_number;

                //下面赋值carid
                  //list=datamanager.FindAll(Carinfo.getClass());
                    int temp=random_number.Next(list_carinfo.Count);
                one_accident.CarID=((Carinfo)list_carinfo[temp]).CarID;

               //下面address
                      //list=datamanager.FindAll(Publicplace.getClass());
                    temp=random_number.Next(list_place.Count);
                    one_accident.Address = ((Publicplace)list_place[temp]).Address;
                //下面time
                 dt=Convert.ToDateTime("2007-1-1");
                dt = dt.AddYears(random_number.Next(5));
                dt = dt.AddMonths(random_number.Next(12));
                dt = dt.AddDays(random_number.Next(30));
                one_accident.Time=dt.ToString();
                //下面类型和描述
                if(random_number.Next(100)>50)//事故
                {
                    one_accident.Type="事故";
                    one_accident.Accidentcontent = accident_penal_describe[random_number.Next(6)];
                }
                else
                {
                    one_accident.Type = "违规";
                    one_accident.Accidentcontent = accident_violation_describe[random_number.Next(6)];
                }

                //下面存入
                datamanager.Persist(one_accident);
            }

            return cases_in_total + accident_in_total;
        }