ホテル管理システム
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
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Windows.Forms;
using System.Drawing;
using System.Xml;
using System.Xml.XPath;
using HotelPms.Share.Util;
using HotelPms.Share.Windows.Component;
using HotelPms.Share.Windows.GraphicsApi;
 
namespace HotelPms.Share.Windows.Util
{
    [Flags()]
    public enum numInputType
    {
        None = 0x1,             //“Á‚ɂȂµ
        Num = 0x2,              //”Žš
        Alpha_S = 0x4,          //ƒAƒ‹ƒtƒ@ƒxƒbƒg¬
        Alpha_C = 0x8,          //ƒAƒ‹ƒtƒ@ƒxƒbƒg‘å
        Kana = 0x10,            //ƒJƒi
        Half = 0x20,            //”¼Šp
        Full = 0x40,            //‘SŠp
        Num_FieldClear = 0x80,  //“ü—͍ő包’´‚¦‚½‚çƒNƒŠƒA
        Plus_FieldClear = 0x100,//"+"ƒL[‚ŃNƒŠƒA
        Space = 0x200,          //‹ó”’
        Colon = 0x400,          //":"‚ð‰Â”\
        Subtract = 0x800,       //"-"
        DotSendKeys = 0x1000,   //"."¨"000"‚Æ‚·‚é
        Dot = 0x2000,           //"."
        Slash = 0x4000,           //"/"
        Comma = 0x8000,        //"," ƒJƒ“ƒ}
 
        Alpha = Alpha_S | Alpha_C,//ƒAƒ‹ƒtƒ@ƒxƒbƒg¬+ƒAƒ‹ƒtƒ@ƒxƒbƒg‘å
        NumAlpha = Num | Alpha | Space,//”Žš{ƒAƒ‹ƒtƒ@ƒxƒbƒg{‹ó”’
        ANK = NumAlpha | Kana,  //”Žš{ƒAƒ‹ƒtƒ@ƒxƒbƒg{‹ó”’{ƒJƒi
        TIME = Num | Colon,     //ŽžŠÔ—p "12:30"
    }
 
    [Flags()]
    public enum numShowStyle
    {
        None = 0x1,             //“Á‚ɂȂµ
        ZeroPad = 0x2,          //Œ…”–¢–ž‚¾‚Á‚½‚ç"0"‚𓪂ɒljÁ
        ThousandSeparator = 0x4,//‹àŠzŽž‚Ì3Œ…‚²‚Æ‚Ì"," —á1,000,000
        ShowList = 0x8,         //ENDƒL[‚ňꗗ‘I‘ð‰æ–Ê‚ª‚ ‚è
    }
 
    public class InputCtrl
    {
        public static string Chr_SqlKinshi = "'";
        public static string Chr_Num = "0123456789";
        public static string Chr_Alpha_S = "abcdefghijklmnopqrstuvwxyz ";
        public static string Chr_Alpha_C = "ABCDEFGHIJKLMNOPQRSTUVWXYZ ";
        public static string Chr_Kana = "¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞß ";
        public static string Chr_Alpha = Chr_Alpha_S + Chr_Alpha_C;
        public static string Chr_NumAlpha = Chr_Num + Chr_Alpha;
        public static string Chr_ANK = Chr_NumAlpha + Chr_Kana; 
 
        ///¡ IsNotInOwnStr
        ///@yŠT@—vzFŠY“–•¶Žš—ñ‚͐e•¶Žš—ñ‚Ì’†‚Ɋ܂܂ê‚ĂȂ¢‚©
        ///@yˆø@”zFhsValue@@@@ŒŸõ•¶Žš—ñ
        ///@@@@@@@hsOwnString@@e•¶Žš—ñ@@
        ///@y–ß‚è’lzFBoolean
        public static bool IsNotInOwnStr(string hsValue, string hsOwnString)
        {
            try
            {
                for (int i = 0; i <= hsValue.Length - 1; i++)
                {
                    if (hsOwnString.IndexOf(hsValue[i]) != -1)
                    {
                        return false;
                    }
                }
                return true;
            }
            catch
            {
                return false;
            }
        }
 
 
        ///¡ IsInOwnStr
        ///@yŠT@—vzFŠY“–•¶Žš—ñ‚͐e•¶Žš—ñ‚Ì’†‚Ɋ܂܂ê‚Ă܂·‚©
        ///@yˆø@”zFhsValue@@@@ŒŸõ•¶Žš—ñ
        ///@@@@@@@hsOwnString@@e•¶Žš—ñ@@@
        ///@y–ß‚è’lzFBoolean
        public static bool IsInOwnStr(string hsValue, string hsOwnString)
        {
            try
            {
                for (int i = 0; i <= hsValue.Length - 1; i++)
                {
                    if (hsOwnString.IndexOf(hsValue[i]) == -1)
                    {
                        return false;
                    }
                }
                return true;
            }
            catch
            {
                return false;
            }
        }
 
        public static bool IsCorrectValue(CTextBox textBox)
        {
            return IsCorrectValue(textBox, true);
        }
 
        ///¡ IsCorrectValue
        ///@yŠT@—vzFƒ`ƒFƒbƒN
        ///@yˆø@”zF
        ///@y–ß‚è’lzFobject
        public static bool IsCorrectValue(CTextBox textBox, bool showErrMsg)
        {
            string wsChkStr = "";
            numInputType wlErrFlg = 0;
            int wiLen;
            try
            {
                string text = (GetShowStyle(textBox) & numShowStyle.ThousandSeparator) == numShowStyle.ThousandSeparator ? textBox.Text.Replace(",", string.Empty) : textBox.Text;
 
                System.Text.Encoding enc = System.Text.Encoding.Default;
                wiLen = enc.GetBytes(text).Length;
 
                numInputType inputType = GetInputType(textBox);
 
                //”¼Špƒ`ƒFƒbƒN
                if ((inputType & numInputType.Half) == numInputType.Half && wiLen != text.Length)
                {
                    if (showErrMsg) { MessageBox.Show(null, "”¼Šp“ü—Í‚µ‚Ä‚­‚¾‚³‚¢B", "“ü—̓`ƒFƒbƒN", MessageBoxButtons.OK); }
                    return false;
                }
 
                //‘SŠpƒ`ƒFƒbƒN
                if ((inputType & numInputType.Full) == numInputType.Full && wiLen != 2 * text.Length)
                {
                    if (showErrMsg) { MessageBox.Show(null, "‘SŠp“ü—Í‚µ‚Ä‚­‚¾‚³‚¢B", "“ü—̓`ƒFƒbƒN", MessageBoxButtons.OK); }
                    return false;
                }
 
                //”Žš
                if ((inputType & numInputType.Num) == numInputType.Num)
                {
                    wsChkStr = wsChkStr + Chr_Num;
                    wlErrFlg = wlErrFlg | numInputType.Num;
                }
 
                //.
                if ((inputType & numInputType.Dot) == numInputType.Dot)
                {
                    wsChkStr = wsChkStr + ".";
                    wlErrFlg = wlErrFlg | numInputType.Dot;
                }
 
                //[/]
                if ((inputType & numInputType.Slash) == numInputType.Slash)
                {
                    wsChkStr = wsChkStr + "/";
                    wlErrFlg = wlErrFlg | numInputType.Slash;
                }
 
                //Space
                if ((inputType & numInputType.Space) == numInputType.Space)
                {
                    wsChkStr = wsChkStr + " ";
                    wlErrFlg = wlErrFlg | numInputType.Space;
                }
 
                //-
                if ((inputType & numInputType.Subtract) == numInputType.Subtract)
                {
                    wsChkStr = wsChkStr + "-";
                    wlErrFlg = wlErrFlg | numInputType.Subtract;
                }
 
                //:
                if ((inputType & numInputType.Colon) == numInputType.Colon)
                {
                    wsChkStr = wsChkStr + ":";
                    wlErrFlg = wlErrFlg | numInputType.Colon;
                }
 
                //,
                if ((inputType & numInputType.Comma) == numInputType.Comma)
                {
                    wsChkStr = wsChkStr + ",";
                    wlErrFlg = wlErrFlg | numInputType.Colon;
                }
 
                //¬‰p
                if ((inputType & numInputType.Alpha_C) == numInputType.Alpha_C)
                {
                    wsChkStr = wsChkStr + Chr_Alpha_C;
                    wlErrFlg = wlErrFlg | numInputType.Alpha_C;
                }
 
                //‘å‰p
                if ((inputType & numInputType.Alpha_S) == numInputType.Alpha_S)
                {
                    wsChkStr = wsChkStr + Chr_Alpha_S;
                    wlErrFlg = wlErrFlg | numInputType.Alpha_S;
                }
 
                //ƒJƒi
                if ((inputType & numInputType.Kana) == numInputType.Kana)
                {
                    wsChkStr = wsChkStr + Chr_Kana;
                    wlErrFlg = wlErrFlg | numInputType.Kana;
                }
                if (wsChkStr != "")
                {
                    if (IsInOwnStr(text, wsChkStr) == false)
                    {
                        if (!showErrMsg) { return false; }
                        if (wlErrFlg == numInputType.Num)
                        {
                            MessageBox.Show(null, "”Žš‚ð“ü—Í‚µ‚Ä‚­‚¾‚³‚¢B", "“ü—̓`ƒFƒbƒN", MessageBoxButtons.OK);
                        }
                        else if (wlErrFlg == numInputType.Kana)
                        {
                            MessageBox.Show(null, "”¼ŠpƒJƒi‚ð“ü—Í‚µ‚Ä‚­‚¾‚³‚¢B", "“ü—̓`ƒFƒbƒN", MessageBoxButtons.OK);
                        }
                        else if (wlErrFlg == numInputType.Alpha_S)
                        {
                            MessageBox.Show(null, "¬‰p•¶Žš‚ð“ü—Í‚µ‚Ä‚­‚¾‚³‚¢B", "“ü—̓`ƒFƒbƒN", MessageBoxButtons.OK);
                        }
                        else if (wlErrFlg == numInputType.Alpha_C)
                        {
                            MessageBox.Show(null, "‘å‰p•¶Žš‚ð“ü—Í‚µ‚Ä‚­‚¾‚³‚¢B", "“ü—̓`ƒFƒbƒN", MessageBoxButtons.OK);
                        }
                        else
                        {
                            MessageBox.Show(null, "³‚µ‚¢’l‚ð“ü—Í‚µ‚Ä‚­‚¾‚³‚¢B", "“ü—̓`ƒFƒbƒN", MessageBoxButtons.OK);
                        }
                        return false;
                    }
                }
                return true;
            }
            catch
            {
                return false;
            }
        }
 
 
        ///¡ IsOutOfRange
        ///@yŠT@—vzFƒ`ƒFƒbƒN
        ///@yˆø@”zF
        ///@y–ß‚è’lzFbool
        public static bool IsOutOfRange(string hsValue, string hsRange)
        {
            try
            {
                string[] wsRange;
                if (hsRange[0] == "'"[0])
                {
 
                    if (hsRange.IndexOf("'" + hsValue + "'") == -1)
                    {
                        return true;
                    }
                }
                else
                {
                    wsRange = hsRange.Split(new char[] { ',' });
                    wsRange[0] = wsRange[0].Substring(1);
                    wsRange[1] = wsRange[1].Substring(0, wsRange[1].Length - 1);
                    if (hsRange[0] == '[')
                    {
                        if (Convert.ToDouble(hsValue) < Convert.ToDouble(wsRange[0]))
                        {
                            return true;
                        }
                    }
                    else if (hsRange[0] == '(')
                    {
                        if (Convert.ToDouble(hsValue) <= Convert.ToDouble(wsRange[0]))
                        {
                            return true;
                        }
                    }
                    if (hsRange[hsRange.Length - 1] == ']')
                    {
                        if (Convert.ToDouble(hsValue) > Convert.ToDouble(wsRange[1]))
                        {
                            return true;
                        }
                    }
                    else if (hsRange[hsRange.Length - 1] == ')')
                    {
                        if (Convert.ToDouble(hsValue) >= Convert.ToDouble(wsRange[1]))
                        {
                            return true;
                        }
                    }
                }
 
                return false;
            }
            catch
            {
                return true;
            }
        }
 
        public static bool IsCorrectText(CTextBox textbox)
        {
            return IsCorrectText(textbox, true, false);
        }
 
        public static bool IsCorrectText(CTextBox textbox, bool showErrMsg)
        {
            return IsCorrectText(textbox, showErrMsg, false);
        }
 
        public static bool IsCorrectText(CTextBox textbox, bool showErrMsg, bool ignoteNull)
        {
            if (!textbox.Visible) { return true; }
 
            if (IsCorrectInput(textbox, showErrMsg, ignoteNull))
            {
                if (textbox.Text.Length > 0)
                {
                    if ((GetShowStyle(textbox) & numShowStyle.ZeroPad) == numShowStyle.ZeroPad)
                    {
                        textbox.Text = textbox.Text.PadLeft(textbox.MaxLength, '0');
                    }
                }
                return true;
            }
            else
            {
                return false;
            }
        }
 
        public static bool IsCorrectInput(CTextBox textbox)
        {
            return IsCorrectInput(textbox, true, false);
        }
 
        ///¡ IsCorrectInput
        ///@yŠT@—vzFƒ`ƒFƒbƒN
        ///@yˆø@”zF
        ///@y–ß‚è’lzFbool
        public static bool IsCorrectInput(CTextBox textbox, bool showErrMsg , bool ignoteNull)
        {
            try
            {
                if (textbox.IsChkData == false)
                {
                    return true;
                }
                
                if ("".Equals(textbox.Text.Trim()))
                {
                    if (ignoteNull){return true;}
 
                    if (textbox.NotNull)
                    {
                        if (showErrMsg) { MessageBox.Show("“à—e‚ð“ü—Í‚µ‚Ä‚­‚¾‚³‚¢B", "“ü—̓`ƒFƒbƒN", MessageBoxButtons.OK, MessageBoxIcon.Information); }
                        return false;
                    }
                    else
                    {
                        return true;
                    }
                }
                if (!IsCorrectValue(textbox, showErrMsg))
                {
                    return false;
                }
                //System.Text.Encoding enc = System.Text.Encoding.GetEncoding("Shift_JIS");
                //if (enc.GetBytes(hsValue).Length > hoCtrTag.MaxKeta)
                //{
                //    if (showErrMsg) { MessageBox.Show(null, hoCtrTag.MaxKeta.ToString() + "Œ…ˆÈ“à‚Å“ü—Í‚µ‚Ä‚­‚¾‚³‚¢B", MessageBoxButtons.OK); }
                //    return false;
                //}
                if (textbox.IsDate)
                {
                    if (CConvert.IsDate(CConvert.ToInt(textbox.Text).ToString().PadLeft(8,'0')))
                    {
                        if (showErrMsg) { MessageBox.Show("“ú•t‚ð“ü—Í‚µ‚Ä‚­‚¾‚³‚¢B", "“ü—̓`ƒFƒbƒN", MessageBoxButtons.OK, MessageBoxIcon.Information); }
                        return false;
                    }
                }
                if (textbox.In_Range != "")
                {
                    if (IsOutOfRange(textbox.Text, textbox.In_Range))
                    {
                        if (showErrMsg) { MessageBox.Show("“ü—͔͈͈ȊO‚Å‚·B", "“ü—̓`ƒFƒbƒN", MessageBoxButtons.OK, MessageBoxIcon.Information); }
                        return false;
                    }
                }
 
                return true;
            }
            catch
            {
                return false;
            }
        }
 
        ///¡ SetNextFocus
        ///@yŠT@—vzFƒJƒ\ƒ‹ˆÚ“®
        ///@yˆø@”zF
        ///@y–ß‚è’lzFbool
        public static bool SetNextFocus(System.Windows.Forms.KeyEventArgs e)
        {
            try
            {
                System.Windows.Forms.Keys KeyCode = e.KeyCode;
                if (KeyCode == Keys.Return)
                {
                    SendKeys.Send("{TAB}");
                }
                else if (KeyCode == Keys.Escape)
                {
                    SendKeys.Send("+{TAB}");
                }
                return true;
            }
            catch
            {
                return false;
            }
        }
 
        public static numShowStyle GetShowStyle(CTextBox curField)
        {
            string[] wsItems = null;
            if (curField.ShowStyle.Length == 0)
            {
                return numShowStyle.None;
            }
            else
            {
                wsItems = curField.ShowStyle.Split(new char[] { ',' });
                numShowStyle ret = (numShowStyle)CConvert.ToInt(wsItems[0]);
                for (int i = 1; i <= wsItems.Length - 1; i++)
                {
                    ret = ret | (numShowStyle)CConvert.ToInt(wsItems[i]);
                }
                return ret;
            }
        }
 
        public static numInputType GetInputType(CTextBox curField)
        {
            string[] wsItems = null;
            if (curField.InputType.Length == 0)
            {
                return numInputType.None;
            }
            else
            {
                wsItems = curField.InputType.Split(new char[] { ',' });
                numInputType ret = (numInputType)CConvert.ToInt(wsItems[0]);
                for (int i = 1; i <= wsItems.Length - 1; i++)
                {
                    ret = ret | (numInputType)CConvert.ToInt(wsItems[i]);
                }
                return ret;
            }
        }
 
        public static void TextEnter(CTextBox hoTextBox)
        {
            numShowStyle style = GetShowStyle(hoTextBox);
            if ((style & numShowStyle.ThousandSeparator) == numShowStyle.ThousandSeparator)
            {
                hoTextBox.Text = hoTextBox.Text.Replace(",", string.Empty);
            }
 
            if (!hoTextBox.PanelExEnabled)
            {
                if ((style & numShowStyle.ShowList) == numShowStyle.ShowList)
                {
                    hoTextBox.BackColor = Color.Pink;
                }
                else
                {
                    hoTextBox.BackColor = Color.LightSteelBlue;
                }
            }
        }
 
        public static void TextLeave(CTextBox hoTextBox)
        {
            numShowStyle style = GetShowStyle(hoTextBox);
            if ((style & numShowStyle.ThousandSeparator) == numShowStyle.ThousandSeparator)
            {
                hoTextBox.Text = string.Format("{0:#,0}", CConvert.ToDecimal(hoTextBox.Text));
            }
            if (!hoTextBox.PanelExEnabled) { hoTextBox.BackColor = hoTextBox.ReadOnly ? ColorType.Control : Color.White; }
        }
 
        public static bool TextKeyPress(TextBox hoTextBox, ref char hKeyAscii, int hlMaxKeta, numInputType hlInputType)
        {
            try
            {
                if (hlInputType == numInputType.None)
                {
                    return true;
                }
 
                if (hKeyAscii == 8)
                {
                    return true;
                }
                else if (hKeyAscii == "'"[0])
                {
                    hKeyAscii = (char)0;
                    return false;
                }
                else if (hKeyAscii == 13)
                {
                    //hKeyAscii = (char)0;
                    return false;
                }
                else if (hKeyAscii == '+')
                {
                    //if ((hlInputType & numInputType.Plus_FieldClear) == numInputType.Plus_FieldClear)
                    //{
                    //    hoTextBox.Text = "";
                    //    hKeyAscii = (char)0;
                    //    return false;
                    //}
                }
 
                if ((hlInputType & numInputType.Num_FieldClear) == numInputType.Num_FieldClear)
                {
                    if (hoTextBox.Text.Length >= hlMaxKeta)
                    {
                        hoTextBox.Text = "";
                        //‰º‚̃`ƒFƒbƒN‚ɍs‚­
                    }
                }
 
                if ((hlInputType & numInputType.Num) == numInputType.Num)
                {
                    if ('0' <= hKeyAscii && hKeyAscii <= '9')
                    {
                        return true;
                    }
                }
 
                if ((hlInputType & numInputType.Dot) == numInputType.Dot)
                {
                    if (hKeyAscii == '.')
                    {
                        return true;
                    }
                }
 
                if ((hlInputType & numInputType.Slash) == numInputType.Slash)
                {
                    if (hKeyAscii == '/')
                    {
                        return true;
                    }
                }
 
                if ((hlInputType & numInputType.Colon) == numInputType.Colon)
                {
                    if (hKeyAscii == ':')
                    {
                        return true;
                    }
                }
 
                if ((hlInputType & numInputType.Subtract) == numInputType.Subtract)
                {
                    if (hKeyAscii == '-')
                    {
                        return true;
                    }
                }
 
                if ((hlInputType & numInputType.Comma) == numInputType.Comma)
                {
                    if (hKeyAscii == ',')
                    {
                        return true;
                    }
                }
 
                if ((hlInputType & numInputType.DotSendKeys) == numInputType.DotSendKeys)
                {
                    if (hKeyAscii == '.')
                    {
                        SendKeys.Send("000");
                        hKeyAscii = (char)0;
                        return true;
                    }
                }
 
                if ((hlInputType & numInputType.Space) == numInputType.Space)
                {
                    if (hKeyAscii == ' ')
                    {
                        return true;
                    }
                }
 
                if ((hlInputType & numInputType.Alpha_C) == numInputType.Alpha_C)
                {
                    if ('A' <= hKeyAscii && hKeyAscii <= 'Z')
                    {
                        return true;
                    }
                }
 
                if ((hlInputType & numInputType.Alpha_S) == numInputType.Alpha_S)
                {
                    if ('a' <= hKeyAscii && hKeyAscii <= 'z')
                    {
                        return true;
                    }
                }
 
                if ((hlInputType & numInputType.Kana) == numInputType.Kana)
                {
                    if ('¦' <= hKeyAscii && hKeyAscii <= 'ß')
                    {
                        return true;
                    }
                }
 
                if ((hlInputType & numInputType.Half) == numInputType.Half)
                {
                    if (hKeyAscii >= 0 && hKeyAscii <= 255)
                    {
                        return true;
                    }
                }
                if ((hlInputType & numInputType.Full) == numInputType.Full)
                {
                    if (hKeyAscii < 0 || hKeyAscii > 255)
                    {
                        return true;
                    }
                }
 
                hKeyAscii = (char)0;
                return false;
            }
            catch
            {
                return false;
            }
        }
 
        public static void TextBoxEnter(object sender)
        {
            TextBox txtField = (TextBox)sender;
            txtField.BackColor = Color.Pink;
        }
 
        public static void TextBoxLeave(object sender)
        {
            TextBox txtField = (TextBox)sender;
            txtField.BackColor = Color.White;
        }
 
        public static void TextBoxKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e,int maxKeta,numInputType inputType)
        {
            TextBox txtField = (TextBox)sender;
            char KeyAscii = e.KeyChar;
            TextKeyPress(txtField, ref KeyAscii, maxKeta, inputType);
            if (KeyAscii == (char)0)
            {
                e.Handled = true;
            }
        }
 
        ///¡ GetFormXml
        ///@yŠT@—vzF¼½ÃѕW€‚Ì‚w‚l‚k‚ð“Ç‚Þ
        ///@yˆø@”zF(IN) hsConfigXml              String          Ì§²ÙÊß½
        ///@y–ß‚è’lzF‚È‚µ
        public static Dictionary<string, InputItem> GetFormXml(object hvConfigXml)
        {
            Dictionary<string, InputItem> woParentHash = new Dictionary<string, InputItem>();
            XmlDocument doc = new XmlDocument();
            string wsName;
            string wsValue;
            string wsCtrKey;
            InputItem woCtrTag;
            try
            {
                if (hvConfigXml == null)
                {
                    return null;
                }
                if (hvConfigXml is Stream)
                {
                    doc.Load(((Stream)(hvConfigXml)));
                }
                else
                {
                    doc.Load(((string)(hvConfigXml)));
                }
                XmlNode rootnode = doc.DocumentElement;
                foreach (XmlNode child in rootnode.ChildNodes)
                {
                    if (child.NodeType == XmlNodeType.Element && child.Name == "control")
                    {
                        wsCtrKey = child.Attributes["CtrName"].Value;
                        if (wsCtrKey.Length == 0)
                        {
                            return null;
                        }
                        woCtrTag = new InputItem();
                        foreach (XmlAttribute child1 in child.Attributes)
                        {
                            wsName = child1.Name;
                            wsValue = child1.Value;
                            //Debug.WriteLine(wsName + " : " + wsValue); 
                            if (wsName.Equals("InputType"))
                            {
                                string[] wsItems = null;
                                wsItems = wsValue.Split(new char[] { ','});
                                for (int i = 0; i <= wsItems.Length - 1; i++)
                                {
                                    woCtrTag.InputType = woCtrTag.InputType | (numInputType)CConvert.ToInt(wsItems[i]);
                                }
                            }
                            else if (wsName.Equals("ShowStyle"))
                            {
                                string[] wsItems = null;
                                wsItems = wsValue.Split(new char[] { ',' });
                                for (int i = 0; i <= wsItems.Length - 1; i++)
                                {
                                    woCtrTag.ShowStyle = woCtrTag.ShowStyle | (numShowStyle)CConvert.ToInt(wsItems[i]);
                                }
                            }
                            else if (wsName.Equals("ImeMode"))
                            {
                                woCtrTag.ImeMode = (ImeMode)CConvert.ToInt(wsValue);
                            }
                            else
                            {
                                CConvert.CallByName(woCtrTag, wsName, CallType.Let, new object[] { wsValue });
                            }
                        }
                        woParentHash.Add(wsCtrKey, woCtrTag);
                    }
                }
                return woParentHash;
            }
            catch
            {
                return woParentHash;
            }
        }
 
        public static bool IsNaturalNumber(String strNumber)
        {
            Regex objNotNaturalPattern = new Regex("[^0-9]");
            Regex objNaturalPattern = new Regex("0*[1-9][0-9]*");
            return !objNotNaturalPattern.IsMatch(strNumber) &&
                    objNaturalPattern.IsMatch(strNumber);
        }
 
        public static bool IsInteger(String strNumber)
        {
            Regex objNotIntPattern = new Regex("[^0-9-]");
            Regex objIntPattern = new Regex("^-[0-9]+$|^[0-9]+$");
            return !objNotIntPattern.IsMatch(strNumber) && objIntPattern.IsMatch(strNumber);
        }
 
        public static bool IsPositiveNumber(String strNumber)
        {
            Regex objNotPositivePattern = new Regex("[^0-9.]");
            Regex objPositivePattern = new Regex("^[.][0-9]+$|[0-9]*[.]*[0-9]+$");
            Regex objTwoDotPattern = new Regex("[0-9]*[.][0-9]*[.][0-9]*");
            return !objNotPositivePattern.IsMatch(strNumber) &&
            objPositivePattern.IsMatch(strNumber) &&
            !objTwoDotPattern.IsMatch(strNumber);
        }
 
        public static bool IsNumber(String strNumber)
        {
            Regex objNotNumberPattern = new Regex("[^0-9.-]");
            Regex objTwoDotPattern = new Regex("[0-9]*[.][0-9]*[.][0-9]*");
            Regex objTwoMinusPattern = new Regex("[0-9]*[-][0-9]*[-][0-9]*");
            String strValidRealPattern = "^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$";
            String strValidIntegerPattern = "^([-]|[0-9])[0-9]*$";
            Regex objNumberPattern = new Regex("(" + strValidRealPattern + ")|(" + strValidIntegerPattern + ")");
            return !objNotNumberPattern.IsMatch(strNumber) &&
            !objTwoDotPattern.IsMatch(strNumber) &&
            !objTwoMinusPattern.IsMatch(strNumber) &&
            objNumberPattern.IsMatch(strNumber);
        }
 
        public static bool IsAlpha(String strToCheck)
        {
            Regex objAlphaPattern = new Regex("[^a-zA-Z]");
            return !objAlphaPattern.IsMatch(strToCheck);
        }
 
        public static bool IsAlphaNumeric(String strToCheck)
        {
            Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]");
            return !objAlphaNumericPattern.IsMatch(strToCheck);
        }
 
        public static bool IsHalfKana(String strToCheck)
        {
            Regex objNotPattern = new Regex("[^¦-ß]");
            Regex objPattern = new Regex("^[¦-ß]+$");
            return !objNotPattern.IsMatch(strToCheck) && objPattern.IsMatch(strToCheck);
        }
 
        public static bool IsLargAlpha(String strToCheck)
        {
            Regex objNotPattern = new Regex("[^A-Z]");
            Regex objPattern = new Regex("^[A-Z]+$");
            return !objNotPattern.IsMatch(strToCheck) && objPattern.IsMatch(strToCheck);
        }
 
        public static bool IsSmallAlpha(String strToCheck)
        {
            Regex objNotPattern = new Regex("[^a-z]");
            Regex objPattern = new Regex("^[a-z]+$");
            return !objNotPattern.IsMatch(strToCheck) && objPattern.IsMatch(strToCheck);
        }
 
        /// <summary>
        /// ‘S‚Đ”Žš‚©‚Ç‚¤‚©
        /// </summary>
        /// <param name="strNumber"></param>
        /// <returns></returns>
        public static bool IsWholeNumber(String strNumber)
        {
            Regex objNotPattern = new Regex("[^0-9]");
            Regex objPattern = new Regex("^[0-9]+$");
            return !objNotPattern.IsMatch(strNumber) && objPattern.IsMatch(strNumber);
        }
 
        /// <summary>
        /// SQL‚ÌSMALLDateTime‚̃`ƒFƒbƒN
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static bool IsCorrectSmallDateTime(string value)
        { 
            //1900-01-01 ` 2079-06-06
            try
            {
                DateTime date = CConvert.ToDateTime(value);
                if (date.Date.CompareTo(CConvert.ToDateTime("1900/01/01").Date) < 0) { return false; }
                if (date.CompareTo(CConvert.ToDateTime("2079/06/05 23:59:59")) > 0) { return false; }
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}