ホテル管理システム
ogi
yesterday 1a1c8e71fcd14858f595029f089b2d4a00202b32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
ÿþusing System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Drawing;
using System.IO;
using System.Diagnostics;
using System.Net;
using System.Collections.Specialized;
using System.Net.Sockets;
using System.Security.Principal;
using HotelPms.Share.Windows.Component;
using Microsoft.Win32;
 
namespace HotelPms.Share.Windows.Util
{
    /// ****************************** Description *******************************
    /// Ç%·0¹0Æ0à0 Tðy
    /// 0Nl(u¯0é0¹0
    /// Ç%‚i‰
    /// 0ˆ0O0OF0¢•peƖ
    /// 0û0‡eW[R¢•pe(w•U00SQLybk‡eW[ÖN)
    ///   û0Inch0cm0dot   YÛc
    /// 0û0
    /// Ç%e\tk
    /// 020070803  \(g0ÝRŸ    °e‰\Ob
    ///   20071015  y0u  nœU    SqlStrEscape_All(),sqlStrEscape_SingleQuoteý R0 0' 0Ò! 0'' 0j0i00¨0¹0±0ü0×0æQt0
    /// ****************************** Declarations ******************************
    public class GeneralSub
    {
        /// <summary>
        /// 1 Inch = 2.54 Cm
        /// </summary>
        public const float INCH_TO_CM = 2.54F;
        public const int WM_COPYDATA = 0x004A;
        private const int GW_HWNDFIRST = 0;
        private const int GW_HWNDLAST = 1;
        private const int GW_HWNDNEXT = 2;
        private const int GW_HWNDPREV = 3;
 
        [DllImport("User32.Dll")]
        public static extern void GetWindowText(int h, StringBuilder s, int nMaxCount);
 
        [DllImport("user32")]
        private static extern int GetWindow(int hwnd, int wCmd);
 
        [StructLayout(LayoutKind.Sequential)]
        public struct COPYDATASTRUCT
        {
            public IntPtr dwData;
            public int cbData;
            [MarshalAs(UnmanagedType.LPStr)]
            public string lpData;
        }
 
        [DllImport("User32.dll", EntryPoint = "SendMessage")]
        private static extern int SendMessage(
        int hWnd,   //   handle   to   destination   window  
        int Msg,   //   message  
        int wParam,   //   first   message   parameter  
        ref   COPYDATASTRUCT lParam   //   second   message   parameter  
        );
 
        private const int WS_SHOWNORMAL = 1;
        private const Int32 AW_BLEND = 0x00080000;
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        private static extern bool SetForegroundWindow(IntPtr hWnd);
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        private static extern void SendMessageA(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
 
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int wndproc);
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
 
        public const int GWL_STYLE = -16;
        public const int WS_DISABLED = 0x8000000;
 
 
        [DllImport("user32.dll", SetLastError = true)]
        private static extern IntPtr GetSystemMenu(IntPtr hwnd, bool bRevert);
 
        [DllImport("user32.dll", SetLastError = true)]
        private static extern int GetMenuItemCount(IntPtr hMenu);
 
        [DllImport("user32.dll", SetLastError = true)]
        private static extern int RemoveMenu(IntPtr hMenu, int uPosition, int uFlags);
 
        private const int MF_BYPOSITION = 0x00000400;
        private static string SqlLimitChar = "',%[_";   //SQLybk‡eW[  0ÿ;ÿ?ÿ
 
        [DllImport("shfolder.dll", CharSet = CharSet.Auto)]
        private static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, int dwFlags, StringBuilder lpszPath);
        private const int MAX_PATH = 260;
        private const int CSIDL_COMMON_DESKTOPDIRECTORY = 0x0019;
        public static string GetAllUsersDesktopFolderPath()
        {
            StringBuilder sbPath = new StringBuilder(MAX_PATH);
            SHGetFolderPath(IntPtr.Zero, CSIDL_COMMON_DESKTOPDIRECTORY, IntPtr.Zero, 0, sbPath);
            return sbPath.ToString();
        }
 
 
        [DllImport("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize")]
        public static extern int SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize);
        /// <summary>
        /// 
        /// </summary>
        public static void FreeMemory()
        {
            GC.Collect();
            GC.WaitForPendingFinalizers();
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
            }
        }
 
        /// <summary>
        /// Windown0óS
Nn0×Ü0¿0ó0’0!q¹Rk0Y0‹0
        /// </summary>
        /// <param name="form"></param>
        public static void DisableFormSysMenuCloseButton(Form form)
        {
            IntPtr hWindow = form.Handle;
            IntPtr hMenu = GetSystemMenu(hWindow, false);
            int count = GetMenuItemCount(hMenu);
            RemoveMenu(hMenu, count - 1, MF_BYPOSITION);
            RemoveMenu(hMenu, count - 2, MF_BYPOSITION);
        }
 
        /// <summary>
        /// APIg0³0ó0È0í0ü0ë0’0 g¹Rû0!q¹Rk0Y0‹0
        /// </summary>
        /// <param name="c"></param>
        /// <param name="enabled"></param>
        public static void SetControlEnabled(Control c, bool enabled)
        {
            if (enabled)
            { SetWindowLong(c.Handle, GWL_STYLE, (~WS_DISABLED) & GetWindowLong(c.Handle, GWL_STYLE)); }
            else
            { SetWindowLong(c.Handle, GWL_STYLE, WS_DISABLED | GetWindowLong(c.Handle, GWL_STYLE)); }
        }
 
 
        #region &&&0Format¢•pe¤0&&&
 
        /// <summary>
        ///   "0"g0_pe’0Format
        /// </summary>
        /// <param name="hoObj">hoObj</param>
        /// <param name="MaxLenth">úQ›Rw•U0</param>
        /// <returns>string</returns>
        public static string Format(object hoObj, int MaxLenth)
        {
            return Format(hoObj, MaxLenth, '0', true);
        }
 
        /// <summary>
        ///   cš[‡eW[g0_pe’0Format
        /// </summary>
        /// <param name="hoObj">hoObj</param>
        /// <param name="MaxLenth">úQ›Rw•U0</param>
        /// <param name="formatChar">cš[‡eW[</param>
        /// <returns>string</returns>
        public static string Format(object hoObj, int MaxLenth, char formatChar)
        {
            return Format(hoObj, MaxLenth, formatChar, true);
        }
 
        /// <summary>
        ///   cš[‡eW[g0_pe’0Format
        /// </summary>
        /// <param name="hoObj">hoObj</param>
        /// <param name="MaxLenth">úQ›Rw•U0</param>
        /// <param name="formatChar">cš[‡eW[</param>
        /// <param name="IsBeforeAdd">...</param>
        /// <returns>string</returns>
        public static string Format(object hoObj, int MaxLenth, char formatChar, bool IsBeforeAdd)
        {
            try
            {
                string wsRet = hoObj.ToString();
                int wiLen = wsRet.Length;
                string wsFormat = new string(formatChar, MaxLenth);
                if (IsBeforeAdd == true)
                {
                    wsRet = wsFormat + wsRet;
                    wsRet = wsRet.Substring(wiLen);
                }
                else
                {
                    wsRet = wsRet + wsFormat;
                    wsRet = wsRet.Substring(0, MaxLenth);
                }
 
                return wsRet;
            }
            catch
            {
                return "";
            }
        }
 
        #endregion
   
        /// <summary>
        ///  Tðyg0³0ó0È0í0ü0ë0’0ÖS—_Y0‹0
        /// </summary>
        /// <param name="classInstance">classInstance(controlName’0cc0f0D0‹0¯0é0¹0)</param>
        /// <param name="controlName">controlName</param>
        /// <returns>object</returns>
        public static object GetControlByName(object classInstance, string controlName)
        {
            try
            {
                //return classInstance.GetType().GetField(controlName,
                //System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(classInstance);
 
                return classInstance.GetType().GetField(controlName, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(classInstance);
            }
            catch
            {
                return null;
            }
        }
 
        /// <summary>
        ///   ¯0é0¹0 Tg0CreateInstance
        /// </summary>
        /// <param name="hoObj">hoObj</param>
        /// <returns>string</returns>
        public static object? ClassForName(string codeBase, string hsClsName)
        {
            System.Reflection.Assembly woAssem = null;
            Type woType = null;
            try
            {
                woAssem = System.Reflection.Assembly.Load(codeBase);
                woType = woAssem.GetType(hsClsName);
                return Activator.CreateInstance(woType);
            }
            catch
            {
                return null;
            }
        }
 
        /// <summary>
        ///   ¯0é0¹0 Tg0CreateInstance
        /// </summary>
        /// <param name="hoObj">hoObj</param>
        /// <returns>string</returns>
        public static object? ClassForName(string hsClsName)
        {
            return ClassForName(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name, hsClsName);
        }
 
        /// <summary>
        ///   Call static member function by name
        /// </summary>
        /// <param name="codeBase">í0ü0É0Y0‹0 Assembly T</param>
        /// <param name="className">¯0é0¹0 T</param>
        /// <param name="memberName">static member T</param>
        /// <param name="memberName">_pe</param>
        /// <returns>object</returns>
        public static object CallStaticMember(string codeBase, string className, string memberName, object[] paraList)
        {
            System.Reflection.Assembly woAssem = null;
            Type woType = null;
            try
            {
                woAssem = System.Reflection.Assembly.Load(codeBase);
                woType = woAssem.GetType(className);
                return woType.InvokeMember(memberName, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod,
                                           null, null, paraList);
            }
            catch
            {
                return null;
            }
        }
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="codebase">Projectn0 Tðyÿ‹OH0p0 Forms0Lib</param>
        /// <param name="clsName"></param>
        /// <returns></returns>
        public static string GetCloneCode(string codebase, string clsName)
        {
            object item = ClassForName(codebase, clsName);
            Type woType = item.GetType();
            FieldInfo[] woFields = woType.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static);
            string ret = string.Empty;
 
            for (int i = 0; i < woFields.Length; i++)
            {
                int len = woFields[i].Name.Length;
                string name = woFields[i].Name.Substring(0, 1).ToUpper() + woFields[i].Name.Substring(1);
                if (name.StartsWith("M_")) { name = name.Substring(2); }
 
                if (woFields[i].FieldType.FullName.Contains("System.Collections.Generic.List"))
                {
                    ret += string.Format("item.{0} = new List<{0}>(); ", name) + Environment.NewLine;
                }
                else
                {
                    ret += string.Format("item.{0} = {1}; ", name, woFields[i].Name) + Environment.NewLine;
                }
            }
            return ret;
        }
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="codebase">Projectn0 Tðyÿ‹OH0p0 Forms0Lib</param>
        /// <param name="clsName"></param>
        /// <returns></returns>
        public static string GetConvertDataRowCode(string codebase, string clsName)
        {
            object item = ClassForName(codebase, clsName);
            Type woType = item.GetType();
            FieldInfo[] woFields = woType.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static);
            string ret = string.Empty;
 
            for (int i = 0; i < woFields.Length; i++)
            {
                //int len = woFields[i].Name.Length;
                string name = woFields[i].Name.Replace("m_", "");
                name = name.Substring(0, 1).ToUpper() + name.Substring(1);
 
                if (woFields[i].FieldType.FullName.Contains("System.Collections.Generic.List")) { continue; }
                if (woFields[i].FieldType.FullName.Contains("System.Data.DataSet")) { continue; }
 
                if ("System.Boolean".Equals(woFields[i].FieldType.FullName))
                {
                    ret += string.Format("this.{1} = CConvert.ToBool(row[\"{0}\"]); ", name, woFields[i].Name) + Environment.NewLine;
                }
                else if ("System.Decimal".Equals(woFields[i].FieldType.FullName))
                {
                    ret += string.Format("this.{1} = CConvert.ToDecimal(row[\"{0}\"]); ", name, woFields[i].Name) + Environment.NewLine;
                }
                else if ("System.Int32".Equals(woFields[i].FieldType.FullName))
                {
                    ret += string.Format("this.{1} = CConvert.ToInt(row[\"{0}\"],{1}); ", name, woFields[i].Name) + Environment.NewLine;
                }
                else if ("System.String".Equals(woFields[i].FieldType.FullName))
                {
                    ret += string.Format("this.{1} = row[\"{0}\"].ToString(); ", name, woFields[i].Name) + Environment.NewLine;
                }
                else if ("System.DateTime".Equals(woFields[i].FieldType.FullName))
                {
                    ret += string.Format("this.{1} = row.IsNull(\"{0}\") ? DateTime.MinValue : (System.DateTime)row[\"{0}\"]; ", name, woFields[i].Name) + Environment.NewLine;
                }
                else
                {
                    ret += string.Format("this.{1} = ({2})ConvertDBValue(row[\"{0}\"],{1}); ", name, woFields[i].Name, woFields[i].FieldType.FullName) + Environment.NewLine;
                }
            }
            return ret;
        }
 
        /// <summary> þ[aŒ³0ó0È0í0ü0ë0…Qn0hQf0n0³0ó0È0í0ü0ë0n0Rc
        /// </summary>
        /// <param name="top">Q0^Y0‹0gRn0³0ó0È0í0ü0ë0</param>
        /// <returns>³0ó0È0í0ü0ë0n0ê0¹0È0</returns>
        public static string GetFormAllControlCode(Control top)
        {
            //System.Collections.ArrayList buf = new System.Collections.ArrayList();
 
            StringBuilder buf = new StringBuilder();
 
            foreach (Control c in top.Controls)
            {
                if (c.Name.Length == 0) { continue; }
                buf.AppendLine(string.Format("  case \"{0}\":", c.Name));
                buf.AppendLine(string.Format("      return {0};", c.Name));
 
                if (c.Controls.Count > 0)
                {
                    buf.AppendLine("");
                    buf.AppendLine(string.Format("  #region {0}", c.Name));
                    buf.Append(GetFormAllControlCode(c));
                    buf.AppendLine("  #endregion");
                    buf.AppendLine("");
                }
            }
 
            return buf.ToString();
        }
 
 
        /// <summary>SQLybk‡eW[ Ç0ü0¿0Ù0ü0¹0æQtþ[Ü_n0ºpn0‡eW[   YÛc ''h0[]g0òV€0
        /// </summary>
        /// <param name="InString"></param>
        /// <returns></returns>
        public static string sqlStrEscape_All(string InString)
        {
            string tmpString = string.Empty;
            string outString = string.Empty;
 
            for (int i = 0; i < InString.ToString().Length; i++)
            {
                tmpString = InString.ToString().Substring(i, 1);
 
                switch (tmpString.ToString())
                {
                    // INSERT , UPDATE , SELECT (  0= 0 0LIKE 0h0‚0k0Å_‰) j0i0k0f0   YÛcL0Å_‰
                    case "'":
                        tmpString = tmpString.ToString().Replace("'", "''");
                        break;
                    // SELECT (  0LIKE 0O(uBfk0Å_‰)k0f0 YÛcL0Å_‰
                    case "%":
                        tmpString = tmpString.ToString().Replace("%", "[%]");
                        break;
                    case "[":
                        tmpString = tmpString.ToString().Replace("[", "[[]");
                        break;
                    case "_":
                        tmpString = tmpString.ToString().Replace("_", "[_]");
                        break;
 
 
                    default:
                        break;
                }
 
                outString = outString + tmpString.ToString();
 
            }
 
            return outString;
        }
 
        /// <summary>SQLybk‡eW[ Ç0ü0¿0Ù0ü0¹0æQtþ[Ü_n0ºpn0‡eW[   YÛc( 0' 0Ò! 0'' 0n00   ÿ
        /// </summary>
        /// <param name="InString"></param>
        /// <returns></returns>
        public static string sqlStrEscape_SingleQuote(string InString)
        {
            string tmpString = string.Empty;
            string outString = string.Empty;
 
            for (int i = 0; i < InString.ToString().Length; i++)
            {
                tmpString = InString.ToString().Substring(i, 1);
 
                switch (tmpString.ToString())
                {
                    // INSERT , UPDATE , SELECT (  0= 0h0 0LIKE 0h0‚0k0Å_‰) j0i0k0f0 YÛcL0Å_‰
                    case "'":
                        tmpString = tmpString.ToString().Replace("'", "''");
                        break;
 
 
                    default:
                        break;
                }
 
                outString = outString + tmpString.ToString();
 
            }
 
            return outString;
        }
 
        /// <summary>SQLybk‡eW[  ‡eW[Rn0-Nk0SQLybk‡eW[L0+T~0Œ0f0D0‹0K0i0F0K0
        /// </summary>
        /// <param name="value">‡eW[R</param>
        /// <returns></returns>
        public static string GetSqlLimitChar(string value)
        {
            for (int i = 0; i <= value.Length - 1; i++)
            {
                if (SqlLimitChar.IndexOf(value[i]) != -1)
                {
                    return value[i].ToString();
                }
            }
            return string.Empty;
        }
 
        
 
        public static void SetWindowActive(System.Diagnostics.Process process)
        {
            //IntPtr hwnd = FindWindow(null, "[!|f)R(ui"}n0agöNeQ›R]");
            //ShowWindowAsync(hwnd, WS_SHOWNORMAL);
            //SetForegroundWindow(hwnd);
 
            int i = 0;
            while (process.MainWindowHandle.ToInt32() == 0 && i < 100)
            {
                System.Threading.Thread.Sleep(500);
                process.Refresh();
                i++;
            }
            ShowWindowAsync(process.MainWindowHandle, WS_SHOWNORMAL);
            SetForegroundWindow(process.MainWindowHandle);
 
            //click
            //SendMessageA(process.MainWindowHandle, 513, IntPtr.Zero, IntPtr.Zero);
            //SendMessageA(process.MainWindowHandle, 514, IntPtr.Zero, IntPtr.Zero);
        }
 
        public static bool ToBool(string value)
        {
            try
            {
                return bool.Parse(value);
            }
            catch
            {
                return false;
            }
        }
 
        public static int FindWindowByText(int hwnd, string text)
        {
            StringBuilder nameBuffer = null;
            int hwndTarget = GetWindow(hwnd, GW_HWNDFIRST);
            while (hwndTarget != 0)
            {
                nameBuffer = new StringBuilder(1024);
                GetWindowText(hwndTarget, nameBuffer, nameBuffer.Capacity);
                if (nameBuffer.ToString().Contains(text))
                {
                    return hwndTarget;
                }
 
                hwndTarget = GetWindow(hwndTarget, GW_HWNDNEXT);
            }
            return 0;
        }
 
        public static bool SendMsgToWindow(int hwnd, string winText, string sendText)
        {
            int WINDOW_HANDLER = FindWindowByText(hwnd, winText);
            if (WINDOW_HANDLER == 0)
            {
                return false;
            }
 
            byte[] sarr = System.Text.Encoding.Default.GetBytes(sendText);
            int len = sarr.Length;
            COPYDATASTRUCT cds;
            cds.dwData = (IntPtr)100;
            cds.lpData = sendText;
            cds.cbData = len + 1;
            SendMessage(WINDOW_HANDLER, WM_COPYDATA, 0, ref cds);
            return true;
        }
 
        /// <summary>
        /// Ç0ü0¿0Ù0ü0¹0n0peW[‹WÇ0ü0¿0’0;ub—k0hˆ:yY0‹0Bfk00 0-1 0or 00 0n04XTo00zz}vk0Y0‹0
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string ToFormText(int value)
        {
            if (value == -1 || value == 0)
            {
                return string.Empty;
            }
            else
            {
                return value.ToString();
            }
        }
 
        public static string ToFormTextPlus(int value)
        {
            if (value < 0)
            {
                return string.Empty;
            }
            else
            {
                return value.ToString();
            }
        }
 
        /// <summary>
        /// ³0ó0È0í0ü0ë0Õ0©0Ã0«0¹0g0M0‹0K0i0F0K0
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static bool CtrlCanFocus(Control obj)
        {
            if (obj is CTextBox)
            {
                if ((obj as CTextBox).Enabled && (obj as CTextBox).Visible)
                {
                    return true;
                }
            }
            else
            {
                if (obj.Enabled && obj.Visible)
                {
                    return true;
                }
            }
            return false;
        }
 
        /// <summary>
        /// GetWeekOfMonth
        /// </summary>
        /// <param name="dtSel"></param>
        /// <returns></returns>
        public static int GetWeekOfMonth(DateTime dtSel)
        {
            if (dtSel.Day == 1)
            {
                return 0;
            }
            DateTime dtStart = new DateTime(dtSel.Year, dtSel.Month, 1);
            int dayofweek = (int)dtStart.DayOfWeek;
            int startWeekDays = 7 - dayofweek;
            if (dtSel.Day <= startWeekDays)
            {
                return 0;
            }
            int aday = dtSel.Day + 7 - startWeekDays;
            return (aday / 7 + (aday % 7 > 0 ? 1 : 0)) - 1;
        }
        /// <summary>
        /// GetDayWeekCode
        /// </summary>
        /// <param name="dt_CheckDay_A"></param>
        /// <returns></returns>
        public static int GetDayWeekCode(DateTime dt_CheckDay_A)
        {
            int nDayWeek = 0;
            switch (dt_CheckDay_A.DayOfWeek.ToString())                // Nåen0ÜfåeÁ0§0Ã0¯0
            {
                case "Sunday":
                    nDayWeek = 0;
                    break;
                case "Monday":
                    nDayWeek = 1;
                    break;
                case "Tuesday":
                    nDayWeek = 2;
                    break;
                case "Wednesday":
                    nDayWeek = 3;
                    break;
                case "Thursday":
                    nDayWeek = 4;
                    break;
                case "Friday":
                    nDayWeek = 5;
                    break;
                case "Saturday":
                    nDayWeek = 6;
                    break;
                default:
                    break;
            }
            return nDayWeek;
        }
 
        /// <summary>
        /// ³0ó0È0í0ü0ë0n0MOn’0Š—{Y0‹0
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="location"></param>
        public static void GetLocationToScreen(Control obj, ref System.Drawing.Point location)
        {
            location.X += obj.Location.X;
            location.Y += obj.Location.Y;
            if (obj.Parent is Form) { return; }
            GetLocationToScreen(obj.Parent, ref location);
        }
 
        /// <summary>
        /// DataGridViewn0PopUpMOn’0ԏY0
        /// </summary>
        /// <param name="ownerForm"></param>
        /// <param name="grid"></param>
        /// <returns></returns>
        public static System.Drawing.Point GetPopUpLocation(Form ownerForm, DataGridView grid)
        {
            System.Drawing.Point location = ownerForm.PointToScreen(new System.Drawing.Point(0, 0));
            GeneralSub.GetLocationToScreen(grid, ref location);
            //for (int i = 0; i < grid.CurrentCell.ColumnIndex; i++)
            //{
            //    if (!grid.Columns[i].Visible) { continue; }
            //    location.X += grid.Columns[i].Width;
            //}
            for (int i = 0; i < grid.ColumnCount; i++)
            {
                if (!grid.Columns[i].Visible) { continue; }
                if (grid.Columns[i].DisplayIndex >= grid.Columns[grid.CurrentCell.ColumnIndex].DisplayIndex) { continue; }
                location.X += grid.Columns[i].Width;
            }
 
            location.X += 3;
            location.X -= grid.HorizontalScrollingOffset;
            location.Y += grid.ColumnHeadersHeight;
            location.Y += grid.Rows[0].Height * (grid.CurrentCell.RowIndex - grid.FirstDisplayedScrollingRowIndex + 1);
            location.Y += 1;
            return location;
        }
 
        public static System.Drawing.Point GetPopUpLocationEx(Form ownerForm, DataGridView grid)
        {
            System.Drawing.Point location = ownerForm.PointToScreen(new System.Drawing.Point(0, 0));
            GeneralSub.GetLocationToScreen(grid, ref location);
            for (int i = 0; i < grid.CurrentCell.ColumnIndex; i++)
            {
                location.X += grid.Columns[i].Width;
            }
            location.X += 3;
            location.X -= grid.HorizontalScrollingOffset;
            location.Y += (grid.ColumnHeadersVisible ? grid.ColumnHeadersHeight : 0);
            for (int i = grid.FirstDisplayedScrollingRowIndex; i <= grid.CurrentCell.RowIndex; i++)
            {
                location.Y += grid.Rows[i].Height;
            }
            location.Y += 1;
            return location;
        }
 
        /// <summary> IDEâ0ü0É0K0i0F0K0
        /// </summary>
        /// <returns></returns>
        public static bool IsIdeMode()
        {
            return (Environment.CommandLine.Contains(".vshost.exe"));
        }
 
 
 
        /// <summary> ‡eW[R’0cš[W0_0Ð0¤0È0k0Y0‹0('YM0D04XTo0óStP’0«0Ã0È00\U0D04XTo0óStPk0zz}v?ceQ)
        /// </summary>
        /// <param name="Xstr">‡eW[R</param>
        /// <param name="Bytes">š[W0_0w•U0</param>
        /// <returns>string</returns>
        public static string Xformat(string Xstr, int Bytes)
        {
            try
            {
                if ("".Equals(Xstr))
                {
                    return new string(' ', Bytes);
                }
                Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);  //NET5g0Shift-JIS’0qbF0¹eÕl
                System.Text.Encoding enc = System.Text.Encoding.GetEncoding("Shift_JIS");  //sjis
                byte[] wvBuff = enc.GetBytes(Xstr.ToString() + new string(' ', Bytes));// 'abcde     '
                return enc.GetString(wvBuff, 0, Bytes);
            }
            catch
            {
                return new string(' ', Bytes);
            }
        }
 
        /// <summary> ‡eW[R’0cš[W0_0Ð0¤0È0k0Y0‹0('YM0D04XTo0æ]tP’0«0Ã0È00\U0D04XTo0æ]tPk0zz}v?ceQ)
        /// </summary>
        /// <param name="Xstr"></param>
        /// <param name="Bytes"></param>
        /// <returns></returns>
        public static string XformatL(string Xstr, int Bytes)
        {
            try
            {
                if ("".Equals(Xstr))
                {
                    return new string(' ', Bytes);
                }
                Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);  //NET5g0Shift-JIS’0qbF0¹eÕl
                System.Text.Encoding enc = System.Text.Encoding.GetEncoding("Shift_JIS");  //sjis
                byte[] wvBuff = enc.GetBytes(new string(' ', Bytes) + Xstr.ToString());// '     abcde'
                return enc.GetString(wvBuff, wvBuff.Length - Bytes, Bytes);
            }
            catch
            {
                return new string(' ', Bytes);
            }
        }
 
        /// <summary> valuen0æ]K0‰0length‡eW[’0RŠ0ÖSŠ0
        /// </summary>
        /// <param name="value"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        public static string Left(string value, int length)
        {
            try
            {
                if (value.Length <= length) { return value; }
                return value.Substring(0, length);
            }
            catch
            {
                return string.Empty;
            }
        }
 
 
        /// <summary>‡eW[Ro0cš[W0_0w•U0g00'YM0D04XTo0R‹00\U0D04XTo0‹kŠ0’0ԏY0</summary>
        /// <param name="Xstr">‡eW[R</param>
        /// <param name="startIdx">‹•ËYMOn0^ÿ</param>
        /// <param name="Bytes">cš[W0_0w•U0</param>
        /// <returns>string</returns>
        public static string MidB(string Xstr, int startIdx, int Bytes)
        {
            try
            {
                string result = string.Empty;//liu 2010/03/17 add
                Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);  //NET5g0Shift-JIS’0qbF0¹eÕl
                System.Text.Encoding enc = System.Text.Encoding.GetEncoding("Shift_JIS");  //sjis
                byte[] wvBuff = enc.GetBytes(Xstr.ToString());
                //if (wvBuff.Length < startIdx + Bytes) { return Xstr; }
                //if (wvBuff.Length < startIdx + Bytes) { return string.Empty; }//liu 2010/03/17 //Redmne#9256 
 
                //20170608 Ûk)R Redmne#9256 startIdx ÿBytesˆ0Š0‚0\U0D0h0M0o00startIdxK0‰0n0‹kŠ0’0ԏY0ˆ0F0k0Y0‹0
                if (wvBuff.Length <= startIdx) { return string.Empty; }//‹•ËYMOnL0X[(WW0j0D0
                if (wvBuff.Length - startIdx < Bytes) { Bytes = wvBuff.Length - startIdx; }//‹•ËYMOnK0‰0‹kŠ0h0RŠ0ÖSŠ0w•U0n0¿Šte
 
                result = enc.GetString(wvBuff, startIdx, Bytes);
                if (enc.GetByteCount(result) > Bytes) { result = result.Substring(0, result.Length - 1); }//liu 2010/03/17 add
                return result;
            }
            catch
            {
                return Xstr;
            }
        }
 
        /// <summary> XstrK0‰0Bytes‡eW[’0RŠ0ÖSŠ0(ByteXSMO0RŒ0‹04XTo0JS҉R!qW0h0j0‹0)
        /// </summary>
        /// <param name="Xstr"></param>
        /// <param name="Bytes"></param>
        /// <returns></returns>
        public static string MidB(string Xstr, int Bytes)
        {
            try
            {
                string result = string.Empty;
                Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);  //NET5g0Shift-JIS’0qbF0¹eÕl
                System.Text.Encoding enc = System.Text.Encoding.GetEncoding("Shift_JIS");  //sjis
                int strbytelen = 0;
                for (int i = 0; i < Xstr.Length; i++)
                {
                    string strChar = Xstr.Substring(i, 1);
                    strbytelen += enc.GetByteCount(strChar);
                    if (strbytelen > Bytes) { break; }
                    result += strChar;
                }
                return result;
            }
            catch
            {
                return string.Empty.PadLeft(Bytes);
            }
        }
 
        /// <summary> cš[W0_0Ð0¤0È0peg0‡eW[’09eLˆY0‹0(List)
        /// </summary>
        /// <param name="value"></param>
        /// <param name="lineByteSize"></param>
        /// <returns></returns>
        public static List<string> GetMultLine(string value, int lineByteSize)
        {
            List<string> list = new List<string>();
            if (value.Length == 0) { list.Add(new string(' ', lineByteSize)); return list; }
 
            int totalLen = GetStrLenB(value);
            int len = 0;
            string remain = value;
            while (len < totalLen)
            {
                string line = GeneralSub.MidB(remain, lineByteSize);
                len += GetStrLenB(line);
                remain = remain.Substring(line.Length);
                list.Add(PadRightB(line, lineByteSize));
            }
            return list;
        }
 
        /// <summary> cš[W0_0Ð0¤0È0peg0‡eW[’09eLˆY0‹0(string)
        /// </summary>
        /// <param name="value"></param>
        /// <param name="lineByteSize">ByteXSMO0RŒ0‹04XTo0JS҉R!qW0h0j0‹0</param>
        /// <param name="canMinLineWord">1Lˆn0gNO‡eW[pe0S0Œ0’0…H0‹0h0
Nn0Lˆk0ý RY0‹0(‡eW[pe)</param>
        /// <param name="maxLine">1åN
N’0cš[W0_04XT]0n0Lˆpe~0g0’0ԏY0</param>
        /// <returns></returns>
        public static string GetMultLineB(string value, int lineByteSize, int canMinLineWord, int maxLine)
        {
            if (value.Length > 0)
            {
                int lineCount = 0;
                string ret = string.Empty;
                string tmp = string.Empty;
                do
                {
                    tmp = GeneralSub.MidB(value, lineByteSize);
                    value = value.Replace(tmp, "");
 
                    ret += (ret.Length > 0 ? Environment.NewLine : "") + tmp;
                    if (value.Length <= canMinLineWord)
                    {
                        ret += value;
                        break;
                    }
                    lineCount++;
                    if (maxLine > 0 && lineCount >= maxLine) break;
                }
                while (value.Length > canMinLineWord);
                value = ret;
            }
            return value;
        }
 
        /// <summary> Ð0¤0È0pek0j0‹0~0g0æ]tPk0‡eW[ËW0(JS҉zz}v)
        /// </summary>
        /// <param name="value"></param>
        /// <param name="totalByte"></param>
        /// <returns></returns>
        public static string PadLeftB(string value, int totalByte)
        {
            return PadLeftB(value, totalByte, ' ');
        }
 
        /// <summary> Ð0¤0È0pek0j0‹0~0g0æ]tPk0‡eW[ËW0(ËW0‡eW[cš[)
        /// </summary>
        /// <param name="value"></param>
        /// <param name="totalByte"></param>
        /// <param name="paddingChar"></param>
        /// <returns></returns>
        public static string PadLeftB(string value, int totalByte, char paddingChar)
        {
            string line = GeneralSub.MidB(value, totalByte);
            int remainCount = totalByte - GetStrLenB(line);
            if (remainCount > 0) { line = new string(paddingChar, remainCount) + line; }
            return line;
        }
 
        /// <summary> Ð0¤0È0pek0j0‹0~0g0óStPk0‡eW[ËW0(JS҉zz}v)
        /// </summary>
        /// <param name="value"></param>
        /// <param name="totalByte"></param>
        /// <returns></returns>
        public static string PadRightB(string value, int totalByte)
        {
            return PadRightB(value, totalByte, ' ');
        }
 
        /// <summary> Ð0¤0È0pek0j0‹0~0g0óStPk0‡eW[ËW0(ËW0‡eW[cš[)
        /// </summary>
        /// <param name="value"></param>
        /// <param name="totalByte"></param>
        /// <param name="paddingChar"></param>
        /// <returns></returns>
        public static string PadRightB(string value, int totalByte, char paddingChar)
        {
            string line = GeneralSub.MidB(value, totalByte);
            int remainCount = totalByte - GetStrLenB(line);
            if (remainCount > 0) { line += new string(paddingChar, remainCount); }
            return line;
        }
 
        /// <summary> JS҉¹0Ú0ü0¹0
        /// </summary>
        /// <param name="count"></param>
        /// <returns></returns>
        public static string Space(int count)
        {
            return new string(' ', count);
        }
 
        /// <summary> hQ҉¹0Ú0ü0¹0
        /// </summary>
        /// <param name="count"></param>
        /// <returns></returns>
        public static string SpaceDouble(int count)
        {
            return new string('0', count);
        }
 
        /// <summary> ‡eW[Rn0Ð0¤0È0pe’0Bl0‹0
        /// </summary>
        /// <param name="Xstr"></param>
        /// <returns></returns>
        public static int GetStrLenB(string Xstr)
        {
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);  //NET5g0Shift-JIS’0qbF0¹eÕl
            System.Text.Encoding enc = System.Text.Encoding.GetEncoding("Shift_JIS");  //sjis
            return enc.GetBytes(Xstr.ToString()).Length;
        }
 
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="g"></param>
        /// <returns></returns>
        public static string GetFitArea(string value, Graphics g, Font font, float maxWidth, GraphicsUnit pageUnit)
        {
            string itemName = value;
            g.PageUnit = pageUnit;
            float allWidth = g.MeasureString(itemName, font).Width;
            if (allWidth > maxWidth)
            {
                while (itemName.Length > 0)
                {
                    itemName = itemName.Substring(0, itemName.Length - 1);
                    allWidth = g.MeasureString(itemName, font).Width;
                    if (allWidth <= maxWidth) { break; }
                }
            }
            return itemName;
        }
 
        public static Encoding GetEncoding(string fileName)
        {
            //return GetEncoding(fileName, Encoding.Default);
            //StreamReader sr = new StreamReader(fileName, Encoding.Default);
            StreamReader sr = new StreamReader(fileName, Encoding.Default);
            sr.ReadToEnd();
            Encoding encoding = sr.CurrentEncoding;
            sr.Close();
            if (encoding.CodePage == 932)
            {
                string fsjis = System.IO.File.ReadAllText(fileName, Encoding.Default);    //SJIS
                string fjis = System.IO.File.ReadAllText(fileName, Encoding.GetEncoding(50221));  //JIS
                if (fjis.Length < fsjis.Length) { encoding = Encoding.GetEncoding(50221); }
            }
            return encoding;
        }
 
        /// <summary> þ[aŒ³0ó0È0í0ü0ë0…Qn0hQf0n0³0ó0È0í0ü0ë0n0Rc
        /// </summary>
        /// <param name="top">Q0^Y0‹0gRn0³0ó0È0í0ü0ë0</param>
        /// <returns>³0ó0È0í0ü0ë0n0ê0¹0È0</returns>
        public static Control[] GetAllControls(Control top)
        {
            //System.Collections.ArrayList buf = new System.Collections.ArrayList();
 
            List<Control> buf = new List<Control>();
 
            foreach (Control c in top.Controls)
            {
                buf.Add(c);
                buf.AddRange(GetAllControls(c));
            }
 
            return (Control[])buf.ToArray();
        }
 
        /// <summary> þ[aŒ³0ó0È0í0ü0ë0…Qn0NôY0‹0¿0¤0×0’0Nd0ԏY0
        /// </summary>
        /// <param name="top">Q0^Y0‹0gRn0³0ó0È0í0ü0ë0</param>
        /// <param name="type">NôY0‹0¿0¤0×0</param>
        /// <returns>³0ó0È0í0ü0ë0</returns>
        public static Control GetFirstControl(Control top, Type type)
        {
            foreach (Control c in top.Controls)
            {
                if (c.GetType().Equals(type)) { return c; }
                Control obj = GetFirstControl(c, type);
                if (obj != null) { return obj; }
            }
 
            return null;
        }
 
        /// <summary>
        /// ª‰Õ0©0ü0à0n0ÖS—_
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static Form GetOwnerForm(Control obj)
        {
            if (obj.Parent == null) { return null; }
            else if (obj.Parent is Form) { return obj.Parent as Form; }
            else { return GetOwnerForm(obj.Parent); }
        }
 
        /// <summary>
        /// ·0¹0Æ0à0.z%R
        /// </summary>
        /// <returns></returns>
        public static string GetOpertatingSystemName()
        {
            System.OperatingSystem os = System.Environment.OSVersion;
            string name = "Unknown";
 
            switch (os.Platform)
            {
                case System.PlatformID.Win32Windows:
                    switch (os.Version.Minor)
                    {
                        case 0:
                            name = "Windows 95";
                            break;
 
                        case 10:
                            name = "Windows 98";
                            break;
 
                        case 90:
                            name = "Windows ME";
                            break;
                    }
                    break;
 
                case System.PlatformID.Win32NT:
                    switch (os.Version.Major)
                    {
                        case 3:
                            name = "Windws NT 3.51";
                            break;
 
                        case 4:
                            name = "Windows NT 4";
                            break;
 
                        case 5:
                            switch (os.Version.Minor)
                            {
                                case 0:
                                    name = "Windows 2000";
                                    break;
                                case 1:
                                    name = "Windows XP";
                                    break;
                                case 2:
                                    name = "Windows Server 2003";
                                    break;
                            }
                            break;
 
                        case 6:
                            switch (os.Version.Minor)
                            {
                                case 0:
                                    name = "Windows Vista";
                                    break;
                                case 1:
                                    name = "Windows 7";
                                    break;
 
                            }
                            break;
                    }
                    break;
            }
 
            return name;
        }
 
        /// <summary>
        ///  Tðyk0ˆ0‹0Enumk0X[(WY0‹0K0i0F0K0
        /// </summary>
        /// <param name="enumType"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static bool IsExistsEnumName(Type enumType, string name)
        {
            try
            {
                object value = Enum.Parse(enumType, name);
                return (value != null);
            }
            catch
            {
                return false;
            }
        }
 
        /// <summary>
        /// DOS ³0Þ0ó0É0n0Ÿ[Lˆ
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        public static string ExecuteDosCmd(string cmd)
        {
            using (Process process = new Process())
            {
                process.StartInfo.FileName = "cmd.exe";
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.RedirectStandardInput = true;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.RedirectStandardError = true;
                process.StartInfo.CreateNoWindow = true;
 
                process.Start();
                process.StandardInput.WriteLine(cmd);
                process.StandardInput.WriteLine("exit");
                string myResult = process.StandardOutput.ReadToEnd();
                process.Close();
                return myResult;
            }
        }
 
        /// <summary>
        /// ¡{t€¹e_g0cmd’0Ÿ[Lˆ
        /// </summary>
        /// <returns></returns>
        public static bool RunCmd()
        {
            try
            {
                using (Process myPro = new Process())
                {                    
                    ProcessStartInfo psi = new ProcessStartInfo("cmd.exe");
                    psi.Verb = "runas";
                    myPro.StartInfo = psi;
                    myPro.Start();
                    myPro.WaitForExit();
                    return true;
                }
            }
            catch
            {
                return false;
            } 
        } 
 
        /// <summary>
        /// cš[W0_0ؚU0k0a0‡0F0i0J0U00‹0Font’0ԏY0
        /// </summary>
        /// <param name="text">Á0§0Ã0¯0Y0‹0‡eW[R</param>
        /// <param name="height">ÎS0_0D0ؚU0</param>
        /// <param name="f">.~\‹•ËYFont</param>
        /// <param name="g">æQt(uGraphics</param>
        /// <param name="sf">æQt(uStringFormat</param>
        /// <returns></returns>
        public static Font SetCollectFontSize(string text, int height, Font f, Graphics g, StringFormat sf)
        {
            bool ok = false;
 
            while (!ok)
            {
                SizeF sff = g.MeasureString(text, f, 50, sf);
 
                Size sfff = new Size((int)(sff.Width), (int)(sff.Height));
 
                if (height < sfff.Height)
                {
                    if (f.Size <= 1.0)
                    {
                        ok = true;
                    }
                    else
                    {
                        f = new Font(f.FontFamily.Name, f.Size - 0.5f);
                    }
                }
                else
                {
                    ok = true;
                }
            }
 
            return f;
        }
 
        /// <summary> DataGridViewn0Ç0Õ0©0ë0È0’0-Šš[
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="isAlternatingRows"></param>
        public static void InitDataGridView(DataGridView grid, bool isAlternatingRows)
        {
            grid.ReadOnly = true;
            grid.EnableHeadersVisualStyles = false;
            //»0ë0n0ƒXLuÚ}’0N͑Ú}k0Y0‹0
            grid.CellBorderStyle = DataGridViewCellBorderStyle.Single;
            grid.ForeColor = System.Drawing.Color.Black;
            if (isAlternatingRows) { grid.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(255, 216, 228, 248); }
            grid.AutoGenerateColumns = true;
            grid.RowHeadersVisible = false;
            grid.AllowUserToAddRows = false;
            grid.AllowUserToDeleteRows = false;
            grid.AllowUserToResizeColumns = true;
            grid.AllowUserToResizeRows = false;
            grid.MultiSelect = false;
            grid.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
        }
 
        /// <summary> …_a0
        /// </summary>
        /// <param name="milliseconds"></param>
        public static void Wait(double milliseconds)
        {
            DateTime t = DateTime.Now.AddMilliseconds(milliseconds);
            while (DateTime.Now < t) 
            { 
                Application.DoEvents();
                if (DateTime.Now.AddMilliseconds(milliseconds + 1000) < t) { break; }  //-Ng0·0¹0Æ0à0Bf“•   Y0c0_0ÿÿ
            }
        }
       
        /// <summary> êRIPn0ÖS—_
        /// </summary>
        /// <returns></returns>
        public static List<string> GetLocalIpv4()
        {
            IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName());
            List<string> IpCollection = new List<string>();
            foreach (IPAddress ip in localIPs)
            {
                if (ip.AddressFamily == AddressFamily.InterNetwork) { IpCollection.Add(ip.ToString()); }
            }
            return IpCollection;
        }
 
 
        /// <summary> êRn0¢•peCQn0Å`1X’0hˆ:y
        /// </summary>
        /// <param name="isAll">true:gRK0‰0þs(W~0g0hQ萠/ false:r0h0d0MR~0g0</param>
        /// <param name="isIncludeMe">true:êR‚0hˆ:y / false:^—hˆ:y</param>
        /// <param name="isExtractSameFanctionName">true:͑‰Y0‹0¢•peo0d–O0 / false:͑‰Y0‹0¢•pe‚0d–K0j0D0</param>
        /// <returns></returns>
        public static string WriteMethod(bool isAll,bool isIncludeMe,bool isExtractSameFanctionName)
        {
            //(Æ0¹0È0(u)þs(Wn0¢•peK0‰00|TúQW0CQn0¢•pe’0åw‹0¹eÕl‹O
            string myMethod = "";
            try
            {
                System.Diagnostics.StackFrame callerFrame = null;
                MethodBase callerMethod = null;
 
                //êRn0¢•pe(S0n0¢•pen0r0h0d0MRn0¢•pe)
                callerFrame = new System.Diagnostics.StackFrame(1);
                callerMethod = callerFrame.GetMethod();
                myMethod = callerMethod.ReflectedType.FullName + "." + callerMethod.Name;
 
                //yrŠkæQt’0Y0‹0¢•pe
                bool isOpenConnect = myMethod == "Oat.Library.CommonClass.Data.MsSqlNet.OpenConnect";
                bool isCloseConnect = myMethod == "Oat.Library.CommonClass.Data.MsSqlNet.Close";
                Dictionary<string, string> noMethodList = new Dictionary<string, string>();
                if (isOpenConnect || isCloseConnect)
                {
                    //åN Nn0h0S00n0¢•pe T’0ÖS—_W0f0‚0asTL0j0D0n0g00
                    //noMethodList.Add(".ctor", "¯0é0¹0¤0ó0¹0¿0ó0¹0Bf");
                    noMethodList.Add("Oat.Library.CommonClass.Data.MsSqlNet..ctor", "¯0é0¹0¤0ó0¹0¿0ó0¹0Bf");
                    noMethodList.Add("Dispose", "");
                    noMethodList.Add("CreateDBAccess", "");
                    noMethodList.Add("CreateCommonDBAccess", "");
                    noMethodList.Add("GetDataTable", "");
                    noMethodList.Add("GetDataSet", "");
                    noMethodList.Add("ExecuteNonQuery", "");
                    noMethodList.Add("GetDataReader", "");
                    noMethodList.Add("ExecuteScalar", "");
 
                }
 
 
                //ËY0‹0ju÷S
                int startFrameIndex = isIncludeMe ? 1 : 2;
 
                //|TúQW0CQ¢•pehˆ:y
                for (int i = startFrameIndex; i <= 100; i++)//h0Š0B0H0Z0Max100
                {
                    callerFrame = new System.Diagnostics.StackFrame(i);
                    if (callerFrame == null) break;
                    callerMethod = callerFrame.GetMethod();
                    if (callerMethod == null) break;
 
                    if (isExtractSameFanctionName && callerMethod.ReflectedType.FullName + "." + callerMethod.Name == myMethod)//_peUD0j0i0o0d–O04XT
                    {
                        continue;//#š}Y0‹0 T To0þ[aŒY
                    }
 
                    myMethod = callerMethod.ReflectedType.FullName + "." + callerMethod.Name;
 
                    if (isOpenConnect || isCloseConnect)
                    {
                        if (noMethodList.ContainsKey(callerMethod.Name)) continue;//þ[aŒY
                        if (noMethodList.ContainsKey(myMethod)) continue;//þ[aŒY
                    }
 
                    Console.WriteLine("0Stack" + (i - 1) + "0" + myMethod + (isOpenConnect ? "0OpenConnect0" : "") + (isCloseConnect ? "0CloseConnect0" : ""));
                    if (!isAll) break;
                }
            }
            catch
            {
                myMethod = "0ÿ0" + myMethod;
            }
 
            return myMethod;
        }
 
        public static void SetDoubleBuffered(Control control)
        {
            // set instance non-public property with name "DoubleBuffered" to true
            typeof(Control).InvokeMember("DoubleBuffered", BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic, null, control, new object[] { true });
        }
 
        public static void AutoBottomScroll(DataGridView grid)
        {
            int rowlimit = grid.DisplayedRowCount(true);
            if (rowlimit < grid.RowCount)
            {
                grid.FirstDisplayedScrollingRowIndex = grid.RowCount - 1;
            }
        }
 
        public static float Inch_To_Cm(float inch)
        {
            return inch * INCH_TO_CM;//Inch’!cm
        }
 
        public static float CM_TO_INCH(float cm)
        {
            return cm / INCH_TO_CM;//cm’!Inch
        }
 
        public static float INCH_TO_DOT(float inch)
        {
            //System.Drawing.Image i;
            //i.HorizontalResolution;//dpi
            //i.VerticalResolution;//dpi
 
            return inch * 96F;//Inch’!Dot
        }
 
        public static float DOT_TO_INCH(float dot)
        {
            return dot / 96F;//Dot’!Inch
        }
 
        public static float CM_TO_DOT(float cm)
        {
            return cm * 96F / INCH_TO_CM;//cm’!Dot
        }
 
        public static float DOT_TO_CM(float dot)
        {
            return dot * INCH_TO_CM / 96F;//Dot’!cm
        }
 
        public static byte[] FileToByte(string fileName)
        {
            //========================================
            //fileNamen0;uÏP’0­Š¼Byteg0ԏY0
            //========================================
            byte[] imageb = null;
            try
            {
                using (FileStream fs = File.OpenRead(fileName))
                {
                    imageb = new byte[fs.Length];
                    fs.Read(imageb, 0, imageb.Length);
                    fs.Close();
                }
                return imageb;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "FileToByte", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }
        }
 
        public static bool ByteToFile(byte[] imageb, string fileName)
        {
            //========================================
            //imageb’0¤0á0ü0¸0SW00fileNamen0;uÏPh0W0f0ÝOX[
            //========================================
 
            try
            {
                using (FileStream fs = File.OpenWrite(fileName))
                {
                    fs.Write(imageb, 0, imageb.Length);
                    fs.Close();
                }
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ByteToFile", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
        }
 
        public static bool SaveJpgImage(Image image,string saveFileName, Int64 quality)
        {
            //========================================
            //image’0jpgg0ÝOX[
            //========================================
            try
            {
                //jpg(ÁTêŒØN)
                //Int64 quality = 20; // ÁTêŒì0Ù0ë0ÿ20
                System.Drawing.Imaging.ImageCodecInfo jpgEncoder = null;
 
                // JPEG(un0¨0ó0³0ü0À0n0ÖS—_
                foreach (System.Drawing.Imaging.ImageCodecInfo ici in System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders())
                {
                    if (ici.FormatID == System.Drawing.Imaging.ImageFormat.Jpeg.Guid) { jpgEncoder = ici; break; }
                }
                // ¨0ó0³0ü0À0k0!nY0Ñ0é0á0ü0¿0n0\Ob
                System.Drawing.Imaging.EncoderParameter encParam = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality);
                // Ñ0é0á0ü0¿0’0M‘Rk0<h }
                System.Drawing.Imaging.EncoderParameters encParams = new System.Drawing.Imaging.EncoderParameters(1);
                encParams.Param[0] = encParam;
                // ;uÏPn0ÝOX[
                image.Save(saveFileName, jpgEncoder, encParams);
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "SaveJpgImage", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
        }
 
        public static bool SaveTifImage(Image image, string saveFileName, Int64 quality)
        {
            //========================================
            //image’0Tifg0ÝOX[
            //========================================
            try
            {
                //jpg(ÁTêŒØN)
                //Int64 quality = 20; // ÁTêŒì0Ù0ë0ÿ20
                System.Drawing.Imaging.ImageCodecInfo jpgEncoder = null;
 
                // JPEG(un0¨0ó0³0ü0À0n0ÖS—_
                foreach (System.Drawing.Imaging.ImageCodecInfo ici in System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders())
                {
                    if (ici.FormatID == System.Drawing.Imaging.ImageFormat.Jpeg.Guid) { jpgEncoder = ici; break; }
                }
                // ¨0ó0³0ü0À0k0!nY0Ñ0é0á0ü0¿0n0\Ob
                System.Drawing.Imaging.EncoderParameter encParam = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality);
                // Ñ0é0á0ü0¿0’0M‘Rk0<h }
                System.Drawing.Imaging.EncoderParameters encParams = new System.Drawing.Imaging.EncoderParameters(1);
                encParams.Param[0] = encParam;
                // ;uÏPn0ÝOX[
                image.Save(saveFileName, jpgEncoder, encParams);
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "SaveJpgImage", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
        }
 
        public static void ClearStringBuilder(StringBuilder sb)
        {
            try
            {
                sb.Length = 0;
                sb.Capacity = 0;
            }
            catch { }
        }
 
        private static string GetCommandLineArgs()
        {
            Queue<string> args = new Queue<string>(Environment.GetCommandLineArgs());
            args.Dequeue(); // args[0] is always exe path/filename
            return string.Join(" ", args.ToArray());
        }
 
        public static void ReStart(System.Threading.Mutex hMutex)
        {
            string commandLineArgs = GetCommandLineArgs();
            string exePath = Application.ExecutablePath;
            try
            {
                if (hMutex != null)
                {
                    // GC.KeepAlive á0½0Ã0É0L0|Ts0úQU0Œ0‹0~0g00¬0Ù0ü0¸0 ³0ì0¯0·0ç0ó0þ[aŒK0‰0d–YU0Œ0‹0
                    GC.KeepAlive(hMutex);
 
                    // Mutex ’0‰•X0‹0 (ckW0O0o0 ª0Ö0¸0§0¯0È0n04xÄh’0ÝO<ŠY0‹0 ’0ÂSgq)
                    hMutex.Close();
                }
                Process.Start(exePath, commandLineArgs);
                Environment.Exit(0);
            }
            catch
            {
                throw;
            }            
        }
        public static DateTime BeginOfMonth(DateTime dt)//gRåe’0ԏY0
        {
            return dt.AddDays((dt.Day - 1) * -1);
        }
        public static DateTime EndOfMonth(DateTime dt)// g+gåe’0ԏY0
        {
            return new DateTime(dt.Year, dt.Month, DaysInMonth(dt));
        }
        public static int DaysInMonth(DateTime dt)
        {
            return DateTime.DaysInMonth(dt.Year, dt.Month);
        }
 
        /// <summary>
        /// ;ub—N§‰k0âek0‹•D0_0K0i0F0K0
        /// </summary>
        /// <param name="a_typ"></param>
        /// <returns></returns>
        public static Form GetOpenForm(Type a_typ)
        {
            foreach (Form item in Application.OpenForms)
            {
                if (a_typ == item.GetType())
                {
                    return item;
                }
            }
            return null;
        }
 
        // ============== (http://note.chiebukuro.yahoo.co.jp/detail/n145045)
        // Bitmap’0Byte‹WM‘R(Ð0¤0Ê0ê0)k0   YÛc
        // b__o00_pek0eQ›Rcš[Y0‹0Bitmapn0Õ0¡0¤0ë0b__h0Y0‹00
        // ,{ÿ_pe: Bitmap‹W;uÏPÅ`1X
        // ;bŠ0$P: Byte‹WM‘R(Ð0¤0Ê0ê0)n0;uÏPÅ`1X
        public static byte[] ConvertImageToBytes(System.Drawing.Bitmap bmp)
        {
            // eQ›R_pen0pu8^Bfn0¨0é0ü0æQt
            if (bmp == null)
            {
                return null;
            }
 
 
            // ÔtS(uÐ0¤0È0‹WM‘R
            byte[] ImageBytes;
 
 
            // á0â0ê0¹0È0ê0ü0à0n0ub
            using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
            {
                #region bmpn04XT
                // Bitmap;uÏP’00Bitmapn0Õ0¡0¤0ë0b__g0¹0È0ê0ü0à0k0ÝOX[
                //bmp.Save(ms, bmp.RawFormat);
                //bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
                #endregion
 
                #region jpgn04XT
 
                //jpg(ÁTêŒØN)
                Int64 quality = 50; // ÁTêŒì0Ù0ë0ÿ20
                System.Drawing.Imaging.ImageCodecInfo jpgEncoder = null;
 
                // JPEG(un0¨0ó0³0ü0À0n0ÖS—_
                foreach (System.Drawing.Imaging.ImageCodecInfo ici in System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders())
                {
                    if (ici.FormatID == System.Drawing.Imaging.ImageFormat.Jpeg.Guid) { jpgEncoder = ici; break; }
                }
                // ¨0ó0³0ü0À0k0!nY0Ñ0é0á0ü0¿0n0\Ob
                System.Drawing.Imaging.EncoderParameter encParam = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality);
                // Ñ0é0á0ü0¿0’0M‘Rk0<h }
                System.Drawing.Imaging.EncoderParameters encParams = new System.Drawing.Imaging.EncoderParameters(1);
                encParams.Param[0] = encParam;
                // ;uÏPn0ÝOX[
                bmp.Save(ms, jpgEncoder, encParams);
 
                #endregion
 
 
                // ¹0È0ê0ü0à0n0Ç0ü0¿0ü0’0Ð0¤0È0‹WM‘Rk0 YÛc
                ImageBytes = ms.ToArray();
 
 
                // ¹0È0ê0ü0à0n0¯0í0ü0º0
                ms.Close();
            }
 
 
            return ImageBytes;
        }
 
        // ============== (http://note.chiebukuro.yahoo.co.jp/detail/n145045)
        // Byte‹WM‘R(Ð0¤0Ê0ê0)’0Bitmapk0   YÛc
        // ,{ÿ_pe: Byte‹WM‘R(Ð0¤0Ê0ê0)n0;uÏPÅ`1X
        // ;bŠ0$P: Bitmap‹W;uÏPÅ`1X
        public static System.Drawing.Bitmap ConvertBytesToImage(byte[] Image_Bytes)
        {
 
            // eQ›R_pen0pu8^Bfn0¨0é0ü0æQt
            if ((Image_Bytes == null) || (Image_Bytes.Length == 0))
            {
                return null;
            }
 
 
            // ÔtS(uBitmap‹Wª0Ö0¸0§0¯0È0
            System.Drawing.Bitmap ResultBmp;
 
 
            // Ð0¤0Ê0ê0(ByteM‘R)’0¹0È0ê0ü0à0k0ÝOX[
            using (System.IO.MemoryStream ms = new System.IO.MemoryStream(Image_Bytes))
            {
 
                // ¹0È0ê0ü0à0n0Ð0¤0Ê0ê0(ByteM‘R)’0Bitmapk0 YÛc
                ResultBmp = new System.Drawing.Bitmap(ms);
 
 
                // ¹0È0ê0ü0à0n0¯0í0ü0º0
                ms.Close();
            }
 
 
            return ResultBmp;
        }
 
        /// <summary>
        /// *j4ls^¹eT
        /// </summary>
        /// <param name="align"></param>
        /// <returns></returns>
        public static StringAlignment ToStringAlignment(DataGridViewContentAlignment align)
        {
            StringAlignment ag = StringAlignment.Near;
            switch (align)
            {
                case DataGridViewContentAlignment.BottomCenter:
                case DataGridViewContentAlignment.MiddleCenter:
                case DataGridViewContentAlignment.TopCenter:
                    ag = StringAlignment.Center;
                    break;
                case DataGridViewContentAlignment.BottomLeft:
                case DataGridViewContentAlignment.MiddleLeft:
                case DataGridViewContentAlignment.TopLeft:
                    ag = StringAlignment.Near;
                    break;
                case DataGridViewContentAlignment.BottomRight:
                case DataGridViewContentAlignment.MiddleRight:
                case DataGridViewContentAlignment.TopRight:
                    ag = StringAlignment.Far;
                    break;
            }
            return ag;
        }
 
        /// <summary>
        /// &~‚Wôv¹eT
        /// </summary>
        /// <param name="align"></param>
        /// <returns></returns>
        public static StringAlignment ToLineStringAlignment(DataGridViewContentAlignment align)
        {
            StringAlignment ag = StringAlignment.Center;
            switch (align)
            {
                case DataGridViewContentAlignment.TopCenter:
                case DataGridViewContentAlignment.TopLeft:
                case DataGridViewContentAlignment.TopRight:
                    ag = StringAlignment.Near;
                    break;
                case DataGridViewContentAlignment.MiddleCenter:
                case DataGridViewContentAlignment.MiddleLeft:
                case DataGridViewContentAlignment.MiddleRight:
                    ag = StringAlignment.Center;
                    break;
                case DataGridViewContentAlignment.BottomCenter:
                case DataGridViewContentAlignment.BottomRight:
                case DataGridViewContentAlignment.BottomLeft:
                    ag = StringAlignment.Far;
                    break;
            }
            return ag;
        }
 
        /// <summary>
        /// Clipboardx0³0Ô0ü0
        /// </summary>
        /// <param name="data"></param>
        public static void CopyToClipboard(string data)
        {
            try
            {
                Clipboard.SetDataObject(data, true);
            }
            catch { }
        }
    }
}