📄 selreturnfrm.pas.bak
字号:
cbPayModes.ItemIndex:=iIndex;
if cdsSelReturnTransfer.Value Then Begin
ActAudit.Enabled:=False and CanAudit;
ActRevert.Enabled:=True and CanRevert;
Lab_State.Caption:='单据状态:已审核';
Lab_State.Font.Color:=clRed;
End Else Begin
ActAudit.Enabled:=True and CanAudit;
ActRevert.Enabled:=False and CanRevert;
Lab_State.Caption:='单据状态:未审核';
Lab_State.Font.Color:=clHotLight;
End;
End;
procedure TFmSelReturn.edProvNameButtonClick(Sender: TObject);
Var
sCustNo,sCustName,sEmpNo,sPayModeNo : String;
begin
if FEditMode=0 Then Exit;
sCustNo := cdsSelReturnCustNo.Value;
if SelectCust(sCustNo,sCustName,sEmpNo,sPayModeNo) Then
Begin
cdsSelReturnCustNo.Value := sCustNo;
cdsSelReturnCustName.Value := sCustName;
cdsSelReturnEmpNo.Value := sEmpNo;
cdsSelReturnPayModeNo.Value := sPayModeNo;
End;
End;
procedure TFmSelReturn.cdsSelReturnDtlGoodsIDChange(Sender: TField);
{Var
LogText,Flag,sGoodsID,sSetFields,sCustNo:String;
Begin
if FEditMode=0 Then Exit;
if FlagGoodsID<>'' Then Begin
FlagGoodsID:='';
Exit;
End;
// if bBrowGoods then Exit;
sGoodsID:=cdsSelReturnDtlGoodsID.AsString;
if sGoodsID='' Then Exit;
if (BeforeGoodsID=sGoodsID) Then Exit;
BeforeGoodsID:=sGoodsID;
sSetFields:= 'Name,Specs,Unit';
sCustNo := cdsSelReturnCustNo.Value;
FlagGoodsID:=GetGoodsInfo(cdsSelReturnDtl,'OPrice',sGoodsID,sSetFields,sCustNo,'S',1);
if FlagGoodsID='' Then Begin
Messagebox(Handle,'无效药品编号',nil,16);
Abort;
End Else Begin
if sGoodsID<>FlagGoodsID then
cdsSelReturnDtl.FieldByName('GoodsID').AsString:=FlagGoodsID
Else
FlagGoodsID:='';
End;}
begin
ParseGoodsInfo;
End;
procedure TFmSelReturn.SumCount;
Var
dOPrice,dRebate,dTaxRate,dQty,
dUnTaxPrice,dPrice,dGoodsSum,dAmount:Double;
begin
//基本的只须标准售价、折扣,税率、数量;
dQty := cdsSelReturnDtlQTY.Value; //数量
dTaxRate:= cdsSelReturnDtlTaxRate.Value; //税率
dOPrice := cdsSelReturnDtlOPrice.Value; //标准售价
if cdsSelReturnDtlRebate.IsNull Then
dRebate := 1
Else
dRebate := cdsSelReturnDtlRebate.Value/100; //折扣
dPrice := dOPrice*dRebate; //实际售价=标准售价*折扣
cdsSelReturnDtlPrice.Value := dPrice; //保存实际售价
dUnTaxPrice := dPrice/(1+dTaxRate/100); //未税单价(实际单价/1+(税率)%)
cdsSelReturnDtlUnTaxPrice.Value := dUnTaxPrice; //保存未税单价
dGoodsSum := dQty*dUnTaxPrice; //计算货款=数量*未税单价
cdsSelReturnDtlGoodsSum.Value := dGoodsSum; //保存货款
dAmount := dQty*dPrice; //计算合计=数量*实际单价
cdsSelReturnDtlAmount.Value := dAmount; //保存合计
cdsSelReturnDtlTaxSum.Value := dAmount-dGoodsSum; //税款=合计-货款
end;
procedure TFmSelReturn.cdsSelReturnDtlOPriceChange(Sender: TField);
begin
SumCount;
end;
procedure TFmSelReturn.ShowPayModes;
Var
A:Variant;
iClientID, I, k:Integer;
begin
Try
iClientID := IFmMain.IFmMainEx.ClientID;
A:=SvrSelReturn.AppServer.GetNeedValue(iClientID,3,sPayModes);
if (Not VarIsNull(A)) And (VarIsArray(A)) Then
Begin
slPayModes.Clear;
cbPayModes.Items.Clear;
k := VarArrayHighBound(A,2);
for i:=VarArrayLowBound(A,2) to k do
Begin
slPayModes.Add(A[0,i]);
cbPayModes.Items.Add(A[0,i]+':'+A[1,i]+'('+A[2,i]+')');
End;
End;
Except
On E:Exception Do
Messagebox(Handle,Pchar(E.Message),'',16);
End;
end;
procedure TFmSelReturn.cdsSelReturnCustNoChange(Sender: TField);
Var
sCustNo,sCustName,LogText:String;
begin
if FEditMode=0 Then Exit;
sCustNo:=cdsSelReturnCustNo.Value;
if sCustNo='' Then Exit;
if sCustNo=BeforeCustNo Then Exit;
BeforeCustNo:=sCustNO;
sCustName:=VarToStr(SvrCommon.AppServer.GetCustInfo(iClientID,sCustNo,1,'CustName',LogText));
cdsSelReturnCustName.Value:=sCustName;
cdsSelReturnLinkman.Clear;
if LogText<>'' Then Begin
Messagebox(Handle,Pchar(LogText),'错误',16);
Abort;
End;
end;
procedure TFmSelReturn.cdsSelReturnEmpNoChange(Sender: TField);
Var
sEmpNo,sEmpName,LogText:String;
begin
if FEditMode=0 Then Exit;
sEmpNo:=cdsSelReturnEmpNo.Value;
if sEmpNo='' Then Exit;
if sEmpNo=BeforeEmpNo Then Exit;
BeforeEmpNo:=sEmpNO;
sEmpName:=VarToStr(SvrCommon.AppServer.GetEmpInfo(iClientID,sEmpNo,1,'Name',LogText));
cdsSelReturnEmpName.Value:=sEmpName;
if LogText<>'' Then Begin
Messagebox(Handle,Pchar(LogText),'错误',16);
Abort;
End;
end;
procedure TFmSelReturn.dbgSelReturnDtlEditButtonClick(Sender: TObject);
Var
sField:String;
dPrice:Double;
iDepotID: Integer;
DepotNo, DepotName, sProvNo: string;
Begin
if FEditMode=0 Then Exit;
sField :='';
sField := Trim(LowerCase(dbgSelReturnDtl.SelectedField.FieldName));
if sField='goodsid' Then
Begin
ParseGoodsInfo;
end
else if sField='oprice' Then
begin
dPrice := ViewGoodsPrice(cdsSelReturnDtlGoodsID.Value, cdsSelReturnDtlUnit.Value);
if dPrice>=0 Then
Begin
cdsSelReturnDtl.Edit;
cdsSelReturnDtlOprice.Value := dPrice;
end;
end
else if sField='depotno' then
begin
iDepotID := cdsSelReturnDtlDepotID.Value;
if SelectDepot(iDepotID,DepotNo,DepotName) Then Begin
cdsSelReturnDtlDepotID.Value := iDepotID;
cdsSelReturnDtlDepotNo.Value := DepotNo;
cdsSelReturnDtlDepotName.Value := DepotName;
end;
end else if sField='provno' then
begin
sProvNo := cdsSelReturnDtlProvNo.Value;
if SelectProv(sProvNo) then
begin
cdsSelReturnDtl.Edit;
cdsSelReturnDtlProvNo.Value := sProvNo;
end;
end;
end;
procedure TFmSelReturn.cdsSelReturnDtlDepotNoChange(Sender: TField);
Var
sDepotNo,LogText:String;
A:Variant;
begin
Try
if FEditMode=0 Then Exit;
sDepotNo:=cdsSelReturnDtlDepotNo.Value;
if sDepotNo='' Then Exit;
if sDepotNo=BeforeDepotNo Then Exit;
BeforeDepotNo:=sDepotNo;
A := SvrCommon.AppServer.GetDepotInfo(iClientID,sDepotNo,2,'DepotID,DepotName',LogText);
cdsSelReturnDtlDepotID.Value := A[0];
cdsSelReturnDtlDepotName.Value:= A[1];
if LogText<>'' Then Begin
Messagebox(Handle,Pchar('无效的仓库编号...'),'错误',16);
Abort;
End;
Except
Messagebox(Handle,Pchar('无效的仓库编号...'),'错误',16);
Abort;
End;
end;
procedure TFmSelReturn.ActAuditExecute(Sender: TObject);
var sBillNo, str,MatchBillNo,sBranchMachine: String;
iBranchID,iMachineId: Integer;
begin
try
If CdsSelReturn.IsEmpty then Exit;
If FEditMode>0 then Exit;
Inherited;
If Application.MessageBox('确实要审核当前数据吗?','提示',4+32)<>6 then Exit;
if not CheckBillDateValid(cdsSelReturnFDate.Value) then Exit;
sBillNo := CdsSelReturnBillNo.AsString;
if sBillNo='' then Exit;
iBranchID := iFmMain.IFmMainEx.GetLocSetting^.BranchNo;
iMachineId := IFmMain.IFmMainEx.GetLocSetting^.MachineNo;
sBranchMachine := FormatFloat('000',iBranchID)+FormatFloat('00',iMachineID);
If SvrSelReturn.AppServer.BillTurn(iClientID, 'SelReturn', 'StockOut', sBillNo, sBranchMachine, MatchBillNo) then
begin
ActAudit.Enabled:=False and CanAudit;
ActRevert.Enabled:=True and CanRevert;
Lab_State.Caption:='单据状态:已审核';
Lab_State.Font.Color:=clRed;
ActRefresh.Execute;
str := sBillNo+'号销售开单已成功转出到['+MatchBillNo+']号出库单,要查看该单据吗?';
if Application.MessageBox(PChar(str), '消息', MB_YESNO+MB_ICONINFORMATION)=IDYES then
IFmMain.DoSome(ActAudit.ModuleFile, 'ViewBill', MatchBillNo);
end else
Messagebox(Handle,'审核数据不成功!','错误',16);
Except
On E:Exception Do
Messagebox(Handle,Pchar(E.Message),'错误',16);
end;
end;
procedure TFmSelReturn.ActRevertExecute(Sender: TObject);
var sBillNo : String;
begin
try
if cdsSelReturn.IsEmpty Then Exit;
if FEditMode>0 then Exit;
if Application.MessageBox('确实要还原当前已审核过的数据吗?','提示',4+32)<>6 Then Exit;
sBillNo := cdsSelReturnBillNo.AsString;
if sBillNo='' Then Exit;
if Not(SvrSelReturn.AppServer.BillRevert(iClientID,'SelReturn',sBillNo,'')) Then Begin
Messagebox(Handle,Pchar('还原数据不成功!'),'错误',16);
End Else Begin
ActAudit.Enabled:=True and CanAudit;
ActRevert.Enabled:=False and CanRevert;
Lab_State.Caption:='单据状态:未审核';
Lab_State.Font.Color:=clHotLight;
ActRefreshExecute(Nil);
End;
except
On E:Exception Do
Messagebox(Handle,Pchar(E.Message),'错误',16);
end;
End;
procedure TFmSelReturn.ActFieldLayoutExecute(Sender: TObject);
begin
SetFieldsLayOut(LocSetting^.FieldLayoutCfgFile, Name,
[dbgSelReturnDtl,dbgSelExpense],'销售退回明细;销售退回费用');
end;
procedure TFmSelReturn.ActDataExportExecute(Sender: TObject);
begin
ExportData([cdsSelReturn, cdsSelReturnDtl,CdsSelExpense],'销售退回;销售退回明细;销售退回费用', '');
end;
function TFmSelReturn.DoSome(cType: PChar; Values: Variant): Variant;
const
cTypes = 'viewbill'#13'query';
// 查看某单 查询
var sTypes: TStrings;
i: integer;
str, str2: String;
begin
sTypes := TStringList.Create;
sTypes.Text := cTypes;
i := sTypes.IndexOf(cType);
case i of
0: begin//ViewBill
if VarIsArray(Values) then begin
str := Values[0];
str2:= Values[1];
end else begin
str := Values;
str2:= '';
end;
if str2='' then begin
if sBillNoList.IndexOf(str)<0 then
sBillNoList.Add(str);
end else
sBillNoList.Text := str2;
self.BringToFront;
SetCurrBillNo(str);
end;
end;
end;
procedure TFmSelReturn.RzDBButtonEdit2ButtonClick(Sender: TObject);
Var
sCustNo,sLinkMan : String;
begin
if FEditMode=0 Then Exit;
if DBEdit8.Text='' Then Begin
MessageBox(Handle,Pchar('请先指定客户单位!'),'错误:',16);
Exit;
End;
sCustNo := cdsSelReturnCustNo.Value;
if SelectCustLinkMan(sCustNo,sLinkMan) Then
cdsSelReturnLinkMan.Value := sLinkMan ;
end;
procedure TFmSelReturn.RzDBButtonEdit1ButtonClick(Sender: TObject);
Var sEmpNo,sEmpName:String;
begin
if FEditMode=0 Then Exit;
sEmpNo := cdsSelReturnEmpNo.Value;
if SelectEmp(sEmpNo,sEmpName) Then begin
cdsSelReturnEmpNo.Value := sEmpNo;
cdsSelReturnEmpName.Value := sEmpName;
End;
end;
procedure TFmSelReturn.ActQueryExecute(Sender: TObject);
begin
IFmMain.OnAction(Sender);
end;
procedure TFmSelReturn.cbPayModesChange(Sender: TObject);
Var iIndex : Integer;
begin
iIndex:=cbPayModes.ItemIndex;
if iIndex<>-1 Then
cdsSelReturnPayModeNo.Value:=slPayModes[iIndex];
end;
procedure TFmSelReturn.ParseGoodsInfo;
var sGoodsID,sCustNo,sUnit:string;
dPrice:Double;
b1: Boolean;
begin
if FEditMode=0 then Exit;
if bBrowGoods then Exit;
bBrowGoods := true;
try
b1:=SelectGoods(cdsSelReturnDtl, cdsSelReturnDtlGoodsID, cdsSelReturnDtlUnit, true, False, False);
if not b1 then abort;
sGoodsID := cdsSelReturnDtlGoodsID.Value;
sCustNo := cdsSelReturnCustNo.Value;
sUnit := cdsSelReturnDtlUnit.Value;
if (sGoodsID<>'') And (sUnit<>'') Then Begin
dPrice := SvrCommon.AppServer.GetGoodsPrice(IClientID,'S',sCustNo,sGoodsID,sUnit);
if dPrice<>0 Then
cdsSelReturnDtlOPrice.Value := dPrice;
End;
finally
bBrowGoods := false;
end;
end;
Initialization
RegisterClass(TFmSelReturn);
Finalization
UnRegisterClass(TFmSelReturn);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -