u_gwbj.pas

来自「一个电力企业的后台管理程序」· PAS 代码 · 共 1,240 行 · 第 1/3 页

PAS
1,240
字号
     begin
        sLst := lbList.Items.Strings[ii];
        sLst := Copy(sLst,1,Pos(',',sLst)-1);
        sAuth[StrToInt(sLst)] :='1';
     end;
  end;
  Result := sAuth;
end;


procedure TFrm_Gwsz.SBtn_SaveClick(Sender: TObject);
var
  sPosition, sPosition0 :String;
  MyTNode1 :TTreeNode;
  MyRecPtr: PMyRec;
  bl :Boolean;
begin
   bl := True;
   sPosition := Trim(Edit2.Text);
   Case cSave of {0:新建;1:修改}
    '0' :
         begin
            if sPosition ='' then
            begin
               MessageBox(0,'请输入岗位名称!','提示...',MB_ICONEXCLAMATION+MB_OK);
               Exit;
            end;
            With Qry_pub1 do
            begin
               Close;
               Sql.Clear ;
               Sql.Add ('Select Position From DFWF_Position Where Position =:p1');
               ParamByName('p1').AsString := sPosition;
               Open;
               if Not IsEmpty then
               Begin
                   MessageBox(0,'岗位重复,请检查新建岗位!','提示...',MB_ICONEXCLAMATION+MB_OK);
                   Edit2.SetFocus ;
                   Close;
                   Exit;
               end;
               Close;
               Sql.Clear ;
               Sql.Add ('Insert Into DFWF_Position(Position,UpperPos,Organ,Property,Authority,AwakeWorkId_1,AwakeWorkId_2,AwakeWorkId_3,CreateTime,Note)');
               Sql.Add ('Values(:p1,:p2,:p3,:p4,:p10,:p5,:p6,:p7,:p8,:p9)');
               ParamByName('p1').AsString := sPosition;
               ParamByName('p2').AsString := Edit1.Text;
               ParamByName('p3').AsString := CmbOrgan.Text ;
               ParamByName('p4').AsString := Mm_Prop.Text ;
               ParamByName('p10').AsString := GetAuth(LbAuthSel);
               ParamByName('p5').AsString := Cmb_cs1.Items.Names[Cmb_cs1.ItemIndex];
               ParamByName('p6').AsString := Cmb_cs2.Items.Names[Cmb_cs2.ItemIndex];
               ParamByName('p7').AsString := Cmb_cs3.Items.Names[Cmb_cs3.ItemIndex];
               ParamByName('p8').AsDateTime := DTP_CL.DateTime ;
               ParamByName('p9').AsString := Mm_Note.Text ;
               ExecSql;
               Close;
            end;
            InsertPeoplePos(sPosition);
            New(MyRecPtr);
            MyRecPtr^.Sign := '0';
            MyRecPtr^.WorkID := '';
            MyRecPtr^.Position := sPosition;

            MyTNode1 := TVPosition.Items.AddChildObject(TVPosition.Selected,sPosition,MyRecPtr);
            MyTNode1.SelectedIndex :=8;
            TVPosition.Items.AddChild(MyTNode1,'');
            cSave :='2';
            Nb_Gw.PageIndex :=0;
         end;
    '1' :
         begin
            sPosition0 := PMyRec(TVPosition.Selected.Data)^.Position ;
            if sPosition0 <>sPosition then
            Begin
                With Qry_pub1 do
                begin
                   Close;
                   Sql.Clear ;
                   Sql.Add ('Select Position From DFWF_Position Where Position =:p1');
                   ParamByName('p1').AsString := sPosition;
                   Open;
                   if Not IsEmpty then
                   Begin
                       MessageBox(0,'岗位重复,请检查改后岗位!','提示...',MB_ICONEXCLAMATION+MB_OK);
                       Edit2.SetFocus ;
                       Close;
                       Exit;
                   end;
                   Close;
                   Sql.Clear ;
                   Sql.Add ('Update DFWF_Position Set UpperPos =:P1 Where UpperPos =:p2');
                   ParamByName('p1').AsString := sPosition ;
                   ParamByName('p2').AsString := sPosition0 ;
                   ExecSql;
                end;
            end;
            With Qry_pub1 do
            begin
               Close;
               Sql.Clear ;
               Sql.Add ('Update DFWF_Position');
               Sql.Add ('Set Position =:p1,UpperPos =:p2,Organ =:p3,Property =:p4');
               Sql.Add (',CreateTime =:p5,Note =:p6,AwakeWorkid_1 =:p8,');
               Sql.Add ('AwakeWorkid_2 =:p9,AwakeWorkid_3 =:p10, Authority =:p11');
               Sql.Add ('Where Position =:p7');
               ParamByName('p1').AsString := sPosition;
               ParamByName('p2').AsString := Edit1.Text;
               ParamByName('p3').AsString := CmbOrgan.Text ;
               ParamByName('p4').AsString := Mm_Prop.Text ;
               ParamByName('p8').AsString := Cmb_cs1.Items.Names[Cmb_cs1.ItemIndex];
               ParamByName('p9').AsString := Cmb_cs2.Items.Names[Cmb_cs2.ItemIndex];
               ParamByName('p10').AsString := Cmb_cs3.Items.Names[Cmb_cs3.ItemIndex];
               ParamByName('p5').AsDateTime := DTP_CL.DateTime ;
               ParamByName('p6').AsString := Mm_Note.Text ;
               ParamByName('p7').AsString := sPosition0;
               ParamByName('p11').AsString := GetAuth(LbAuthSel);
               ExecSql;
               Close;
               Sql.Clear ;
               Sql.Add ('Delete DFWF_PeoplePos');
               Sql.Add ('Where Position=:p1');
               ParamByName('p1').AsString := sPosition0;
               ExecSql;
               Close;
            end;
            InsertPeoplePos(sPosition);
            TVPosition.Selected.Text := sPosition;
            PMyRec(TVPosition.Selected.Data)^.Position := sPosition;
            TVPositionExpanding(Sender, TVPosition.Selected,bl);
         end;
   end;

end;

procedure TFrm_Gwsz.TBtn_ExitClick(Sender: TObject);
begin
   Close;
end;

procedure TFrm_Gwsz.SdBtn_SavePersonClick(Sender: TObject);
var
  sSex, sWorkId0, sWorkId, sName :String;
begin
   sWorkId := Trim(Edit3.Text);
   sName := Trim(Edit4.Text);
   if sWorkId ='' then
   begin
      MessageBox(0,'请输入工号!','提示...',MB_ICONEXCLAMATION+MB_OK);
      Exit;
   end;
   if sName ='' then
   begin
      MessageBox(0,'请输入姓名!','提示...',MB_ICONEXCLAMATION+MB_OK);
      Exit;
   end;
   sWorkId0 := PMyRec(TVPosition.Selected.Data)^.WorkID ;
   sSex := Cmb_Sex.Text ;
   if sSex ='男' then sSex :='M'
   else if sSex ='女' then sSex :='F';
   With Qry_pub1 do
   begin
      if sWorkId0 <>sWorkId then
      Begin
         Close;
         Sql.Clear ;
         Sql.Add ('Select WorkId From DFWF_People Where WorkId =:p1');
         ParamByName('p1').AsString := sWorkId;
         Open;
         if Not IsEmpty then
         Begin
             MessageBox(0,'工号重复,请检查改后工号!','提示...',MB_ICONEXCLAMATION+MB_OK);
             Edit3.SetFocus ;
             Close;
             Exit;
         end;
      end;
      Close;
      Sql.Clear ;
      Sql.Add ('Update DFWF_People');
      Sql.Add ('Set WorkId =:p1,Name =:p2,Sex =:p3,PassWord =:P4,');
      Sql.Add ('Property=:p6,CreateTime=:p7,Note =:p8,Phone1 =:p10,Phone2 =:p11,Phone3 =:p12,');
      Sql.Add ('AcdGroup=:p13,SkillLevel=:p14');
      Sql.Add ('Where WorkId =:p9');
      ParamByName('p1').AsString := sWorkId ;
      ParamByName('p2').AsString := sName ;
      ParamByName('p3').AsString := sSex;
      ParamByName('p4').AsString := Edit5.Text ;
      ParamByName('p6').AsString := Mm_personProp.Text ;
      ParamByName('p7').AsDateTime := DTP_Person.DateTime ;
      ParamByName('p8').AsString := Mm_PersonNt.Text ;
      ParamByName('p9').AsString := sWorkId0;
      ParamByName('p10').AsString := Edt_Phone1.Text ;
      ParamByName('p11').AsString := Edt_Phone2.Text ;
      ParamByName('p12').AsString := Edt_Phone3.Text ;
      ParamByName('p13').AsString := Cmb_AcdGroup.Items.Names[Cmb_AcdGroup.ItemIndex];
      ParamByName('p14').AsString := Cmb_SkillLevel.Items.Names[Cmb_SkillLevel.ItemIndex];
      ExecSql;
      Close;
   end;
   PMyRec(TVPosition.Selected.Data)^.WorkID := sWorkId;
   TVPosition.Selected.Text := sName;
end;


procedure TFrm_Gwsz.PopupMenu1Popup(Sender: TObject);
var
   ii :Integer;
begin
   For ii :=0 to PopupMenu1.Items.Count -1 do
      PopupMenu1.Items[ii].Enabled := True;
   if TVPosition.Selected.Parent =nil then
   begin
      N_DelGw.Enabled := False;
      N_DelPerson.Enabled := False;
      N_Property.Enabled := False;
   end
   else if (PMyRec(TVPosition.Selected.Data)^.Sign ='0') then
      N_DelPerson.Enabled :=False
   else
   begin
     N_NewGw.Enabled := False;
     N_DelGw.Enabled := False;
   end;
end;

procedure TFrm_Gwsz.TBtn_OrgtanClick(Sender: TObject);
begin
    Frm_EditLst := TFrm_EditLst.Create(Application);
    Frm_EditLst.cEditType := '0';
    StBar.Panels[0].Text :='组织机构设置';
    Frm_EditLst.ShowModal;
    Frm_EditLst.Free;
end;

procedure TFrm_Gwsz.TBtn_PersonClick(Sender: TObject);
begin
    Frm_EditLst := TFrm_EditLst.Create(Application);
    Frm_EditLst.cEditType := '1';
    StBar.Panels[0].Text :='人员设置';
    Frm_EditLst.ShowModal;
    Frm_EditLst.Free;
end;






























{
      - - 总务科
           |
           |_ _ 王成
           |
           |_ _ 投诉处理
           |    |
           |    |_ _ 王成
           |    |
           |    |_ _ 投诉处理岗位
           |    |
           |    |_ _ 投诉审批岗位
           |         |
           |         |_ _ 王成
           |         |
           |         |_ _ 王海
           |
           |
           |_ _ 用电处理
                |
                |_ _ 用电申请处理岗位
                |
                |_ _ 用电申请岗位
}

procedure TFrm_Gwsz.FormClose(Sender: TObject; var Action: TCloseAction);
begin
    if screen.FormCount=2 then WebIsHide(0);
    Action:=CaFree;
    Frm_Gwsz :=nil;
end;

procedure TFrm_Gwsz.FormCreate(Sender: TObject);
begin
  cYe :='0';
  with DBDFWF do
  begin
    close;
    AliasName:=ReadIni('DBOption','DFWF_AliasName','');
    DatabaseName:=ReadIni('DBOption','DFWF_DatabaseName','');
    Params.Values['DATABASE NAME']:=ReadIni('DBOption','DFWF_DatabaseName','');
    Params.Values['SERVER NAME']:=ReadIni('DBOption','DFWF_ServerName','');
    Params.Values['USER NAME']:=ReadIni('DBOption','DFWF_UserName','');
    Params.Values['PASSWORD']:=ReadIni('DBOption','DFWF_PassWord','');
    try
      Open;
      Qry_OrganLst.DatabaseName := DBDFWF.DatabaseName;
      Qry_pub2.DatabaseName := DBDFWF.DatabaseName;
      Qry_PersonLst.DatabaseName := DBDFWF.DatabaseName;
    except
      Application.MessageBox('工作流数据库连接失败!','',mb_Ok);
      Close;
      cYe :='1';
    end;
  end;

end;


procedure TFrm_Gwsz.DataSyn;
var
  ii :integer;
begin
   for ii :=1 to 4 do
   begin
      With Qry_pub1 do
      begin
         Close;
         Sql.Clear;
         Sql.Add('Select * From ' + BatchTable[ii]);
         Open;
      end;
      SysDM.tbl_Batch.TableName := BatchTable[ii];
      Try
         Batch.Source := Qry_pub1;
         Batch.Destination := SysDM.tbl_Batch;

         Batch.Execute ;
      Except
         MessageBox(0,Pchar('表:' + BatchTable[ii] + ' 同步失败!'),'提示...',mB_ICONWARNING);
         Exit;
      end;
   end;
   MessageBox(0,'同步成功!','提示...',MB_ICONINFORMATION);
end;


procedure TFrm_Gwsz.Btn_DataSynClick(Sender: TObject);
begin
   DataSyn;
end;

procedure TFrm_Gwsz.sBtn_DelAuthClick(Sender: TObject);
begin
   LbAuthSel.Items.Delete(LbAuthSel.ItemIndex);
end;

procedure TFrm_Gwsz.LbAuthSelDblClick(Sender: TObject);
begin
   LbAuthSel.Items.Delete(LbAuthSel.ItemIndex);
end;

procedure TFrm_Gwsz.sBtn_AddAuthClick(Sender: TObject);
begin
   AddItemAuth(LbAllAuth.Items[LbAllAuth.ItemIndex]);
end;

procedure TFrm_Gwsz.sBtn_DellAllAuthClick(Sender: TObject);
begin
   LbAuthSel.Clear ;
end;

procedure TFrm_Gwsz.sBtn_AddAllAuthClick(Sender: TObject);
var
  ii :Integer;
begin
   for ii :=0 to LbAllAuth.Items.Count -1 do
   begin
      AddItemAuth(LbAllAuth.Items[ii]);
   end;
end;

procedure TFrm_Gwsz.LbAllAuthClick(Sender: TObject);
begin
   LbAllAuth.Hint := LbAllAuth.Items[LbAllAuth.ItemIndex] ;
end;

procedure TFrm_Gwsz.LbAllAuthDblClick(Sender: TObject);
begin
   AddItemAuth(LbAllAuth.Items[LbAllAuth.ItemIndex]);
end;

procedure TFrm_Gwsz.LbAuthSelClick(Sender: TObject);
begin
   LbAuthSel.Hint := LbAuthSel.Items[LbAuthSel.ItemIndex] ;
end;

end.

⌨️ 快捷键说明

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