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

📄 uoutputreimburse.pas

📁 天涯進銷存系統
💻 PAS
📖 第 1 页 / 共 3 页
字号:
  OpenData('Select * from ReimburseBillBody where BillCode='+
            #39+BillHandData.Fieldbyname('BillCode').asstring+#39,
            BillBodyData);
  if BillHandData.FieldByName('isAuditing').AsString='1' then
  Auditing.Visible:=True
  else
  Auditing.Visible:=False;
  if BillHandData.FieldByName('isExecute').AsString='1' then
   InPubImg.Visible:=True
  else
   InPubImg.Visible:=False;
end;

procedure TfrmOutPutReimburse.Action1Execute(Sender: TObject);
begin
  SetView;
  ClientDBEdit.SetFocus;
  ClientDBEdit.DataField:='ProviderCode';
  BillBodyData.ReadOnly:=False;
  BillHandData.ReadOnly:=False;
  BillHandData.Append;
  BillBodyData.Append;
  BillHandData.Fieldbyname('BillCode').asstring:='新单据';
  BillHandData.FieldByName('Operator').asstring:=UserName;
  BillHandData.Fieldbyname('BILLDATE').asDateTime:=Date;
  BillHandData.FieldByName('isAccept').AsString:='0';
  BillHandData.FieldByName('isAuditing').AsString:='0';
  BillHandData.Fieldbyname('ACCEPTSUM').asFloat:=0;
  BillHandData.Fieldbyname('AGIOSUM').asFloat:=0;
  BillHandData.Fieldbyname('ReimburseType').asstring:='2';
  BillBodyData.Fieldbyname('BillCode').asstring:='新单据';
  BillBodyData.Fieldbyname('ID').asInteger:=1;
  BillBodyData.Post;
  OldSum:=0;
  Sum:=0;
  OldCode:='';
  isEdit:=False;
  isStateEdit:=True;
  DepotDBEditEnter(Nil);
  BillInfoLabel.Caption:='';
  OldProviderCode:='';
end;

procedure TfrmOutPutReimburse.Action2Execute(Sender: TObject);
begin
  if BillHandData.IsEmpty then
  begin
    Application.MessageBox('没有可修改的销售退货单。',Hintinfo,$30);
    Exit;
  end;
  if BillHandData.FieldByName('isAuditing').asstring='1' then
  begin
    Application.MessageBox('此销售退货单已审核,不可修改。',Hintinfo,$30);
    Exit; 
  end;
  SetView;
  ClientDBEdit.SetFocus;
  ClientDBEdit.DataField:='ProviderCode'; 
  try
    BillHandData.ReadOnly:=False;
    BillBodyData.ReadOnly:=False;
    BillHandData.Edit;
    BillBodyData.Edit;
  except
    SetView;
    Application.MessageBox('修改数据错误。',Hintinfo,$10);
    ClientDBEdit.DataField:='ProviderName'; 
    Exit;
  end;
  Sum:=BillHandData.FieldByName('TOTALSUM').AsFloat;
  isEdit:=True;
  isStateEdit:=True;
  DepotDBEditEnter(Nil);
end;

procedure TfrmOutPutReimburse.Action3Execute(Sender: TObject);
var
  BillCode: string;
begin
  if BillHandData.IsEmpty then
  begin
    Application.MessageBox('没有可删除的销售退货单。',Hintinfo,$30);
    Exit;
  end;
  if BillHandData.FieldByName('isAuditing').asstring='1' then
  begin
    Application.MessageBox('此销售退货单已审核,不可删除。',Hintinfo,$30);
    Exit;
  end;
  if Application.MessageBox('确定在要删除当前销售退货单吗?',Hintinfo,$24)=idYes then
  begin
    BillHandData.ReadOnly:=False;
    BillCode:=BillHandData.Fieldbyname('BillCode').asstring;
    try
      BillHandData.Delete;
      BillHandData.ApplyUpdates(-1);
      DeleteBillBody('Delete From ReimburseBillBody where BillCode='+#39+BillCode+#39);
      OpenData('select * from ReimburseBillHand Order by BillCode DESC',
               BillHandData);
    except
      Application.MessageBox('删除数据不成功。',Errorinfo,$10);
    end;
    BillHandData.ReadOnly:=True;
  end;
end;

procedure TfrmOutPutReimburse.Action4Execute(Sender: TObject);
begin
  PrintView('RepOutPutReimburse.frf', Report);
end;

procedure TfrmOutPutReimburse.Action5Execute(Sender: TObject);
begin
  if BillHandData.IsEmpty then
  begin
    Application.MessageBox('没有可审核的单据。',Hintinfo,$30);
    Exit;
  end;
  if BillHandData.FieldByName('isAuditing').AsString='1' then
  begin
    Application.MessageBox('此单据已审核。',Hintinfo,$30);
    Exit;
  end;
  if Application.MessageBox('确定要审核此销售退货单吗?',Hintinfo,$24)=idYes then
     SetAuditing;
end;

procedure TfrmOutPutReimburse.Action6Execute(Sender: TObject);
begin
 if BillHandData.IsEmpty then
  begin
    Application.MessageBox('没有可入库的单据。',Hintinfo,$30);
    Exit;
  end;
  if BillHandData.FieldByName('isExecute').AsString='1' then
  begin
    Application.MessageBox('此单据已入库。',Hintinfo,$30);
    Exit;
  end;
  if BillHandData.FieldByName('isAuditing').AsString<>'1' then
  begin
    Application.MessageBox('请先审核单据后再入库。',Hintinfo,$30);
    Exit;
  end;
  try
    BillHandData.ReadOnly:=False;
    BillHandData.Edit;
    BillHandData.FieldByName('isExecute').AsString:='1';
    SavePartData:=TClientDataSet.Create(Nil);
    SavePartData.Data:=BillBodyData.Data;
    PartInPutDataSave(BillHandData.FieldByName('DepotCode').asstring,
                      BillHandData.FieldByName('DepotName').asstring,
                      BillHandData.FieldByName('BillDate').asDateTime,
                      1);
    BillHandData.ApplyUpdates(-1);
    InPubImg.Visible:=True;
    BillHandData.ReadOnly:=True;
    Application.MessageBox('入库提交数据成功。',Hintinfo,$30);
  except
    Application.MessageBox('入库提交数据不成功。',Errorinfo,$10);
    Exit;
  end;
end;


procedure TfrmOutPutReimburse.Action7Execute(Sender: TObject);
var
  sql: string;
begin
  SelectBillCode:='';
  OpposingCode:=BillHandData.Fieldbyname('ProviderCode').asstring;
  frmSelectOutPutReimburse:=TfrmSelectOutPutReimburse.Create(Application);
  frmSelectOutPutReimburse.ShowModal;
  frmSelectOutPutReimburse.Free;
  if  SelectBillCode<>'' then
  begin
    sql:='Select * from ReimburseBillHand where '+
         'BillCode='+#39+SelectBillCode+#39+
         'Order by BillCode DESC';
    OpenData(sql,BillHandData);
  end;
end;

procedure TfrmOutPutReimburse.Action8Execute(Sender: TObject);
begin
  OpenData('Select * from ReimburseBillHand where ReimburseType='''+'2'''+' Order by BillCode DESC',BillHandData);
  BillInfoLabel.Caption:='';
end;

procedure TfrmOutPutReimburse.Action9Execute(Sender: TObject);
var
  i:integer;
begin
  i:=0;
  if (BillBodyData.RecordCount=1)and
   (PartCodeDBEdit.Text='')  then
  begin
    Application.MessageBox(NotPartsOfSave, Hintinfo,$30);
    Exit;
  end;
  BillBodyData.Edit;
  BillBodyData.Post;
  DBCtrlGrid.SetFocus;
  if BillHandData.FieldByName('ProviderCode').AsString='' then
  begin
    Application.MessageBox('客户不能为空,请输入。',Hintinfo,$30);
    ClientDBEdit.SetFocus;
    Exit;
  end;
  if BillHandData.FieldByName('DepotCode').AsString='' then
  begin
    Application.MessageBox('仓库不能为空,请输入。',Hintinfo,$30);
    DepotDBEdit.SetFocus;
    Exit;
  end;
  if BillHandData.FieldByName('OrderBillNo').AsString='' then
  begin
    Application.MessageBox('入库单号不能为空,请输入。',Hintinfo,$30);
    OutPutBillCodeDBEdit.SetFocus;
    Exit;
  end;
  if BillHandData.FieldByName('BillDate').AsString='' then
  begin
    Application.MessageBox('退货日期不能为空,请输入。',Hintinfo,$30);
    BillDateDBEdit.SetFocus;
    Exit;
  end;
  if not isEdit then
  begin
    BillHandData.Edit;
    BillHandData.Fieldbyname('BILLCode').asstring:=ComDepotCode+'-'+'ST'+'-'+
          GetBillID('25', BillHandData.Fieldbyname('BILLDATE').asstring);
  end;
  with BillBodyData do
  begin
    First;
    while not Eof do
    begin
      if Fieldbyname('PartCode').asstring<>'' then
      begin
        Edit;
        Fieldbyname('ID').asinteger:=i+1;
        Fieldbyname('OutPutQry').asfloat:=0;
        Fieldbyname('BILLCode').asstring:=BillHandData.Fieldbyname('BILLCode').asstring;
        i:=i+1;
        Next;
      end
      else
      begin
        BillHandData.Edit;
        BillHandData.FieldByName('TOTALSUM').asfloat:=
        BillHandData.FieldByName('TOTALSUM').asfloat-
        Fieldbyname('TOTALSUM').AsFloat;
        Sum:=BillHandData.FieldByName('TOTALSUM').asfloat;
        Delete;
        if BillBodyData.RecNo=BillBodyData.RecordCount  then
        Next;
      end;
    end;
  end;
  if BillBodyData.IsEmpty then
  begin
    Application.MessageBox(NotPartsOfSave,Hintinfo,$30);
    Exit;
  end;
  Try
    BillBodyData.ApplyUpdates(-1);
    BillHandData.ApplyUpDates(-1);
    Application.MessageBox(DataSaveOfSucceed,Hintinfo,$30);
  except
    Application.MessageBox(DataSaveOfFail, Errorinfo,$10);
    BillBodyData.CancelUpdates;
    BillHandData.CancelUpdates;
  end;
  BillBodyData.First;
  Sum:=0;
  isStateEdit:=False;
  SetView;
  BillBodyData.ReadOnly:=True;
  BillHandData.ReadOnly:=True;
  Action5Execute(Sender);
end;

procedure TfrmOutPutReimburse.Action10Execute(Sender: TObject);
begin
  DBCtrlGrid.SetFocus;
  BillBodyData.CancelUpdates;
  BillHandData.CancelUpdates;
  BillBodyData.First;
  Sum:=0;
  isStateEdit:=False;
  SetView;
  BillBodyData.ReadOnly:=True;
  BillHandData.ReadOnly:=True;
end;

procedure TfrmOutPutReimburse.DepotDBEditEnter(Sender: TObject);
begin
  if Not isStateEdit then Exit;
  OldDepotCode:=DepotDBEdit.Text;
  SetIndexListData('select DepotCode, DepotName From Depot', DepotDBEdit, 'DepotCode','DepotName');
  if Not dmData.sdsPublic.IsEmpty then isGetList:=True;
end;

procedure TfrmOutPutReimburse.DBCtrlGridKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  key:=0;
end;

procedure TfrmOutPutReimburse.LBSpeecButton3Click(Sender: TObject);
var
  BillCode: string;
begin
  if BillHandData.IsEmpty then
  begin
    Application.MessageBox('没有可删除的采购订货单。',Hintinfo,$30);
    Exit;
  end;
  if BillHandData.FieldByName('isAuditing').asstring='1' then
  begin
    Application.MessageBox('此采购订货单已审核,不可删除。',Hintinfo,$30);
    Exit;
  end;
  if Application.MessageBox('确定在要删除当前订货单吗?',Hintinfo,$24)=idYes then
  begin
    BillHandData.ReadOnly:=False;
    BillCode:=BillHandData.Fieldbyname('BillCode').asstring;
    try
      BillHandData.Delete;
      BillHandData.ApplyUpdates(-1);
      DeleteBillBody('Delete From OrderBillBody where BillCode='+#39+BillCode+#39);
      OpenData('select * from OrderBillHand Order by BillCode DESC',
               BillHandData);
    except
      Application.MessageBox('删除数据不成功。',Errorinfo,$10);
    end;
    BillHandData.ReadOnly:=True;
  end;
end;

procedure TfrmOutPutReimburse.LBEditButton2Click(Sender: TObject);
begin
  if not isStateEdit then Exit;
  GetXoY(LBEditButton2);
  if BillHandData.Fieldbyname('BillDate').asDateTime>0 then
    sDate:=BillHandData.Fieldbyname('BillDate').asDateTime
  else
    sDate:=Date;
  SelectDate;
  BillHandData.Edit;
  BillHandData.FieldByName('BillDate').AsDateTime:=SDate;
end;

procedure TfrmOutPutReimburse.PartCodeDBEditKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key=VK_DELETE then
  begin
    BillDeletePart(BillHandData, BillBodyData);
    if BillBodyData.RecordCount=0 then
    begin
      BillHandData.Edit;
      BillHandData.FieldByName('ORDERBILLNO').AsString:='';
    end;
  end;  
  if key=13 then
  begin
    DBCtrlGrid.SetFocus;
    PartNameDBEdit.SetFocus;
  end;
  BillKeyDown(Key, BillBodyData, 15);
end;

procedure TfrmOutPutReimburse.PartNameDBEditKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  if Key=VK_DELETE then
  begin
    BillDeletePart(BillHandData, BillBodyData);
    if BillBodyData.RecordCount=0 then
    begin
      BillHandData.Edit;
      BillHandData.FieldByName('ORDERBILLNO').AsString:='';
    end;
  end;  
  if key=13 then
  begin
    DBCtrlGrid.SetFocus;
    ProducingDBEdit.SetFocus;
  end;  
  BillKeyDown(Key, BillBodyData, 15);
end;

procedure TfrmOutPutReimburse.ProducingDBEditKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  if key=13 then
  begin
    DBCtrlGrid.SetFocus;
    UnitDBEdit.SetFocus;
  end;

⌨️ 快捷键说明

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