EveryDB2のデータベースを読み込んでWinFormでGUI表示するサンプル
Revision | f8acc5d752cbb824c20f3eacd57030b749281695 (tree) |
---|---|
Zeit | 2021-06-05 05:23:52 |
Autor | yoshy <yoshy@user...> |
Commiter | yoshy |
temp_20210605_0523
@@ -43,11 +43,15 @@ namespace UmaTest.App.Adaptor.Gateway.ViewModel.Dto | ||
43 | 43 | |
44 | 44 | public string GradeName => CodeHelper.GetInstance().GetGradeName(Race, "?"); |
45 | 45 | |
46 | - public string CourseName => CodeHelper.GetInstance().GetTurfDurtName(Race?.Trackcd, "?") + Race?.Kyori; | |
46 | + public string TurfDirtName => CodeHelper.GetInstance().GetTurfDurtName(Race?.Trackcd, "?"); | |
47 | + | |
48 | + public string CourseName => TurfDirtName + Race?.Kyori; | |
47 | 49 | |
48 | 50 | public string NinkiFormatted => FormatHelper.SuppressZeroLeading(Ninki); |
49 | 51 | |
50 | - public string SyussoTosuFormatted => FormatHelper.SuppressZeroLeading(Race.Syussotosu); | |
52 | + public string TosuFormatted => FormatHelper.FormatTosu(Race); | |
53 | + | |
54 | + public string BabaJyotaiFormatted => FormatHelper.FormatBabaJyotai(Race); | |
51 | 55 | |
52 | 56 | public string KakuteiJyuniFormatted => FormatHelper.SuppressZeroLeading(Kakuteijyuni); |
53 | 57 |
@@ -97,12 +97,20 @@ namespace UmaTest.App.Adaptor.Gateway.ViewModel.Dto | ||
97 | 97 | { |
98 | 98 | get |
99 | 99 | { |
100 | - if (Konso?.Bataijyu != null) | |
100 | + if (!string.IsNullOrEmpty(Konso?.Bataijyu) && (Konso.Bataijyu != "0000")) | |
101 | 101 | { |
102 | 102 | return Konso.BataijyuFormatted; |
103 | 103 | } |
104 | - if (Zenso?.Bataijyu != null) | |
104 | + | |
105 | + if (!string.IsNullOrEmpty(Zenso?.Bataijyu)) | |
105 | 106 | { |
107 | + if ( string.IsNullOrEmpty(Konso?.Bataijyu) || (Konso?.Bataijyu == "0000") ) | |
108 | + { | |
109 | + Konso.Bataijyu = Zenso.Bataijyu; | |
110 | + Konso.Zogensa = null; | |
111 | + return Konso.Bataijyu; | |
112 | + } | |
113 | + | |
106 | 114 | return Zenso.BataijyuFormatted; |
107 | 115 | } |
108 | 116 |
@@ -208,6 +208,11 @@ namespace UmaTest.App.Presentation.View | ||
208 | 208 | }, |
209 | 209 | new DataGridViewTextBoxColumn |
210 | 210 | { |
211 | + DataPropertyName = "Zenso.BabaJyotaiFormatted", | |
212 | + Name = "前走馬場", | |
213 | + }, | |
214 | + new DataGridViewTextBoxColumn | |
215 | + { | |
211 | 216 | DataPropertyName = "Zenso.NinkiFormatted", |
212 | 217 | Name = "前走人気", |
213 | 218 | }, |
@@ -288,6 +293,11 @@ namespace UmaTest.App.Presentation.View | ||
288 | 293 | }, |
289 | 294 | new DataGridViewTextBoxColumn |
290 | 295 | { |
296 | + DataPropertyName = "NisoMae.BabaJyotaiFormatted", | |
297 | + Name = "前々走馬場", | |
298 | + }, | |
299 | + new DataGridViewTextBoxColumn | |
300 | + { | |
291 | 301 | DataPropertyName = "NisoMae.NinkiFormatted", |
292 | 302 | Name = "前々走人気", |
293 | 303 | }, |
@@ -481,6 +491,7 @@ namespace UmaTest.App.Presentation.View | ||
481 | 491 | dataGridView1.Columns["間隔"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; |
482 | 492 | |
483 | 493 | dataGridView1.Columns["前走G"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; |
494 | + dataGridView1.Columns["前走馬場"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; | |
484 | 495 | dataGridView1.Columns["前走人気"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; |
485 | 496 | dataGridView1.Columns["前走通過順位"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; |
486 | 497 | dataGridView1.Columns["前走着順"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; |
@@ -491,6 +502,7 @@ namespace UmaTest.App.Presentation.View | ||
491 | 502 | dataGridView1.Columns["前走間隔"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; |
492 | 503 | |
493 | 504 | dataGridView1.Columns["前々走G"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; |
505 | + dataGridView1.Columns["前々走馬場"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; | |
494 | 506 | dataGridView1.Columns["前々走人気"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; |
495 | 507 | dataGridView1.Columns["前々走通過順位"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; |
496 | 508 | dataGridView1.Columns["前々走着順"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; |
@@ -555,11 +567,16 @@ namespace UmaTest.App.Presentation.View | ||
555 | 567 | }, |
556 | 568 | new DataGridViewTextBoxColumn |
557 | 569 | { |
558 | - DataPropertyName = "SyussoTosuFormatted", | |
570 | + DataPropertyName = "TosuFormatted", | |
559 | 571 | Name = "頭数", |
560 | 572 | }, |
561 | 573 | new DataGridViewTextBoxColumn |
562 | 574 | { |
575 | + DataPropertyName = "BabaJyotaiFormatted", | |
576 | + Name = "馬場", | |
577 | + }, | |
578 | + new DataGridViewTextBoxColumn | |
579 | + { | |
563 | 580 | DataPropertyName = "WakubanFormatted", |
564 | 581 | Name = "枠番", |
565 | 582 | }, |
@@ -605,23 +622,23 @@ namespace UmaTest.App.Presentation.View | ||
605 | 622 | }, |
606 | 623 | new DataGridViewTextBoxColumn |
607 | 624 | { |
608 | - DataPropertyName = "AvgHaronTimeMinus3Formatted", | |
609 | - Name = "平均-3F", | |
625 | + DataPropertyName = "AvgHaronTimeMinus3DevFormatted", | |
626 | + Name = "平均-3F ペース", | |
610 | 627 | }, |
611 | 628 | new DataGridViewTextBoxColumn |
612 | 629 | { |
613 | - DataPropertyName = "AvgHaronTimeMinus3DevFormatted", | |
614 | - Name = "平均-3F ペース", | |
630 | + DataPropertyName = "HaronTimeL3DevFormatted", | |
631 | + Name = "上3F指数", | |
615 | 632 | }, |
616 | 633 | new DataGridViewTextBoxColumn |
617 | 634 | { |
618 | - DataPropertyName = "HaronTimeL3Formatted", | |
619 | - Name = "上3F", | |
635 | + DataPropertyName = "AvgHaronTimeMinus3Formatted", | |
636 | + Name = "平均-3F", | |
620 | 637 | }, |
621 | 638 | new DataGridViewTextBoxColumn |
622 | 639 | { |
623 | - DataPropertyName = "HaronTimeL3DevFormatted", | |
624 | - Name = "上3F指数", | |
640 | + DataPropertyName = "HaronTimeL3Formatted", | |
641 | + Name = "上3F", | |
625 | 642 | }, |
626 | 643 | new DataGridViewTextBoxColumn |
627 | 644 | { |
@@ -674,6 +691,7 @@ namespace UmaTest.App.Presentation.View | ||
674 | 691 | |
675 | 692 | dataGridView2.Columns["G"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; |
676 | 693 | dataGridView2.Columns["頭数"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; |
694 | + dataGridView2.Columns["馬場"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; | |
677 | 695 | dataGridView2.Columns["枠番"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; |
678 | 696 | dataGridView2.Columns["馬番"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; |
679 | 697 | dataGridView2.Columns["人気"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; |
@@ -15,6 +15,7 @@ namespace UmaTest.Infra.Helper | ||
15 | 15 | public static readonly string GRADE_CODE = "2003"; |
16 | 16 | public static readonly string JYOKEN_CODE = "2007"; |
17 | 17 | public static readonly string TRACK_CODE = "2009"; |
18 | + public static readonly string BABA_JYOTAI_CODE = "2010"; | |
18 | 19 | |
19 | 20 | public static readonly string SEX_CODE = "2202"; |
20 | 21 |
@@ -106,7 +106,7 @@ namespace UmaTest.Infra.Helper | ||
106 | 106 | |
107 | 107 | public static string FormatTimeSSF(string time3) |
108 | 108 | { |
109 | - return time3.Length == 3 | |
109 | + return time3?.Length == 3 | |
110 | 110 | ? time3 != "000" && time3 != "999" |
111 | 111 | ? $"{time3.Substring(0, 2)}.{time3.Substring(2, 1)}" |
112 | 112 | : "-" |
@@ -115,7 +115,7 @@ namespace UmaTest.Infra.Helper | ||
115 | 115 | |
116 | 116 | public static string FormatTimeMSSF(string time4) |
117 | 117 | { |
118 | - return time4.Length == 4 | |
118 | + return time4?.Length == 4 | |
119 | 119 | ? time4 != "0000" |
120 | 120 | ? $"{time4.Substring(0, 1)}:{time4.Substring(1, 2)}.{time4.Substring(3, 1)}" |
121 | 121 | : "-" |
@@ -124,7 +124,7 @@ namespace UmaTest.Infra.Helper | ||
124 | 124 | |
125 | 125 | public static string FormatTimeHHMM(string time4) |
126 | 126 | { |
127 | - return time4.Length == 4 | |
127 | + return time4?.Length == 4 | |
128 | 128 | ? time4 != "0000" |
129 | 129 | ? $"{time4.Substring(0, 2)}:{time4.Substring(2, 2)}" |
130 | 130 | : "-" |
@@ -305,7 +305,7 @@ namespace UmaTest.Infra.Helper | ||
305 | 305 | |
306 | 306 | public static string ToNumber(string value) |
307 | 307 | { |
308 | - return ToNumber(value, value.Length, 0); | |
308 | + return !string.IsNullOrEmpty(value) ? ToNumber(value, value.Length, 0) : string.Empty; | |
309 | 309 | } |
310 | 310 | |
311 | 311 | public static string ToNumber(string value, int length, int digits) |
@@ -340,5 +340,55 @@ namespace UmaTest.Infra.Helper | ||
340 | 340 | |
341 | 341 | return Math.Round((number / pow10s[digits]), digits, MidpointRounding.AwayFromZero).ToString(digitFormats[digits]); |
342 | 342 | } |
343 | + | |
344 | + public static string FormatBabaJyotai(NRace race) | |
345 | + { | |
346 | + if (race == null) | |
347 | + { | |
348 | + return "-"; | |
349 | + } | |
350 | + | |
351 | + string sibaJyotai = CodeHelper.GetInstance().GetName(CodeHelper.BABA_JYOTAI_CODE, race.Sibababacd, string.Empty); | |
352 | + string dirtJyotai = CodeHelper.GetInstance().GetName(CodeHelper.BABA_JYOTAI_CODE, race.Dirtbabacd, string.Empty); | |
353 | + | |
354 | + string turfDirtName = CodeHelper.GetInstance().GetTurfDurtName(race.Trackcd, string.Empty); | |
355 | + | |
356 | + switch(turfDirtName) | |
357 | + { | |
358 | + case "芝": | |
359 | + return sibaJyotai; | |
360 | + case "ダ": | |
361 | + return dirtJyotai; | |
362 | + case "芝ダ": | |
363 | + return !string.IsNullOrEmpty(sibaJyotai) && !string.IsNullOrEmpty(dirtJyotai) ? sibaJyotai + "・" + dirtJyotai : string.Empty; | |
364 | + } | |
365 | + | |
366 | + return string.Empty; | |
367 | + } | |
368 | + | |
369 | + public static string FormatTosu(NRace race) | |
370 | + { | |
371 | + if (race == null) | |
372 | + { | |
373 | + return "-"; | |
374 | + } | |
375 | + | |
376 | + string syussoTosuu = SuppressZeroLeading(race?.Syussotosu); | |
377 | + | |
378 | + if ( !string.IsNullOrEmpty(syussoTosuu) && (syussoTosuu != "-") ) | |
379 | + { | |
380 | + return syussoTosuu; | |
381 | + } | |
382 | + | |
383 | + string torokuTosuu = SuppressZeroLeading(race?.Torokutosu); | |
384 | + | |
385 | + if ( !string.IsNullOrEmpty(torokuTosuu) && (torokuTosuu != "-") ) | |
386 | + { | |
387 | + return torokuTosuu; | |
388 | + } | |
389 | + | |
390 | + return string.Empty; | |
391 | + } | |
392 | + | |
343 | 393 | } |
344 | 394 | } |
@@ -1,5 +1,6 @@ | ||
1 | +create table app_uma_race_stddev as | |
1 | 2 | with v_uma_race_base1 as ( |
2 | -select distinct | |
3 | +select | |
3 | 4 | r.jyocd |
4 | 5 | , r.year |
5 | 6 | , r.monthday |
@@ -11,7 +12,7 @@ select distinct | ||
11 | 12 | when '702' then 'N' |
12 | 13 | when '703' then 'M' |
13 | 14 | else case |
14 | - when jyokencd5 = '000' then '-' | |
15 | + when jyokencd5 <= '000' then '-' | |
15 | 16 | when jyokencd5 <= '005' then '1' |
16 | 17 | when jyokencd5 <= '010' then '2' |
17 | 18 | when jyokencd5 <= '016' then '3' |
@@ -21,19 +22,21 @@ select distinct | ||
21 | 22 | else r.gradecd |
22 | 23 | end as gradecd |
23 | 24 | , r.syubetucd |
25 | + , ur.time | |
26 | + , ur.harontimel3 | |
24 | 27 | from |
25 | 28 | n_uma_race ur |
26 | 29 | inner join n_race r |
27 | 30 | using (year, jyocd, kaiji, nichiji, racenum) |
28 | -where | |
29 | - ur.kettonum in ('1985104409') | |
30 | 31 | ), v_uma_race_base2 as ( |
31 | -select distinct | |
32 | +select | |
32 | 33 | ur.jyocd |
33 | 34 | , ur.kyori |
34 | 35 | , ur.trackcd |
35 | 36 | , ur.gradecd |
36 | 37 | , ur.syubetucd |
38 | + , ur.time | |
39 | + , ur.harontimel3 | |
37 | 40 | , coalesce(max(c.kaishudate) |
38 | 41 | filter (where c.kaishudate <= ur.year || ur.monthday) |
39 | 42 | over (partition by ur.jyocd, ur.kyori, ur.trackcd, ur.gradecd, ur.syubetucd) |
@@ -43,37 +46,85 @@ from | ||
43 | 46 | v_uma_race_base1 ur |
44 | 47 | inner join n_course c |
45 | 48 | using(jyocd, kyori, trackcd) |
49 | +), v_uma_race_base3 as ( | |
50 | +select | |
51 | + ur.jyocd | |
52 | + , to_number(ur.kyori, '0000') as kyori | |
53 | + , ur.trackcd | |
54 | + , ur.gradecd | |
55 | + , ur.syubetucd | |
56 | + , ur.kaishudate | |
57 | + , case ur.time | |
58 | + when '0000' then null | |
59 | + when ' ' then null | |
60 | + else to_number(substring(ur.time, 1, 1), '0') * 600 | |
61 | + + to_number(substring(ur.time, 2, 2), '00') * 10 | |
62 | + + to_number(substring(ur.time, 4, 1), '0') | |
63 | + end as time | |
64 | + , case ur.harontimel3 | |
65 | + when '000' then null | |
66 | + when '999' then null | |
67 | + when ' ' then null | |
68 | + else to_number(substring(ur.harontimel3, 1, 2), '00') * 10 | |
69 | + + to_number(substring(ur.harontimel3, 3, 1), '0') | |
70 | + end as harontimel3 | |
71 | +from | |
72 | + v_uma_race_base2 ur | |
73 | +), v_uma_race as ( | |
74 | +select | |
75 | + ur.jyocd | |
76 | + , ur.kyori | |
77 | + , ur.trackcd | |
78 | + , ur.gradecd | |
79 | + , ur.syubetucd | |
80 | + , ur.kaishudate | |
81 | + , ur.time | |
82 | + , ur.harontimel3 | |
83 | + , case ur.harontimel3 | |
84 | + when null then null | |
85 | + else (ur.time - ur.harontimel3) * 600 / (ur.kyori - 600) | |
86 | + end as avgharontimeminus3 | |
87 | +from | |
88 | + v_uma_race_base3 ur | |
46 | 89 | ) |
47 | -SELECT ur.*, r.*, vur.*, urdev.* | |
48 | -FROM n_uma_race ur | |
49 | -INNER JOIN n_race r USING(year, jyocd, kaiji, nichiji, racenum) | |
50 | -LEFT JOIN n_uma u USING(kettonum) | |
51 | -LEFT JOIN v_uma_race_base2 vur | |
52 | - ON r.jyocd = vur.jyocd | |
53 | -AND r.kyori = vur.kyori | |
54 | -AND r.trackcd = vur.trackcd | |
55 | -AND vur.gradecd = case r.gradecd | |
56 | - when '' then case r.jyokencd5 | |
57 | - when '701' then 'N' | |
58 | - when '702' then 'N' | |
59 | - when '703' then 'M' | |
60 | - else case | |
61 | - when r.jyokencd5 = '000' then null | |
62 | - when r.jyokencd5 <= '005' then '1' | |
63 | - when r.jyokencd5 <= '010' then '2' | |
64 | - when r.jyokencd5 <= '016' then '3' | |
65 | - else 'OP' | |
66 | - end | |
67 | - end | |
68 | - else r.gradecd | |
69 | - end | |
70 | -AND r.syubetucd = vur.syubetucd | |
71 | -LEFT JOIN app_uma_race_stddev urdev | |
72 | - ON vur.jyocd = urdev.jyocd | |
73 | -AND vur.kyori = urdev.kyori | |
74 | -AND vur.trackcd = urdev.trackcd | |
75 | -AND vur.gradecd = urdev.gradecd | |
76 | -AND vur.syubetucd = urdev.syubetucd | |
77 | -AND vur.kaishudate = urdev.kaishudate | |
78 | -WHERE ur.kettonum in ('1985104409') | |
79 | -ORDER BY ur.kettonum, ur.year desc, ur.monthday desc | |
\ No newline at end of file | ||
90 | +select | |
91 | + ur.jyocd | |
92 | + , to_char(ur.kyori, 'FM0000') as kyori | |
93 | + , ur.trackcd | |
94 | + , ur.gradecd | |
95 | + , ur.syubetucd | |
96 | + , ur.kaishudate | |
97 | + , count(ur.time) as cnt | |
98 | + , min(ur.time) as time_min | |
99 | + , max(ur.time) as time_max | |
100 | + , round(avg(ur.time), 2) as time_avg | |
101 | + , round(stddev(ur.time), 2) as time_dev | |
102 | + , min(ur.harontimel3) as harontimel3_min | |
103 | + , max(ur.harontimel3) as harontimel3_max | |
104 | + , round(avg(ur.harontimel3), 2) as harontimel3_avg | |
105 | + , round(stddev(ur.harontimel3), 2) as harontimel3_dev | |
106 | + , round(min(ur.avgharontimeminus3), 2) as avgharontimeminus3_min | |
107 | + , round(max(ur.avgharontimeminus3), 2) as avgharontimeminus3_max | |
108 | + , round(avg(ur.avgharontimeminus3), 2) as avgharontimeminus3_avg | |
109 | + , round(stddev(ur.avgharontimeminus3), 2) as avgharontimeminus3_dev | |
110 | +from | |
111 | + v_uma_race ur | |
112 | +group by | |
113 | + ur.jyocd | |
114 | + , ur.kyori | |
115 | + , ur.trackcd | |
116 | + , ur.kaishudate | |
117 | + , ur.gradecd | |
118 | + , ur.syubetucd | |
119 | +order by | |
120 | + ur.jyocd | |
121 | + , ur.kyori | |
122 | + , ur.trackcd | |
123 | + , ur.gradecd | |
124 | + , ur.syubetucd | |
125 | + , ur.kaishudate | |
126 | +; | |
127 | +alter table app_uma_race_stddev add constraint pk_app_uma_race_stddev primary key (jyocd, kyori, trackcd, gradecd, syubetucd, kaishudate) | |
128 | +; | |
129 | +drop table app_uma_race_stddev | |
130 | +; |