⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cformedithuman.pas

📁 IntraWeb应用举例
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    Exit;
  end;
  if iwcSex.ItemIndex = -1 then
  begin
    WebApplication.ShowMessage('必须指定人员性别');
    Exit;
  end;
  if iwcCountry.ItemIndex = -1 then
  begin
    WebApplication.ShowMessage('必须指定人员的国籍');
    Exit;
  end;
  if iwcEduLevel.ItemIndex = -1 then
  begin
    WebApplication.ShowMessage('必须指定人员的教育水平');
    Exit;
  end;
  if iwcEngLevel.ItemIndex = -1 then
  begin
    WebApplication.ShowMessage('必须指定人员的英语水平');
    Exit;
  end;
  if Trim(iweAge.Text) = '' then
  begin
    WebApplication.ShowMessage('必须指定人员的年龄');
    Exit;
  end;
  if Trim(iweWorkAge.Text) = '' then
  begin
    WebApplication.ShowMessage('必须指定人员的工作时间');
    Exit;
  end;
  Result := True;
end;

function TformEditHuman.GetAge: Integer;
begin
  Result := StrToInt(iweAge.Text); //获得年龄
end;

function TformEditHuman.GetWorkAge: Integer;
begin
  result := StrToInt(iweWorkAge.Text);
end;

function TformEditHuman.GetCorpId: Integer;
begin
  //获得公司ID
  result := StrToInt(GetKeyFromCombo(iwcCorp, FCorpList));
end;

function TformEditHuman.GetSex: string;
begin
  result := GetKeyFromCombo(iwcSex, FSexList);
end;

function TformEditHuman.GetCountry: string;
begin
  result := GetKeyFromCombo(iwcCountry, FCountryList);
end;

function TformEditHuman.GetEduLevel: string;
begin
  result := GetKeyFromCombo(iwcEduLevel, FEduLevelList);
end;

function TformEditHuman.GetEngLevel: string;
begin
  result := GetKeyFromCombo(iwcEngLevel, FEngLevelList);
end;

function TformEditHuman.GetResume: string;
begin
  result := Trim(iwlResume.Caption);
end;

procedure TformEditHuman.SetHId(const Value: Integer);
var
  HumanTech: THumanTech;
  I: Integer;
  FHumanTechList: TStrings;
begin
  FHId := Value;
  //设定显示
  with dmHR.badoHuman do
  begin
    iweChnName.Text := FieldByName('ChnName').AsString;
    SetComboKeyByValue(iwcCorp, FieldByName('CorpID').AsString, FCorpList);
    SetComboKeyByValue(iwcSex, FieldByName('SexCode').AsString, FSexList);
    iweAge.Text := FieldByName('Age').AsString;
    iweWorkAge.Text := FieldByName('WorkAge').AsString;
    iwePhone.Text := FieldByName('Phone').AsString;
    iweMobile.Text := FieldByName('Mobile').AsString;
    iweEmail.Text := FieldByName('Email').asstring;
    SetComboKeyByValue(iwcCountry, FieldByName('CountryCode').AsString,
      FCountryList);
    SetComboKeyByValue(iwcEduLevel, FieldByName('EduLevelCode').AsString,
      FEduLevelList);
    SetComboKeyByValue(iwcEngLevel, FieldByName('EngLevelCode').AsString,
      FEngLevelList);
    iwmEduInfo.Lines.Text := FieldByName('Education').AsString;
    iwmPrjInfo.Lines.Text := FieldByName('PrjInfo').AsString;
    iwlResume.Caption := FieldByName('Resume').AsString;
    //    if Trim(iwlResume.Caption) = '' then
    //      iwlResume.Caption := '无';
        //初始化Tech列表
    //    if Assigned(FHumanTechList) then
    //      FreeAndNil(FHumanTechList);
        //Todo:这里有内存泄漏
    FHumanTechList := TStringList.Create;
    try
      with dmHR do
      begin
        badoHumanTech.Active := False;
        badoHumanTech.ParamByName['HId'].Value := Value;
        badoHumanTech.Active := True;
        badoHumanTech.First;
        while not badoHumanTech.Eof do
        begin
          HumanTech := THumanTech.Create;
          HumanTech.TechCode := badoHumanTech.FieldByName('TechCode').AsInteger;
          HumanTech.TechLevel :=
            badoHumanTech.FieldByName('TechLevel').AsInteger;
          FHumanTechList.AddObject('', HumanTech);
          badoHumanTech.Next;
        end;
      end;
      //初始化Grid
      with iwgTech do
      begin
        RowCount := FHumanTechList.Count + 1;
        //初始化标题栏
        Cell[0, 0].Text := '技术';
        Cell[0, 1].Text := '水平';
        Cell[0, 2].Text := '';
        for i := 1 to RowCount - 1 do
        begin
          with Cell[i, 0] do
          begin
            Text := GetValueByKey(FTechList,
              IntToStr(THumanTech(FHumanTechList.Objects[i - 1]).TechCode));
          end;
          with Cell[i, 1] do
          begin
            Text := GetValueByKey(FTechLevelList,
              IntToStr(THumanTech(FHumanTechList.Objects[i - 1]).TechLevel));
          end;
          with Cell[i, 2] do
          begin
            Clickable := True;
            Text := '删除';
          end;
        end;
      end;
    finally
      FreeAndNil(FHumanTechList);
    end;
  end;
end;

procedure TformEditHuman.iwlResumeClick(Sender: TObject);
var
  FileName: string;
begin
  if (Trim(iwlResume.Caption) <> '无') and (Trim(iwlResume.Caption) <> '') then
  begin
    //gsAppPath定义在SWSystem中
    //CodeSite.SendString('download resume', gsAppPath+'resumes\'+iwlResume.Caption);
    FileName := gsAppPath + 'resumes\' + iwlResume.Caption;
    if not FileExists(FileName) then
    begin
      WebApplication.ShowMessage('没有找到相应的简历!');
      Exit;
    end;
    WebApplication.SendFile(gsAppPath + 'resumes\' + iwlResume.Caption, '', '',
      true);
  end;
end;

procedure TformEditHuman.iwbUploadClick(Sender: TObject);
var
  FileName: string;
begin
  FileName := gsAppPath + 'resumes\' + iwfResume.Filename;
  if FileExists(FileName) then
  begin
    WebApplication.ShowMessage(format('同名的%s文件已经存在,请将文档改名后重新上传', [FileName]));
    Exit;
  end;
  iwfResume.SaveToFile(gsAppPath + 'resumes\' + iwfResume.FileName);
  iwlResume.Caption := ExtractFilename(FileName);
  WebApplication.ShowMessage('文件上传成功');
end;

procedure TformEditHuman.iwgTechRenderCell(ACell: TIWGridCell; const ARow,
  AColumn: Integer);
//var
//  LTotal: Currency;
begin
  with ACell do
  begin
    //标题列
    if ARow = 0 then
    begin
      Alignment := taCenter;
      BGColor := clBlue;
      Font.Style := [fsBold];
    end;
  end;
end;

{ THumanTech }

procedure THumanTech.SetTechCode(const Value: Integer);
begin
  FTechCode := Value;
end;

procedure THumanTech.SetTechLevel(const Value: Integer);
begin
  FTechLevel := Value;
end;

procedure TformEditHuman.iwgTechCellClick(const ARow, AColumn: Integer);
var
  HumanTech: THumanTech;
begin
  //删除当前Row的记录
  iwgTech.DeleteRow(ARow);
  //  if editmode=emEdit then
  //  dmHR.adocHR.BeginTrans;
  //  try
  //    dmHR.adocEdit.CommandText :=
  //      format('Delete from tblhumantech where hid=%d and techcode=%d', [hid,
  //      techcode]);
  //    dmHR.adocEdit.Execute;
  //    dmHR.adocHR.CommitTrans;
  //  except
  //    dmHR.adocHR.RollbackTrans;
  //  end;
end;

procedure TformEditHuman.iwbAddClick(Sender: TObject);
var
  I: Integer;
begin
  //添加信息,判断是否已经添加过相应技术了,如果是就退出
  for I := 0 to iwgTech.RowCount - 1 do
  begin
    if iwgTech.Cell[I, 0].Text = iwcTech.Text then
    begin
      WebApplication.ShowMessage('列表中已经有相应的技术了');
      Exit;
    end;
  end;

  with iwgTech do
  begin
    RowCount := RowCount + 1;
    Cell[RowCount - 1, 0].Text := iwctech.Text;
    Cell[RowCount - 1, 1].Text := iwcTechlevel.Text;
    Cell[RowCount - 1, 2].Clickable := True;
    Cell[RowCount - 1, 2].Text := '删除';
  end;
end;

procedure TformEditHuman.InsertHumanTech;
var
  TechCode, TechLevel: Integer;
  I: Integer;
begin
  // with dmHR do
  begin
    //Todo:为什么页面上明明有三个记录,这里只有一个?
    for I := 1 to iwgTech.RowCount - 1 do
    begin
      TechCode := StrToInt(FTechList.Values[iwgTech.Cell[I, 0].Text]);
      TechLevel := StrToInt(FTechLevelList.Values[iwgTech.Cell[I, 1].Text]);
      dmHR.adocEdit.CommandText :=
        format('insert into TblHumanTech ( HID, CorpID, TechCode, TechLevel)' +
        'Values ( %d, %d, %d, %d)', [HID, CorpID, TechCode, TechLevel]);
      dmHR.adocEdit.Execute;
    end;
  end;
end;

procedure TformEditHuman.DelHumanTech;
var
  TechCode, TechLevel: Integer;
  I: Integer;
begin
  with dmHR do
  begin
    adocEdit.CommandText := format('delete from TblHumanTech where hid=%d',
      [HID]);
    adocEdit.Execute;
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -