//打开已存在的Excel文档
ExlApp.WorkBooks.Open(self.OpenDialog1.FileName);
ExlApp.Visible:=False;
Screen.Cursor:=crSQLWait;
for i:=2 to ExlApp.ActiveSheet.UsedRange.Rows.Count do
begin
//取出各个单元格,并对某些单元格进行判断
str_xm:=ExlApp.Cells[i,1].Value;
str_xb:=ExlApp.Cells[i,2].Value;
str_sfzh:=ExlApp.Cells[i,3].Value;
str_cbrq:=ExlApp.Cells[i,4].Value;
str_rylb:=ExlApp.Cells[i,5].Value;
str_dbzh:=ExlApp.Cells[i,6].Value;
str_jtdz:=ExlApp.Cells[i,7].Value;
str_jtdh:=ExlApp.Cells[i,8].Value;
str_yhzh:=ExlApp.Cells[i,9].Value;
str_hm:=ExlApp.Cells[i,10].Value;
str_xyh:=ExlApp.Cells[i,11].Value;
//判断身份证号的位数及校验的正确性
iLen:=length(str_sfzh);
if (iLen<>18) and (iLen<>15) then
begin
serrmsg:='该行身份证号位数不对,应为18位或15位!';
//goto L1;
end;
if iLen=18 then //18位校验位的判断
begin
if IDverify(sstr[0])=false then
begin
serrmsg:='该行证件号码校验出错!';
//goto L1;
end;
end;
if iLen=15 then //15位自动转换为18位
begin
str_sfzh:=ID15to18(sstr[0]);
end;
//性别的判断(男或女或空)
if (str_xb<>'男') and (str_xb<>'女') and (str_xb<>'') then
begin
serrmsg:='该行性别格式不对,应为男或女或为空!';
//goto L1;
end;
//参保日期的判断
if length(str_cbrq)<>6 then
begin
serrmsg:='该行参保日期位数不对,应为6位的yyyymm!';
//goto L1;
end;
Stp_Jfjl.Close;
Stp_Jfjl.StoredProcName:='JM_I_JFJL';
Stp_Jfjl.Prepare ;
Stp_Jfjl.ParamByName('p_fsdwybdm').AsString :=trim(EdtDwybdm.Text);
Stp_Jfjl.ParamByName('p_fssfzh').AsString :=str_sfzh;
Stp_Jfjl.ParamByName('p_fsxm').AsString :=str_xm;
Stp_Jfjl.ParamByName('p_fsrylb').AsString :=str_rylb;
Stp_Jfjl.ParamByName('p_fscbrq').AsString :=str_cbrq;
//低保标志或残疾标志
if copy(str_dbzh,1,1)='残' then
Stp_Jfjl.ParamByName('p_fsdbbz').AsString :='2'
else if copy(str_dbzh,1,1)='低' then
Stp_Jfjl.ParamByName('p_fsdbbz').AsString :='1'
else
Stp_Jfjl.ParamByName('p_fsdbbz').AsString :='';
Stp_Jfjl.ParamByName('p_fsdbzh').AsString :=copy(str_dbzh,2,length(str_dbzh)-1);
Stp_Jfjl.ParamByName('p_fsjtdz').AsString :=str_jtdz;
Stp_Jfjl.ParamByName('p_fsjtdh').AsString :=str_jtdh;
if ChkMfq.Checked =True then
begin
Stp_Jfjl.ParamByName('p_fsmfqbz').AsString :='1';
Stp_Jfjl.ParamByName('p_fsmfq').AsString :=trim(EdtMfq.Text);
end
else
begin
Stp_Jfjl.ParamByName('p_fsmfqbz').AsString :='0';
Stp_Jfjl.ParamByName('p_fsmfq').AsString :='';
end;
Stp_Jfjl.ParamByName('p_fsczy').AsString :=czydm;
if ChkDkbz.Checked =True then
Stp_Jfjl.ParamByName('p_dkbz').AsString :='1'
else
Stp_Jfjl.ParamByName('p_dkbz').AsString :='0';
if ChkXs.Checked =True then
Stp_Jfjl.ParamByName('p_xsbz').AsString :='1'
else
Stp_Jfjl.ParamByName('p_xsbz').AsString :='0';
try
Stp_Jfjl.ExecProc;
except
sErrMsg:='调用存储过程<JM_I_JFJL>出错!';
InsertJfjl:=false;
exit;
END;
if Stp_Jfjl.ParamByName('x_rc').AsString<>'0' then
begin
serrmsg:=Stp_Jfjl.ParamByName('x_message').AsString;
InsertJfjl:=false;
exit;
end
else
begin
InsertJfjl:=true;
end;