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

📄 umain.~pas

📁 一个小程序
💻 ~PAS
📖 第 1 页 / 共 3 页
字号:
  if ortbl1WMID.AsString='4' then
    Text:='4-联营';
  if ortbl1WMID.AsString='5' then
    Text:='5-租赁';
end;

procedure TwMain.ortbl1WMIDSetText(Sender: TField; const Text: String);
begin
  if Text='1-经销' then
    ortbl1WMID.Value:='1';
  if (Text='2-成本代销') then
    ortbl1WMID.Value:='2';   
  if (Text='3-扣率代销') then
    ortbl1WMID.Value:='3';
  if (Text='4-联营') then
    ortbl1WMID.Value:='4';
  if (Text='5-租赁') then
    ortbl1WMID.Value:='5';
end;

procedure TwMain.RzEditSupidKeyPress(Sender: TObject; var Key: Char);
var
  lqry:TOraQuery;
  lsql:string;
  lcnt:Integer;
begin
  if Key=#13 then
  begin
    if RzEditSupid.Text='' then exit;
  
    lqry:=TOraQuery.Create(Application);
    lqry.Session:=DmEl.orsn1;
    lqry.FetchAll:=True;
    try            
      lsql:='select sbcname from dbusrpub.supplierbase@eldata '+
            ' where sbid='''+trim(RzEditSupid.Text)+'''';
      lcnt:=OraOpenQry(lqry,lsql);
      if lcnt<>1 then
      begin
        WarningMsgBox('供应商不存在存在!');
        Exit;
      end;
      lqry.First;
      RzLabelGys.Caption:=lqry.FieldValues['sbcname'];

      lsql:='select cmsupid,cmcontno,cmstatus,cmwmid,cmtitle '+
            '  from '+RzEditUser.Text+'.contmain@eldata '+
            ' where cmsupid='''+trim(RzEditSupid.Text)+''' and '+
            '       cmstatus=''Y'' order by cmcontno desc';
      lcnt:=OraOpenQry(lqry,lsql);
      if lcnt<1 then
      begin
        RzEditSupid.SetFocus;
        Exit;
      end;
      lqry.First;
      cbbContid.Items.Clear;
      if lcnt=1 then
        begin
          cbbContid.Items.Add(lqry.FieldValues['cmcontno']);
          cbbContid.Text:=lqry.FieldValues['cmcontno'];
          cbbContidKeyPress(Sender,Key);
        end
      else
        while not lqry.Eof do
        begin
          cbbContid.Items.Add(lqry.FieldValues['cmcontno']);
          lqry.Next;
        end;
      cbbContid.SetFocus;
    finally
      lqry.Free;
    end;
  end;
end;

procedure TwMain.RzEditNameKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
    RzEditAlias.SetFocus;
end;

procedure TwMain.RzEditAliasKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
    RzEditIp.SetFocus;
end;

procedure TwMain.RzEditIpKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
    RzEditUser.SetFocus;
end;

procedure TwMain.RzEditUserKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
    RzEditPass.SetFocus;
end;

procedure TwMain.RzEditPassKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
    RzEditPort.SetFocus;
end;

procedure TwMain.RzEditPortKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
    RzEditName.SetFocus;
end;

procedure TwMain.cbbContidKeyPress(Sender: TObject; var Key: Char);
var
  lqry:TOraQuery;
  lsql:string;
  lcnt:Integer;
begin
  if Key=#13 then
  begin
    if RzEditSupid.Text='' then exit;
    if iOperOra='S' then
    begin     
      if RzRadioButtonJe.Checked then
        RzNumericEditJe.SetFocus
      else
        RzNumericEditBl.SetFocus;
      Exit;
    end;
  
    lqry:=TOraQuery.Create(Application);
    lqry.Session:=DmEl.orsn1;
    lqry.FetchAll:=True;
    try
      lsql:='select count(*) cnt from Eltwoacc1 '+
            ' where supid='''+trim(RzEditSupid.Text)+''' and '+
            '       contid='''+trim(cbbContid.Text)+'''';
      lcnt:=OraOpenQry(lqry,lsql);
      if lcnt>0 then
      begin
        if lqry.FieldValues['cnt']>0 then
        begin
          WarningMsgBox('供应商,合同已经存在!');
          exit;
        end;
      end;
      lsql:='select cmsupid,cmcontno,cmstatus,cmwmid,cmtitle from '+RzEditUser.Text+'.contmain@eldata '+
            ' where cmsupid='''+trim(RzEditSupid.Text)+''' and '+
            '       cmcontno='''+trim(cbbContid.Text)+''' and '+
            '       cmstatus=''Y''';
      lcnt:=OraOpenQry(lqry,lsql);
      if lcnt<>1 then Exit;
      RzEditWmid.Text:=lqry.FieldValues['cmwmid'];
      if RzRadioButtonJe.Checked then
        RzNumericEditJe.SetFocus
      else
        RzNumericEditBl.SetFocus;
    finally
      lqry.Free;
    end;
  end;
end;

procedure TwMain.RzNumericEditBlKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
    RzEditSupid.SetFocus;
end;

procedure TwMain.RzNumericEditJeKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
    RzNumericEditBl.SetFocus;
end;

procedure TwMain.btn8Click(Sender: TObject);
var
  Safer: TCursor;
begin     
  Safer:=Screen.Cursor;
  Screen.Cursor:=crHourGlass;
  if StrToDate(edtKsrq.Text)>StrToDate(edtJsrq.Text) then
  begin
    WarningMsgBox('开始日期大于结束日期');
    edtKsrq.SetFocus;
    Exit;
  end;
  rzstspnInfo.Caption:='开始运算数据,请等待...';
  DmEl.orsn1.StartTransaction;
  OraStoredProc1.UnPrepare;
  OraStoredProc1.Prepare;
  OraStoredProc1.Params.ParamByName('vksrq').AsDate:=StrToDate(edtKsrq.Text);
  OraStoredProc1.Params.ParamByName('vjsrq').AsDate:=StrToDate(edtJsrq.Text);
  try
    OraStoredProc1.ExecProc;
    DmEl.orsn1.Commit;
    rzstspnInfo.Caption:='运算数据结束,请检查(:';
  except
    on e:Exception do
    begin
      DmEl.orsn1.Rollback;   
      rzstspnInfo.Caption:='运算数据错误,请检查):';
      ErrorMsgBox('运算数据错误!'+e.Message);
    end;
  end;

  Screen.Cursor:=Safer;
end;

procedure TwMain.tbl1AfterOpen(DataSet: TDataSet);
begin
  RzEditName.Text:=tbl1.FieldByName('dbname').AsString;
  RzEditAlias.Text:=tbl1.FieldByName('dbalias').AsString;
  RzEditUser.Text:=tbl1.FieldByName('dbuser').AsString;
  RzEditPass.Text:=tbl1.FieldByName('dbpass').AsString;
  RzEditIp.Text:=tbl1.FieldByName('dbip').AsString;
  RzEditPort.Text:=tbl1.FieldByName('dbport').AsString;
end;

procedure TwMain.ortbl1AfterOpen(DataSet: TDataSet);
var
  lqry:TOraQuery;
  lsql:string;
  lcnt:Integer;
begin            
  if not ortbl1.Active then Exit;
  lqry:=TOraQuery.Create(Application);
  lqry.Session:=DmEl.orsn1;
  lqry.FetchAll:=True;
  try
    
    RzEditSupid.Text:=ortbl1.FieldByName('SUPID').AsString;
    RzLabelGys.Caption:=ortbl1.FieldByName('SUPNAME').AsString;

    cbbContid.Text:=ortbl1.FieldByName('CONTID').AsString;
    if ortbl1.FieldByName('TYPE').AsString='1' then
      RzRadioButtonJe.Checked:=True
    else
      RzRadioButtonBl.Checked:=True;
    RzEditWmid.Text:=ortbl1.FieldByName('WMID').AsString;
    RzEditMfid.Text:=ortbl1.FieldByName('MFID').AsString;
    if not (RzEditMfid.Text='') then
    begin
      lsql:='select mfcname from dbusrpub.manaframe@eldata '+
            ' where mfcode='''+trim(RzEditMfid.Text)+''' and '+
            '       mffcode='''+gMktid+'''';
      lcnt:=OraOpenQry(lqry,lsql);
      if lcnt=1 then
        RzLabelGz.Caption:=lqry.FieldValues['mfcname']
      else
        RzLabelGz.Caption:='';
    end;
    
    RzNumericEditJe.Text:=FloatToStr(ortbl1.FieldByName('je').AsFloat);
    RzNumericEditBl.Text:=FloatToStr(ortbl1.FieldByName('bl').AsFloat);
    RzEditSupid.SetFocus;
    
  finally
    lqry.Free;
  end;

end;

procedure TwMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  DmEl.orsn1.Close;
  DmEl.ado1.Close;
end;

procedure TwMain.btn9Click(Sender: TObject);
begin 
  if (RzEditFindGys.Text='') and (RzEditContId.Text='') then exit;
  if not (RzEditContId.Text='') then
    if ortbl1.Locate('CONTID',RzEditContId.Text,[]) then
    else
    begin
      Application.MessageBox(PChar('对不起,没有该合同!'), PChar('提示'), MB_ICONEXCLAMATION);
      RzEditContId.Text:='';
      RzEditContId.setfocus;
    end
  else
    if not (RzEditFindGys.Text='') then
      if ortbl1.Locate('supid',RzEditFindGys.Text,[]) then
      else
      begin
        Application.MessageBox(PChar('对不起,没有该供应商!'), PChar('提示'), MB_ICONEXCLAMATION);
        RzEditFindGys.Text:='';
        RzEditFindGys.setfocus;
      end;

end;

procedure TwMain.RzEditMfidKeyPress(Sender: TObject; var Key: Char);
var
  lqry:TOraQuery;
  lsql:string;
  lcnt:Integer;
begin
  if Key=#13 then
  begin
    if RzEditMfid.Text='' then exit;
  
    lqry:=TOraQuery.Create(Application);
    lqry.Session:=DmEl.orsn1;
    lqry.FetchAll:=True;
    try            
      lsql:='select mfcname from dbusrpub.manaframe@eldata '+
            ' where mfcode='''+trim(RzEditMfid.Text)+''' and '+
            '       mffcode='''+gMktid+'''';
      lcnt:=OraOpenQry(lqry,lsql);
      if lcnt<>1 then
      begin
        WarningMsgBox('柜组编码不存在存在!');
        Exit;
      end;
      lqry.First;
      RzLabelGz.Caption:=lqry.FieldValues['mfcname'];  
      if RzRadioButtonJe.Checked then
        RzNumericEditJe.SetFocus
      else
        RzNumericEditBl.SetFocus;
    finally
      lqry.Free;
    end;
  end;
end;

procedure TwMain.cbbContidExit(Sender: TObject);
var
  lqry:TOraQuery;
  lsql:string;
  lcnt:Integer;
begin
  if RzEditSupid.Text='' then exit;
  if cbbContid.Text='' then exit;
  if iOperOra='S' then
  begin     
    if RzRadioButtonJe.Checked then
      RzNumericEditJe.SetFocus
    else
      RzNumericEditBl.SetFocus;
    Exit;
  end;
  
  lqry:=TOraQuery.Create(Application);
  lqry.Session:=DmEl.orsn1;
  lqry.FetchAll:=True;
  try
    lsql:='select count(*) cnt from Eltwoacc1 '+
          ' where supid='''+trim(RzEditSupid.Text)+''' and '+
          '       contid='''+trim(cbbContid.Text)+'''';
    lcnt:=OraOpenQry(lqry,lsql);
    if lcnt>0 then
    begin
      if lqry.FieldValues['cnt']>0 then
      begin
        WarningMsgBox('供应商,合同已经存在!'); 
        cbbContid.SetFocus;
        exit;
      end;
    end;
    lsql:='select cmsupid,cmcontno,cmstatus,cmwmid,cmtitle from '+RzEditUser.Text+'.contmain@eldata '+
          ' where cmsupid='''+trim(RzEditSupid.Text)+''' and '+
          '       cmcontno='''+trim(cbbContid.Text)+''' and '+
          '       cmstatus=''Y''';
    lcnt:=OraOpenQry(lqry,lsql);
    if lcnt<>1 then
    begin
      cbbContid.SetFocus;
      Exit;
    end;
    RzEditWmid.Text:=lqry.FieldValues['cmwmid'];
    if RzRadioButtonJe.Checked then
      RzNumericEditJe.SetFocus
    else
      RzNumericEditBl.SetFocus;
  finally
    lqry.Free;
  end;
end;

end.

⌨️ 快捷键说明

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