📄 uunpos.pas
字号:
unit UUnPos;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, fm_Base, ExtCtrls, StdCtrls, Buttons, Grids, DB, DBClient;
type TSendMaster = record
vcSendBillId: string;
VcSourceId: string;
BillNo: string;
iBIlltype: integer;
vcSendStockID: string; //配送仓库
vcRecvStockID: string; //接收门店仓库
dtDrawDate: TDateTime;
dtOutStockDate: Tdatetime;
vcEId: string; ///经手人
vcListerId: string; // 制单人
vcAssessorId: string; //审核人
NSumQty: Double;
nuCess: Double;
nuTax: Double;
nuIncTaxSum: Double;
nuTotalMoney: Double;
nuUnTaxSum: Double;
BillStatus: Integer;
inVoucherSign: Integer;
inIsReadSign: Integer;
vcOutHouseReadBillId: string;
inByReadSign: Integer;
vcExplain: string;
SendStatus: Integer;
VcSendStockName: string;
VcRecvStockName: string;
ObjectID: Integer;
end;
type
TfmUnPosSendBill = class(TfmBase)
CdsMasterData: TClientDataSet;
CdsDetailData: TClientDataSet;
Panel3: TPanel;
sgorder: TStringGrid;
Panel10: TPanel;
Cmd_Delete: TSpeedButton;
Cmd_Add: TSpeedButton;
Panel2: TPanel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
bitcheck: TBitBtn;
Panel1: TPanel;
Label3: TLabel;
Label4: TLabel;
SpeedButton4: TSpeedButton;
Label5: TLabel;
SpeedButton5: TSpeedButton;
Label6: TLabel;
Panel4: TPanel;
TeThemeButton1: TSpeedButton;
TeThemeButton2: TSpeedButton;
sourcebill: TSpeedButton;
query: TSpeedButton;
help: TSpeedButton;
BillTitle: TLabel;
EdtM: TEdit;
EdtG: TEdit;
EdtC: TEdit;
EdtMemo: TEdit;
StaticText1: TStaticText;
EdtBillNo: TEdit;
Label1: TLabel;
Label7: TLabel;
SpeedButton1: TSpeedButton;
EdtRecvStock: TEdit;
EdtsendStock: TEdit;
procedure Cmd_AddClick(Sender: TObject);
procedure Cmd_DeleteClick(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure sgorderDblClick(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure sgorderSelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
procedure bitcheckClick(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure sgorderKeyPress(Sender: TObject; var Key: Char);
procedure sgorderMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure sgorderDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
private
{ Private declarations }
pcol,prow:integer; //记录行列编号
SendMaster: TSendMaster;
sBillId, SEditMode: string;
sGoodsName: string;
sUserCode: string;
zd:boolean;
ckid:string;
procedure FormIni;
//procedure SelectGoods(iRow: Integer);
function CheckData: Boolean;
function SaveData: Boolean;
function ReadBill: Boolean;
//procedure SumCol(ACol, ARow: Integer);
public
{ Public declarations }
end;
var
fmUnPosSendBill: TfmUnPosSendBill;
function ShowUNPosSendbill(sBillId: string; EditMode: string; iBillType: Integer): Integer;
implementation
uses func, Unt_PubStrGrid, untdatadm, Untselectps, USelgoodCode, Login_Man;
{$R *.dfm}
function ShowUNPosSendbill(sBillId: string; EditMode: string; iBillType: Integer): Integer;
begin
Result := 1;
fmUnPosSendBill := tfmUnPosSendBill.Create(application);
fmUnPosSendBill.sBillId := sBillId;
fmUnPosSendBill.SEditMode := UpperCase(EditMode);
fmUnPosSendBill.SendMaster.iBIlltype := iBillType;
try
fmUnPosSendBill.FormIni;
fmUnPosSendBill.ShowModal;
finally
fmUnPosSendBill.Free;
end;
end;
//////////////////////////
procedure TfmUnPosSendBill.FormIni;
var
iRow: Integer;
temp,make:string;
begin
EdtSendStock.Text := '';
EdtRecvStock.Text := trim(shopid);
EdtM.Text := trim(Handle_Man);
SendMaster.vcListerId:=edtm.Text;
EdtG.Text := '';
EdtC.Text := '';
EdtMemo.Text := '';
ckid:=shopid ;
SendMaster.vcRecvStockID:=shopid;
if sbillid='' then
begin
temp:='select max(right(billno,4)) from SendMasterTable where iBIlltype='+'505'+' and dtDrawDate='+''''+formatdatetime('yyyy''-''mm''-''dd',date)+'''';
make:='UPS-'+trim(Handle_Part)+trim(handle_no); //编码中部门编号
edtbillno.Text:=setcode(temp,make);
sgorder.RowCount := 2;
for iRow := 1 to sgorder.RowCount do
sgorder.Rows[irow].Clear;
sgorder.Cells[0, iRow] := IntToStr(iRow);
end else
begin
ReadBill;
end;
zd:=false;
InitialStrGrid(sgorder,'配送退货单');
CdsMasterData.Close;
CdsMasterData.Data :=null;
temp:= 'Select * from SendMasterTable where 1=2';
CdsMasterData.Data:=adisp.PubBatch(temp);
CdsMasterData.Open;
temp:='Select * from SendDetailTable where 1=2';
CdsDetailData.Close;
CdsDetailData.Data:=null;
CdsDetailData.Data:=adisp.PubBatch(temp);
CdsDetailData.Open;
end;
function TfmUnPosSendBill.CheckData: Boolean;
var
iRow: Integer;
begin
//
Result := False;
SendMaster.vcExplain := EdtMemo.Text;
SendMaster.BillNo := EdtBillNo.Text;
if Trim(SendMaster.BillNo) = '' then
begin
EdtBillNo.SetFocus;
Application.MessageBox('单据编号不能为空!', pchar(application.Title), MB_OK + MB_ICONinformation);
Exit;
end;
if (Trim(EdtsendStock.Text) = '') or
(SendMaster.vcSendStockID = '') then
begin
EdtSendStock.SetFocus;
Application.MessageBox('配送仓库不能为空!', pchar(application.Title), MB_OK + MB_ICONinformation);
Exit;
end;
if (Trim(EdtRecvStock.Text) = '') or
(SendMaster.vcRecvStockID = '') then
begin
EdtRecvStock.SetFocus;
Application.MessageBox('退货仓库不能为空!', pchar(application.Title), MB_OK + MB_ICONinformation);
Exit;
end;
if (Trim(EdtM.Text) = '') or
(SendMaster.vcListerId = '') then
begin
EdtM.SetFocus;
Application.MessageBox('制单人不能为空!', pchar(application.Title), MB_OK + MB_ICONinformation);
Exit;
end;
if (Trim(EdtG.Text) = '') or
(SendMaster.vcEId = '') then
begin
EdtG.SetFocus;
Application.MessageBox('经手人不能为空!', pchar(application.Title), MB_OK + MB_ICONinformation);
Exit;
end;
for iRow := 1 to sgorder.RowCount - 1 do
begin
if (sgorder.Cells[1, iRow] = '') or (sgorder.Cells[2, iRow] = '') then
begin
sgorder.SetFocus;
sgorder.Row := iRow;
sgorder.Col := 1;
Application.MessageBox('当前商品不能为空!', pchar(application.Title), MB_OK + MB_ICONinformation);
Exit;
end;
if Trim(sgorder.Cells[7, iRow]) = '' then sgorder.Cells[7, iRow] := '0';
if StrToFloat(sgorder.Cells[7, iRow]) = 0 then
begin
sgorder.SetFocus;
sgorder.Row := iRow;
sgorder.Col := 7;
Application.MessageBox('请输入配送数量!', pchar(application.Title), MB_OK + MB_ICONinformation);
Exit;
end;
if strtoint(trim(sgorder.Cells[7, iRow]))>strtoint(trim(sgorder.Cells[21, iRow])) then
begin
sgorder.SetFocus;
sgorder.Row := iRow;
sgorder.Col := 7;
Application.MessageBox(pchar('退货数量不得多于配送数量!'), pchar(application.Title), MB_OK + MB_ICONinformation);
Exit;
end;
sgorder.Cells[9, iRow] := FloatToStr(StrToFloat(sgorder.Cells[7, iRow]) * StrToFloat(Trim(sgorder.Cells[8, iRow])));
end;
Result := True;
end;
function TfmUnPosSendBill.SaveData: Boolean;
var
IRow: Integer;
fQty, fPrice, fTotal, dRate: Double;
PsRst, iunit,i: Integer;
iEditMode: Integer;
mdata,Ddata:olevariant;//主副表数据
begin
if ieditmode=1 then
begin
if not bedit then
begin
if trim(Handle_Man)<>trim(edtm.Text) then
begin
Application.MessageBox('不能修改数据!',pchar(application.Title),mb_iconinformation);
exit;
end;
end;
end;
SendMaster.dtDrawDate:=date;
for i:=1 to sgorder.RowCount-1 do
begin
SendMaster.nuTotalMoney:=SendMaster.nuTotalMoney+strtofloat(sgorder.cells[9,i]);
end;
Result := False;
if SEditMode = '' then
iEditMode := 0
else
iEditMode := 1;
try
CdsMasterData.EmptyDataSet;
CdsMasterData.Append;
CdsMasterData.FieldByName('vcSendBillId').AsString := SendMaster.vcSendBillId;
CdsMasterData.FieldByName('VcSourceId').AsString := SendMaster.VcSourceId;
CdsMasterData.FieldByName('vcSendStockID').AsString := SendMaster.vcSendStockID;
CdsMasterData.FieldByName('vcRecvStockID').AsString := SendMaster.vcRecvStockID;
CdsMasterData.FieldByName('vcEId').AsString := SendMaster.vcEId;
CdsMasterData.FieldByName('vcListerId').AsString := SendMaster.vcListerId;
CdsMasterData.FieldByName('vcAssessorId').AsString := SendMaster.vcEId;
CdsMasterData.FieldByName('vcOutHouseReadBillId').AsString := SendMaster.vcOutHouseReadBillId;
CdsMasterData.FieldByName('vcExplain').AsString := SendMaster.vcExplain;
CdsMasterData.FieldByName('BillStatus').Asinteger := SendMaster.BillStatus;
CdsMasterData.FieldByName('iBIlltype').Asinteger := SendMaster.iBIlltype;
CdsMasterData.FieldByName('inVoucherSign').Asinteger := SendMaster.inVoucherSign;
CdsMasterData.FieldByName('inIsReadSign').Asinteger := SendMaster.inIsReadSign;
CdsMasterData.FieldByName('SendStatus').Asinteger := SendMaster.SendStatus;
CdsMasterData.FieldByName('NSumQty').AsFloat := SendMaster.NSumQty;
CdsMasterData.FieldByName('nuCess').AsFloat := SendMaster.nuCess;
CdsMasterData.FieldByName('nuTax').AsFloat := SendMaster.nuTax;
CdsMasterData.FieldByName('nuIncTaxSum').AsFloat := SendMaster.nuIncTaxSum;
CdsMasterData.FieldByName('nuTotalMoney').AsFloat := SendMaster.nuTotalMoney;
CdsMasterData.FieldByName('nuUnTaxSum').AsFloat := SendMaster.nuUnTaxSum;
CdsMasterData.FieldByName('dtDrawDate').AsDateTime := SendMaster.dtDrawDate;
CdsMasterData.FieldByName('dtOutStockDate').AsDateTime := SendMaster.dtOutStockDate;
CdsMasterData.FieldByName('BillNo').AsString := SendMaster.BillNo;
CdsMasterData.FieldByName('ObjectID').asInteger := SendMaster.ObjectID;
CdsDetailData.EmptyDataSet;
for IRow := 1 to sgorder.RowCount - 1 do
begin
CdsDetailData.Append;
CdsDetailData.FieldByName('vcSendBillId').AsString := SendMaster.vcSendBillId;
CdsDetailData.FieldByName('ord').asInteger := IRow;
CdsDetailData.FieldByName('InOrderId').asInteger := IRow;
CdsDetailData.FieldByName('vcPtypeid').AsString := Trim(sgorder.cells[2, iRow]);
CdsDetailData.FieldByName('VcSendStockID').AsString := Trim(SendMaster.vcSendStockID);
CdsDetailData.FieldByName('VcRecvStockID').AsString := Trim(SendMaster.vcRecvStockID);
CdsDetailData.FieldByName('vcBatch').AsString := '';
CdsDetailData.FieldByName('vcGoodUnitId').AsString := Trim(sgorder.cells[6, iRow]);
dRate := StrToFloat(sgorder.Cells[16, iRow]);
iunit:=0;
if iunit = 1 then
begin
fQty := StrToFloat(Trim(sgorder.cells[7, iRow])) * dRate;
CdsDetailData.FieldByName('nuOutQuantity').asFloat := fQty;
fPrice := StrToFloat(Trim(sgorder.cells[8, iRow])) / dRate;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -