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

📄 frm_employu.~pas

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

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, frm_infoU, DB, StdCtrls, Grids, DBGrids,Control_employU,
  ClassesU,Control_StudentU, ComCtrls,Control_CompanyU;

type
  Tfrm_employ = class(Tfrm_info)
    Label1: TLabel;
    edt_stdNo: TEdit;
    edt_company: TEdit;
    Label2: TLabel;
    Label3: TLabel;
    Label18: TLabel;
    edt_stdNo_s: TEdit;
    btn_search_stdNo: TButton;
    edt_duty: TEdit;
    Label4: TLabel;
    DTP_date: TDateTimePicker;
    procedure btn_addClick(Sender: TObject);
    procedure btn_delClick(Sender: TObject);
    procedure btn_editClick(Sender: TObject);
    procedure DBGrid_infoCellClick(Column: TColumn);
    procedure btn_search_stdNoClick(Sender: TObject);
  private
    { Private declarations }
  public
    procedure FillData;override;
  end;

var
  frm_Employ: Tfrm_Employ;

implementation

{$R *.dfm}
procedure Tfrm_Employ.FillData;
begin
  self.DataSource_info.DataSet:=Control_EmployU.GetEmployArray;
  self.DBGrid_info.Columns[0].Visible  :=false;
  self.DBGrid_info.Columns[5].Visible  :=false;
end;

procedure Tfrm_Employ.btn_addClick(Sender: TObject);
var
  Employ:TEmploy;
  Student:TStudent;
  Company:TCompany;
begin
  inherited;
 if((edt_stdNo.Text='') or (edt_company.Text='')
    or (edt_duty.Text='')) then
        begin
           MessageBox(Handle, '内容填写不正确!', '信息', MB_ICONEXCLAMATION);
           exit;
        end;
 Student:=TStudent.Create;
 Student:=Control_StudentU.GetStudentByStudentNo(self.edt_stdNo.Text);
     if Student=nil then
       begin
         MessageBox(Handle, '学号填写不正确!', '信息', MB_ICONEXCLAMATION);
         edt_stdNo.SetFocus;
         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;
      Employ:=TEmploy.Create;
      Employ.stdNo:=Student.stdNo;
      Employ.companyID:=Company.id;
      Employ.duty:=self.edt_duty.Text;
      Employ.date:=DateToStr(self.DTP_date.Date);

      if(Control_EmployU.AddEmploy(Employ)) then
        begin
          MessageBox(Handle, '添加成功!', '信息', MB_ICONASTERISK);
          //刷新内容
          FillData;
          if self.DBGrid_info.Fields[0].IsNull then
            begin
              self.edt_stdNo.Tag:=0;//保存id
              self.edt_stdNo.Text:='';
              self.edt_company.Tag:=0;
              self.edt_company.Text :='';
              self.edt_duty.Text:='';
              self.DTP_date.Date:=now;
            end
          else
            begin
              self.edt_stdNo.Tag:=self.DBGrid_info.Fields[0].Value;
              self.edt_stdNo.Text:=self.DBGrid_info.Fields[5].Value;
              self.edt_company.Text :=self.DBGrid_info.Fields[2].Value;;
              self.edt_duty.Text:=self.DBGrid_info.Fields[3].Value;;
              self.DTP_date.Date:=self.DBGrid_info.Fields[4].Value;;
            end;
        end
      else
        begin
          MessageBox(Handle, '添加失败!', '信息', MB_ICONEXCLAMATION);
          exit;
        end;
end;

procedure Tfrm_Employ.btn_delClick(Sender: TObject);
begin
  inherited;
if MessageBox(Handle, '您确定要删除该信息', '信息',
     MB_ICONQUESTION or MB_OKCANCEL) = IDOK then
    begin
      Control_EmployU.DelEmploy(self.edt_stdNo.Tag);
      FillData;
      if self.DBGrid_info.Fields[0].IsNull then
            begin
              self.edt_stdNo.Tag:=0;//保存id
              self.edt_stdNo.Text:='';
              self.edt_company.Tag:=0;
              self.edt_company.Text :='';
              self.edt_duty.Text:='0';
              self.DTP_date.Date:=now;
            end
          else
            begin
              self.edt_stdNo.Tag:=self.DBGrid_info.Fields[0].Value;
              self.edt_stdNo.Text:=self.DBGrid_info.Fields[5].Value;
              self.edt_company.Text :=self.DBGrid_info.Fields[2].Value;;
              self.edt_duty.Text:=self.DBGrid_info.Fields[3].Value;;
              self.DTP_date.Date:=self.DBGrid_info.Fields[4].Value;;
            end;
    end;
end;

procedure Tfrm_Employ.btn_editClick(Sender: TObject);
var
  Employ:TEmploy;
  Student:TStudent;
  Company:TCompany;
begin
  inherited;
 if edt_stdNo.Text ='' then
    begin
      MessageBox(Handle, '没有可以修改的数据!', '信息', MB_ICONEXCLAMATION);
      exit;
    end
  else
    begin
      if((edt_stdNo.Text='') or (edt_company.Text='')
    or (edt_duty.Text='')) then
      begin
         MessageBox(Handle, '内容填写不正确!', '信息', MB_ICONEXCLAMATION);
         exit;
      end;
     Student:=TStudent.Create;
     Student:=Control_StudentU.GetStudentByStudentNo(self.edt_stdNo.Text);
     if Student=nil then
       begin
         MessageBox(Handle, '学号填写不正确!', '信息', MB_ICONEXCLAMATION);
         edt_stdNo.SetFocus;
         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;
      Employ:=TEmploy.Create;
      Employ.id:=edt_stdNo.Tag;
      Employ.stdNo:=Student.stdNo;
      Employ.companyID:=Company.id;
      Employ.duty:=self.edt_duty.Text;
      Employ.date:=DateToStr(self.DTP_date.Date);

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

procedure Tfrm_Employ.DBGrid_infoCellClick(Column: TColumn);
begin
  inherited;
      if self.DBGrid_info.Fields[0].IsNull then
            begin
              self.edt_stdNo.Tag:=0;//保存id
              self.edt_stdNo.Text:='';
              self.edt_company.Tag:=0;
              self.edt_company.Text :='';
              self.edt_duty.Text:='0';
              self.DTP_date.Date:=now;
            end
          else
            begin
              self.edt_stdNo.Tag:=self.DBGrid_info.Fields[0].Value;
              self.edt_stdNo.Text:=self.DBGrid_info.Fields[5].Value;
              self.edt_company.Text :=self.DBGrid_info.Fields[2].Value;;
              self.edt_duty.Text:=self.DBGrid_info.Fields[3].Value;;
              self.DTP_date.Date:=self.DBGrid_info.Fields[4].Value;;
            end;
end;

procedure Tfrm_Employ.btn_search_stdNoClick(Sender: TObject);
begin
  inherited;
  self.DataSource_info.DataSet:=
       Control_EmployU.GetEmployByStdNO(self.edt_stdNo_s.Text);
  self.DBGrid_info.Columns[0].Visible  :=false;
end;

end.

⌨️ 快捷键说明

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