10月 09, 2015

asp.net FTP上傳檔案和獲取修改時間

        Dim wc As New WebClient()
        wc.Credentials = New NetworkCredential("hello", "***")
        wc.UploadFile("ftp://127.0.0.1/sort.zip", MapPath("sort.zip"))

        Dim ftp As FtpWebRequest = CType(FtpWebRequest.Create("ftp://127.0.0.1/sort.zip"), FtpWebRequest)
        ftp.Credentials = New NetworkCredential("hello", "***")
        ftp.Method = WebRequestMethods.Ftp.GetDateTimestamp
        Dim uu As FtpWebResponse = ftp.GetResponse
        Label1.Text = uu.LastModified

9月 30, 2015

COBOL 寫檔


        COPY 'UTI\UNY.FC'.

        DATA DIVISION.
        FILE SECTION.
        COPY 'UTI\UNIT.FD'.
        COPY 'UTI\UNY.FD'.

        WORKING-STORAGE SECTION.
        01 EOF PIC 9 VALUE 0.
        77 UNIT-STATUS PIC X(02).
            88 UNIT-FIND VALUE '00'.
            88 UNIT-ERR VALUE '94' '98'.
        77 WS01 PIC X(01).
        77 WK-FLG PIC 99.


        PROCEDURE DIVISION.

        MAIN SECTION.
        MAIN-RTN.
            MOVE 0 TO WK-FLG.
            MOVE SPACES TO WS01.
            OPEN I-O UNIT-FILE.
            OPEN OUTPUT UNY-FILE.


                PERFORM UNTIL EOF = 1
                    READ UNIT-FILE NEXT AT END MOVE 1 TO EOF
                    END-READ
                    IF UNIT-FIND
                         ADD 1 TO WK-FLG

                         MOVE UNIT-KEY TO UNY-KEY
                         MOVE UNIT-NAME TO UNY-NAME
                         MOVE UNIT-PEOPLE TO UNY-PEOPLE
                         MOVE UNIT-MAX TO UNY-MAX
                         MOVE UNIT-FLAG TO UNY-FLAG
                         MOVE UNIT-NOTE TO UNY-NOTE
                         MOVE ',' TO XA1 XA2 XA3 XA4 XA5
                         WRITE UNY-REC
                     END-IF
                END-PERFORM.
                DISPLAY WK-FLG.

            CLOSE UNIT-FILE UNY-FILE.
            STOP RUN.

        MAIN-EXIT.
            EXIT PROGRAM.

9月 15, 2015

COBOL 顯示所有資料


        ID DIVISION.
        PROGRAM-ID. P0611.
        ENVIRONMENT DIVISION.
        INPUT-OUTPUT SECTION.
        FILE-CONTROL.
        COPY 'UTI\PC.FC'.
        DATA DIVISION.
        FILE SECTION.
        COPY 'UTI\PC.FD'.
        WORKING-STORAGE SECTION.
        01 EOF PIC 9 VALUE 0.
        77 PC-STATUS PIC X(02).

        77 CUT PIC 99 VALUE 0.
        PROCEDURE DIVISION.
        MAIN SECTION.
        MAIN-RTN.
            OPEN I-O PC-FILE.
            PERFORM UNTIL EOF = 1
                READ PC-FILE NEXT AT END MOVE 1 TO EOF
                END-READ
                ADD 1 TO CUT
            END-PERFORM
            SUBTRACT 1 FROM CUT
            PERFORM CUT TIMES
                DISPLAY PC-PASSWORD PC-PROP-ID PC-STCK-ID PC-OFFICE-NAME
                DISPLAY PC-CHINESE-CODE PC-PRINTER-CODE PC-CHAR-DENSITY
                DISPLAY PC-RATE
            END-PERFORM.
            CLOSE PC-FILE.
        MAIN-EXIT.

9月 08, 2015

COBOL 讀取資料


        ID DIVISION.
        PROGRAM-ID. P0612.
        ENVIRONMENT DIVISION.
        INPUT-OUTPUT SECTION.
        FILE-CONTROL.
        COPY 'UTI\PERSON.FC'.
        DATA DIVISION.
        FILE SECTION.
        COPY 'UTI\PERSON.FD'.
        WORKING-STORAGE SECTION.
        01 EOF PIC X VALUE 'N'.
        77 PERSON-FSTATUS PIC X(02).
        77 CUT PIC 9999 VALUE 0.
        PROCEDURE DIVISION.
        MAIN SECTION.
        MAIN-RTN.
            OPEN I-O PERSON-FILE.


                ACCEPT CUT.

                MOVE CUT TO PERSON-NO.
                READ PERSON-FILE
                END-READ.
                DISPLAY PERSON-NO PERSON-NAMEX PERSON-BANK-NO.
                DISPLAY PERSON-BIRTHDAY PERSON-MAIL-ADDR.
                DISPLAY PERSON-ARV-DATE PERSON-EDUC-XXX.
                DISPLAY PERSON-DEDUCT-DAY PERSON-DEDUCT-MONTH.
                DISPLAY PERSON-DUTY PERSON-INSURE-BEG-DATE.
                DISPLAY PERSON-INSURE-MONTH-PAY.
                DISPLAY WAGE-DATA.
                DISPLAY PERSON-PRO-SALARY-FLAG PERSON-PRO-SALARY.
                DISPLAY PERSON-PRO-PROMOTE-FLAG.



            CLOSE PERSON-FILE.
        MAIN-EXIT.

8月 02, 2015

COBOL 算術運算


        ID DIVISION.
        PROGRAM-ID. P06999.
        ENVIRONMENT DIVISION.
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 A PIC 99.
        01 B PIC 9(2) VALUE 2.
        01 C PIC 99 VALUE 30.
        01 R PIC 99 VALUE 0.
        01 DIV PIC 99V99 VALUE 00.00.
        PROCEDURE DIVISION.
        MAIN SECTION.
        MAIN-PARA.
            DISPLAY 'INPUT NUMBER'.

            ACCEPT A.
            ADD 10 A TO R.
            DISPLAY '10 + ' A '=' R.
            MOVE 20 TO R.
            SUBTRACT 10 A FROM R.
            DISPLAY '10 - ' A '=' R.
            MOVE 10 TO R.
            MULTIPLY A BY R.
            DISPLAY A ' * 10 = ' R.
            DIVIDE A BY 2 GIVING DIV.
            DISPLAY A ' / 2 =' DIV.
            MOVE 2 TO R.
            MULTIPLY A BY R GIVING DIV.
            DISPLAY A ' * 2 =' DIV.
            SUBTRACT A FROM 2 GIVING DIV.
            DISPLAY A ' - 2 =' DIV.
            ADD A TO 2 GIVING DIV ON SIZE ERROR DISPLAY 'TOO MUCH'.
            DISPLAY A ' + 2 =' DIV.
            DIVIDE 4 BY 3 GIVING DIV.
            DISPLAY '4 / 3 = ' DIV.
            COMPUTE DIV ROUNDED = 4 / 3.
            DISPLAY '4 / 3 = ' DIV.
            COMPUTE DIV = A + 2.
            DISPLAY A ' + 2 = ' DIV.
            COMPUTE DIV = A - 2.
            DISPLAY A ' - 2 = ' DIV.
            COMPUTE DIV = A / 2.
            DISPLAY A ' / 2 = ' DIV.
            COMPUTE DIV = A * 2 ON SIZE ERROR DISPLAY 'NUM IS OVER'.
            DISPLAY A ' * 2 = ' DIV.
            EXIT PROGRAM.
      

COMPUTE 输出变量 ROUNDED = 运算表达式
ROUNDED 四舍五入和输出项定义有关系
如一输出项定义99.99,一输入项为12.356
则输出为12.36,小数后第三位向前进位
如一输出项定义99,一输入项为12.356
则输出为12,小数后第第一位向前进位

8月 01, 2015

COBOL 的HELLO WORLD 並省略IDENTIFICATION DIVISION.

        
        ID DIVISION.
        PROGRAM-ID. P0609.
        ENVIRONMENT DIVISION.
        DATA DIVISION.
        PROCEDURE DIVISION.
        MAIN SECTION.
        MAIN-RTN.
            DISPLAY 'HELLO WORLD' LINE 30 POSITION 20.
            EXIT PROGRAM.
PE2 P0609.CBL -F2 存檔 F3 存檔關閉 F5清行 F9 新增下一行
RMCOBOL P0609.CBL
RUNCOBOL P0609
DISPLAY 'HELLO WORLD' LINE 30 ERASE. --可清除螢幕

7月 19, 2015

按按鍵執行跳轉

  window.onkeyup = hr;
        var keyCount = 0;
        function hr(e) {
            if (e.keyCode === 72 && keyCount === 0) {
                keyCount++;
            } else if (e.keyCode === 82 && keyCount === 1) {
                alert('進入特殊模式!');
                window.location = "/ang.aspx";
                keyCount = 0;
            } else {
                keyCount = 0;
            };
        };
        function konami(e) {
            if (e.keyCode === 38 && keyCount === 0) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 38 && keyCount === 1) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 40 && keyCount === 2) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 40 && keyCount === 3) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 37 && keyCount === 4) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 39 && keyCount === 5) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 37 && keyCount === 6) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 39 && keyCount === 7) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 66 && keyCount === 8) {
                keyCount++;
                console.log(keyCount);
            } else if (e.keyCode === 65 && keyCount === 9) {            
                alert('進入特殊模式!');
                window.location = "/ang.aspx";
                keyCount = 0;
            } else {
                keyCount = 0;
                
            }
        }
        

7月 18, 2015

sql用while迴圈

declare @rt nvarchar(4)
declare @rr nvarchar(4)
declare @uu int
set @uu=0
while @uu < 22 --(select count(單位代碼) from View_LiveUnit where 單位代碼 < 0242)
begin
--print @uu
select top 1 @rr=單位代碼 from View_LiveUnit order by 單位代碼 --where 單位代碼 > @rr
select top 1 @rt=單位代碼 from View_LiveUnit where 單位代碼 > @rr order by 單位代碼
print @rt
set @uu+=1
end

7月 17, 2015

sql 指標的使用方法

declare @p3 nvarchar(4);
DECLARE cs CURSOR FAST_FORWARD for select 單位代碼 from View_LiveUnit where 單位代碼 < 0242;
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
open cs;
FETCH NEXT FROM cs INTO @p3;
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO [HR].[dbo].[HR_UnitDivisionCode]
([單位代碼]
,[科別代碼]
,[生效日期]
,[總分行別]
,[科別名稱]
)
VALUES
(@p3,531,getdate(),0,'作業組'

)
INSERT INTO [HR].[dbo].[HR_UnitDivisionCode]
([單位代碼]
,[科別代碼]
,[生效日期]
,[總分行別]
,[科別名稱]
)
VALUES
(@p3,532,getdate(),0,'業務組'

)
FETCH NEXT FROM cs INTO @p3;
END

CLOSE cs;
DEALLOCATE cs;
END