How to import payroll data to a database from Notepad

Source: Internet
Author: User



Import payroll data from Notepad to the database,



This need to use the OpenDialog to first add this component;





1 procedure TForm3.N6Click(Sender: TObject);
2 var
3   KeFuAry: TArray<string>;
4   YueFen: string;
5   MyList: TStringList;
6   MyAdoq: TADOQuery;
7   I: Integer;
8 begin
9   MyList := TStringList.Create;
10   MyAdoq := TADOQuery.Create(nil);
11 try
12     MyAdoq.Connection := frmDataPool.ADOConnection1;
13 / / get month
14 if not inputquery ("input month", "input month", Yuefen) then
15 begin
16 showmessage ('Please enter the month ');
17       Exit;
18 end;
19 / / get data from the clipboard
20 try
21     if OpenDialog1.Execute then
22 begin
23     MyList.Clear;
24     MyList.LoadFromFile(OpenDialog1.FileName);
25 end;
26     except
27       on E:EReadError do
28 showmessage ('failed to open file ');
29 end;
Thirty
31 / / take out the null value and read it line by line
32     for I := 0 to MyList.Count - 1 do
33 begin
34 If (mylist [i] < and (mylist [i] < payroll summary: ') then
35       begin
36 kefuary: = mylist [i]. Replace (':', '). Replace (', '). Replace (', '). Replace ('), '). Replace (' - personal social security ','). Replace ('- personal provident fund', ',')
37 replace ('+ overtime leave', ','). Replace ('+ sales commission', '). Replace (' + sales bonus', '). Replace (' + point bonus', ','). Replace ('+ QQ group bonus',', ')
38 replace ('=', ','). Replace ('yuan ','). Split ([',']);
Thirty-nine
40 / / write to database
41         with MyAdoq do
42         begin
43           Close;
44 SQL. Text: = 'insert into salary table (month, name, basic salary, individual social security payment, individual accumulation fund payment, overtime leave, sales commission, sales bonus, after-sales bonus, QQ group level bonus, total salary) values (' + Yuefen. Quotedstring + ',' + kefuary [0]. Quotedstring + ',')+
45                       KeFuAry[1]+‘,-‘+KeFuAry[2]+‘,-‘+KeFuAry[3]+‘,‘+KeFuAry[4]+‘,‘+KeFuAry[5]+‘,‘+
46                       KeFuAry[6]+‘,‘+KeFuAry[7]+‘,‘+KeFuAry[8]+‘,‘+KeFuAry[9]+‘)‘;
47           ExecSQL;
48         end;
49       end;
Fifty
51 / / prevent program death
52       Application.ProcessMessages;
53 end;
Fifty-four
55 / / refresh the display
56 frmdatapool.qry payroll.close;
57 frmDataPool.qry payroll.Open;
58 finally
59     MyList.Free;
60     MyAdoq.Free;
61 end;
62 end; 





How to import payroll data to a database from Notepad


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.