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

📄 frm_jobu.~pas

📁 这是一个毕业生就业管理系统
💻 ~PAS
字号:
unit frm_jobU;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, frm_infoU, DB, StdCtrls, Grids, DBGrids, ComCtrls,Control_jobU,
  ClassesU,Control_companyU;

type
  Tfrm_job = class(Tfrm_info)
    Label1: TLabel;
    edt_company: TEdit;
    Label2: TLabel;
    Label4: TLabel;
    DTP_beginDate: TDateTimePicker;
    edt_address: TEdit;
    Label5: TLabel;
    Label3: TLabel;
    edt_jobnum: TEdit;
    Label6: TLabel;
    edt_duty: TEdit;
    Memo_remark: TMemo;
    procedure btn_addClick(Sender: TObject);
    procedure btn_delClick(Sender: TObject);
    procedure btn_editClick(Sender: TObject);
    procedure DBGrid_infoCellClick(Column: TColumn);
    procedure edt_jobnumKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    procedure FillData;override;
  end;

var
  frm_job: Tfrm_job;

implementation

{$R *.dfm}
procedure Tfrm_job.FillData;
begin
  self.DataSource_info.DataSet:=Control_JobU.GetJobArray;
  self.DBGrid_info.Columns[0].Visible  :=false;
end;

procedure Tfrm_job.btn_addClick(Sender: TObject);
var
  Job:TJob;
  Company:TCompany;
begin
  inherited;
 if((edt_company.Text='') or (edt_jobnum.Text='') or (edt_duty.Text='')
    or (edt_address.Text='')) then
        begin
           MessageBox(Handle, '内容填写不正确!', '信息', MB_ICONEXCLAMATION);
           exit;
        end;
 Company:=TCompany.Create;
 Company:=Control_CompanyU.GetCompanyByName(self.edt_company.Text);
     if Company=nil then
       begin
         MessageBox(Handle, '单位填写不正确!', '信息', MB_ICONEXCLAMATION);
         edt_company.SetFocus;
         exit;
       end;

      Job:=TJob.Create;
      Job.id:=edt_company.Tag;
      Job.companyID:=company.id;
      Job.jobDate:=DateToStr(self.DTP_beginDate.Date);
      Job.jobNum:=strtoint(self.edt_jobnum.Text);
      Job.jobDuty:=self.edt_duty.Text;
      Job.address:=self.edt_address.Text;
      Job.remark:=self.Memo_remark.Text;

      if(Control_JobU.AddJob(Job)) then
        begin
          MessageBox(Handle, '添加成功!', '信息', MB_ICONASTERISK);
          //刷新内容
          FillData;
          if self.DBGrid_info.Fields[0].IsNull then
            begin
              self.edt_Company.Tag:=0;//保存id
              self.edt_Company.Text:='';
              self.DTP_beginDate.Date :=now;
              self.edt_jobnum.Text:='0';
              self.edt_duty.Text:='';
              self.edt_address.Text:='';
              self.Memo_remark.Text:='';
            end
          else
            begin
              self.edt_company.Tag:=self.DBGrid_info.Fields[0].Value;//保存id
              self.edt_company.Text:=self.DBGrid_info.Fields[1].Value;
              self.DTP_beginDate.Date :=self.DBGrid_info.Fields[2].Value;
              self.edt_jobnum.Text:=self.DBGrid_info.Fields[3].Value;
              self.edt_duty.Text:=self.DBGrid_info.Fields[4].Value;
              self.edt_address.Text:=self.DBGrid_info.Fields[5].Value;
              self.Memo_remark.Text:=self.DBGrid_info.Fields[6].Value;
            end;
        end
      else
        begin
          MessageBox(Handle, '添加失败!', '信息', MB_ICONEXCLAMATION);
          exit;
        end;
end;

procedure Tfrm_job.btn_delClick(Sender: TObject);
begin
  inherited;
if MessageBox(Handle, '您确定要删除该信息', '信息',
     MB_ICONQUESTION or MB_OKCANCEL) = IDOK then
    begin
      Control_JobU.DelJob(self.edt_company.Tag);
      FillData;
      if self.DBGrid_info.Fields[0].IsNull then
            begin
              self.edt_Company.Tag:=0;//保存id
              self.edt_Company.Text:='';
              self.DTP_beginDate.Date :=now;
              self.edt_jobnum.Text:='0';
              self.edt_duty.Text:='';
              self.edt_address.Text:='';
              self.Memo_remark.Text:='';
            end
          else
            begin
              self.edt_company.Tag:=self.DBGrid_info.Fields[0].Value;//保存id
              self.edt_company.Text:=self.DBGrid_info.Fields[1].Value;
              self.DTP_beginDate.Date :=self.DBGrid_info.Fields[2].Value;
              self.edt_jobnum.Text:=self.DBGrid_info.Fields[3].Value;
              self.edt_duty.Text:=self.DBGrid_info.Fields[4].Value;
              self.edt_address.Text:=self.DBGrid_info.Fields[5].Value;
              self.Memo_remark.Text:=self.DBGrid_info.Fields[6].Value;
            end;
    end;
end;

procedure Tfrm_job.btn_editClick(Sender: TObject);
var
  Job:TJob;
  Company:TCompany;
begin
  inherited;
 if edt_company.Text ='' then
    begin
      MessageBox(Handle, '没有可以修改的数据!', '信息', MB_ICONEXCLAMATION);
      exit;
    end
  else
    begin
       if((edt_company.Text='') or (edt_jobnum.Text='') or (edt_duty.Text='')
          or (edt_address.Text='')) then
      begin
         MessageBox(Handle, '内容填写不正确!', '信息', MB_ICONEXCLAMATION);
         exit;
      end;
     Company:=TCompany.Create;
     Company:=Control_CompanyU.GetCompanyByName(self.edt_company.Text);
     if Company=nil then
       begin
         MessageBox(Handle, '单位填写不正确!', '信息', MB_ICONEXCLAMATION);
         edt_company.SetFocus;
         exit;
       end;

      Job:=TJob.Create;
      Job.id:=edt_company.Tag;
      Job.companyID:=company.id;
      Job.jobDate:=DateToStr(self.DTP_beginDate.Date);
      Job.jobNum:=strtoint(self.edt_jobnum.Text);
      Job.jobDuty:=self.edt_duty.Text;
      Job.address:=self.edt_address.Text;
      Job.remark:=self.Memo_remark.Text;

      if(Control_JobU.EditJob(Job)) then
        begin
          MessageBox(Handle, '修改成功!', '信息', MB_ICONASTERISK);
          //刷新内容
          FillData;
        end
      else
         begin
          MessageBox(Handle, '修改失败!', '信息', MB_ICONEXCLAMATION);
          exit;
         end;
          self.edt_company.SetFocus;
  end;
end;

procedure Tfrm_job.DBGrid_infoCellClick(Column: TColumn);
begin
  inherited;
    if self.DBGrid_info.Fields[0].IsNull then
            begin
              self.edt_Company.Tag:=0;//保存id
              self.edt_Company.Text:='';
              self.DTP_beginDate.Date :=now;
              self.edt_jobnum.Text:='0';
              self.edt_duty.Text:='';
              self.edt_address.Text:='';
              self.Memo_remark.Text:='';
            end
          else
            begin
              self.edt_company.Tag:=self.DBGrid_info.Fields[0].Value;//保存id
              self.edt_company.Text:=self.DBGrid_info.Fields[1].Value;
              self.DTP_beginDate.Date :=self.DBGrid_info.Fields[2].Value;
              self.edt_jobnum.Text:=self.DBGrid_info.Fields[3].Value;
              self.edt_duty.Text:=self.DBGrid_info.Fields[4].Value;
              self.edt_address.Text:=self.DBGrid_info.Fields[5].Value;
              self.Memo_remark.Text:=self.DBGrid_info.Fields[6].Value;
            end;
end;



procedure Tfrm_job.edt_jobnumKeyPress(Sender: TObject; var Key: Char);
begin
  inherited;
if not((key in ['0'..'9',#8,#13])) then
    key:=#0;
end;

end.

⌨️ 快捷键说明

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