Example #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Volunteer_ViewModel view_model = new Volunteer_ViewModel();

            //搜尋條件
            name      = nametext.Text;
            group     = 組別CB.Text;
            expertise = 專長CB.Text;
            List <int> years = new List <int>();

            if (this.年資0到1.IsChecked == true)
            {
                years.Add(0); years.Add(1);
            }
            if (this.年資1到3.IsChecked == true)
            {
                years.Add(1); years.Add(2); years.Add(3);
            }
            if (this.年資3到5.IsChecked == true)
            {
                years.Add(3); years.Add(4); years.Add(5);
            }
            if (this.年資5到10.IsChecked == true)
            {
                years.Add(5); years.Add(6); years.Add(7); years.Add(8); years.Add(9); years.Add(10);
            }
            if (this.年資10年以上.IsChecked == true)
            {
                for (int i = 10; i <= 30; i++)
                {
                    years.Add(i);
                }
            }
            //將條件給後面使用
            var q = view_model.Search_Volunteer(name, group, expertise, years);

            //使用自訂類別控制欄位表現
            List <Volunteer_DataGirdView> q2 = new List <Volunteer_DataGirdView>();

            foreach (var p in q)
            {
                Volunteer_DataGirdView a = new Volunteer_DataGirdView();
                a.志工編號 = p.Volunteer_no;
                a.志工姓名 = p.Chinese_name;
                a.志工身分 = p.Identity_type;
                a.志工年資 = p.Seniority;
                a.志工專長 = p.getallexpetise();
                a.志工組別 = p.getallgroup();


                q2.Add(a);
            }

            this.datagrid1.ItemsSource = q2;
        }
        public Volunteer_detail(int Volunteer_no)
        {
            InitializeComponent();

            Volunteer_ViewModel volunteer_ViewModel = new Volunteer_ViewModel();

            volunteer_ViewModel.SelectVolunteer_byVolunteerno(Volunteer_no);

            this.Chinese_name_Label.Content      = volunteer_ViewModel.Chinese_name;
            this.English_name_Label.Content      = volunteer_ViewModel.English_name;
            this.Sex_Label.Content               = volunteer_ViewModel.Sex;
            this.Birthday_Label.Content          = volunteer_ViewModel.Birthday;
            this.IDcrad_Label.Content            = volunteer_ViewModel.IDcrad_no;
            this.Medical_record_no_Label.Content = volunteer_ViewModel.Medical_record_no;
            this.Identity_type_Label.Content     = volunteer_ViewModel.Identity_type;
            this.Seniority_Label.Content         = volunteer_ViewModel.Seniority;
            this.Join_date_Label.Content         = volunteer_ViewModel.Join_date;
            this.Leave_date_Label.Content        = volunteer_ViewModel.Leave_date;
            this.Leave_reason_Label.Content      = volunteer_ViewModel.Leave_reason;
            this.Phone_no_Label.Content          = volunteer_ViewModel.Phone_no;
            this.Mobile_no_Label.Content         = volunteer_ViewModel.Mobile_no;
            this.Vest_no_Label.Content           = volunteer_ViewModel.Vest_no;
            this.Postal_code_Label.Content       = volunteer_ViewModel.Postal_code;
            this.Address_Label.Content           = volunteer_ViewModel.Address;
            this.Education_Label.Content         = volunteer_ViewModel.Education;
            this.Lssuing_unit_Label.Content      = volunteer_ViewModel.Lssuing_unit;
            this.Service_manual_no_Label.Content = volunteer_ViewModel.Service_manual_no;
            this.Personality_scale_Label.Content = volunteer_ViewModel.Personality_scale;
            this.Photo.Source = volunteer_ViewModel.Photo;
            this.Leader_list_Label.Content   = volunteer_ViewModel.Leader_list;
            this.Experise_list_Label.Content = volunteer_ViewModel.Experise_list;

            ObservableCollection <Activity_list> activity_list = new ObservableCollection <Activity_list>();
            Activity_ViewModel        activity_ViewModel       = new Activity_ViewModel();
            List <Activity_ViewModel> activity_ViewModel_list  = activity_ViewModel.SelectVolunteer_ActivitybyVolunteerno(Volunteer_no);

            foreach (var row in activity_ViewModel_list)
            {
                activity_list.Add(new Activity_list()
                {
                    活動編號 = row.Activity_no, 活動名稱 = row.Activity_name, 活動承辦人 = row.Undertaker
                });
            }

            Activity_datagrid.ItemsSource = activity_list;
        }