📄 urefund.pas
字号:
unit Urefund;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, Buttons, Grids, ComCtrls, StdCtrls, ExtCtrls, dxCntner,
dxEditor, dxExEdtr, dxEdLib, DB, ADODB, RpCon, RpConDS, RpDefine, RpRave;
type
Tfrmrefund = class(TForm)
Panel2: TPanel;
Label3: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Edit2: TEdit;
ComboBox2: TComboBox;
DTPicker3: TDateTimePicker;
ComboBox3: TComboBox;
Edit3: TEdit;
Edit4: TEdit;
Panel3: TPanel;
StringGrid1: TStringGrid;
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Label4: TLabel;
SpeedButton1: TSpeedButton;
Label10: TLabel;
Edit1: TEdit;
DTPicker1: TDateTimePicker;
DTPicker2: TDateTimePicker;
ComboBox1: TComboBox;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
SpeedButton2: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
SpeedButton7: TSpeedButton;
SpeedButton9: TSpeedButton;
StringGrid2: TStringGrid;
ADOQuery1: TADOQuery;
ADOQuery2: TADOQuery;
ADOQuery3: TADOQuery;
dxButtonEdit1: TdxButtonEdit;
RvProject1: TRvProject;
refundConnection1: TRvDataSetConnection;
refundConnection2: TRvDataSetConnection;
procedure FormCreate(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
procedure SpeedButton6Click(Sender: TObject);
procedure SpeedButton9Click(Sender: TObject);
procedure StringGrid1Click(Sender: TObject);
procedure StringGrid2SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
procedure StringGrid2KeyPress(Sender: TObject; var Key: Char);
procedure StringGrid2KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure StringGrid2Exit(Sender: TObject);
procedure dxButtonEdit1ButtonClick(Sender: TObject;
AbsoluteIndex: Integer);
procedure dxButtonEdit1Exit(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure SpeedButton7Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmrefund: Tfrmrefund;
implementation
uses Udatamodule, Ufilprod;
{$R *.dfm}
procedure Tfrmrefund.FormCreate(Sender: TObject);
var
i,arow:integer;
begin
stringgrid1.Cells[1,0]:='单据编号';
stringgrid1.Cells[2,0]:='供应商';
stringgrid1.Cells[3,0]:='退货日期';
stringgrid2.Cells[1,0]:='商品编号';
stringgrid2.Cells[2,0]:='商品名称';
stringgrid2.Cells[3,0]:='商品数量';
stringgrid2.Cells[4,0]:='商品进价';
stringgrid2.Cells[5,0]:='商品总价';
dtpicker1.Date:=date-7;
dtpicker2.Date:=date;
dtpicker3.Date:=date;
adoquery1.SQL.Text:='select provid,provname from provinfo';
adoquery1.Open;
while not adoquery1.Eof do
begin
combobox1.Items.Add(adoquery1.FieldValues['provid']+' '+adoquery1.FieldValues['provname']);
combobox2.Items.Add(adoquery1.FieldValues['provid']+' '+adoquery1.FieldValues['provname']);
adoquery1.Next;
end;
adoquery1.Close;
adoquery1.SQL.Text:='select filname from filiale';
adoquery1.Open;
while not adoquery1.Eof do
begin
combobox3.Items.Add(adoquery1.FieldValues['filname']);
adoquery1.Next;
end;
adoquery1.Close;
adoquery1.SQL.Text:='select * from refund ';
adoquery1.Open;
if adoquery1.RecordCount > 0 then
begin
edit2.Text:=adoquery1.FieldValues['refid'];
edit3.Text:=adoquery1.FieldValues['handleman'];
edit4.Text:=adoquery1.FieldValues['accounts'];
dtpicker3.Date:=adoquery1.FieldValues['refudate'];
for i:=0 to combobox2.Items.Count-1 do
if copy(combobox2.Items.Strings[i],1,5) = adoquery1.FieldByName('provid').AsString then
begin
combobox2.ItemIndex:=i;
break;
end;
adoquery2.SQL.Text:='select filname from filiale where filid = '''+adoquery1.FieldValues['filid']+'''';
adoquery2.Open;
for i:=0 to combobox3.Items.Count-1 do
begin
if combobox3.Items.Strings[i] = adoquery2.FieldByName('filname').AsString then
begin
combobox3.ItemIndex:=i;
break;
end;
end;
stringgrid1.RowCount:=adoquery1.RecordCount+1;
arow:=1;
while not adoquery1.Eof do
begin
stringgrid1.Cells[1,arow]:=adoquery1.FieldValues['refid'];
stringgrid1.Cells[2,arow]:=adoquery1.FieldValues['provid'];
stringgrid1.Cells[3,arow]:=adoquery1.FieldValues['refudate'];
adoquery1.Next;
inc(arow);
end;
adoquery1.Close;
stringgrid1.Cols[0].Clear;
stringgrid1.Cells[0,1]:='*';
adoquery1.SQL.Text:='select refund1.refid,pluinfo.prname,refund1.refunum,'+
' refund1.refuprice from refund1 inner join pluinfo on refund1.prid = pluinfo.prid'+
' where refid = '''+edit2.Text+'''';
adoquery1.Open;
if adoquery1.RecordCount > 0 then
begin
stringgrid2.RowCount:=adoquery1.RecordCount+1;
for i:=1 to stringgrid2.RowCount-1 do
begin
stringgrid2.Cells[1,i]:=adoquery1.FieldValues['refid'];
stringgrid2.Cells[2,i]:=adoquery1.FieldValues['prname'];
stringgrid2.Cells[3,i]:=adoquery1.FieldValues['refunum'];
stringgrid2.Cells[4,i]:=adoquery1.FieldValues['refuprice'];
stringgrid2.Cells[5,i]:=floattostr(strtofloat(stringgrid2.Cells[3,i])*strtofloat(stringgrid2.Cells[4,i]));
adoquery1.Next;
end;
end;
adoquery1.Close;
end;
end;
procedure Tfrmrefund.SpeedButton1Click(Sender: TObject);
var
i,arow:integer;
begin
for i:=1 to stringgrid1.RowCount-1 do
stringgrid1.Rows[i].Clear;
stringgrid1.RowCount:=2;
for i:=1 to stringgrid2.RowCount-1 do
stringgrid2.Rows[i].Clear;
stringgrid1.RowCount:=2;
adoquery1.SQL.Text:='select refid,provid,refudate,handleman,filid,accounts from refund where refudate between #'+datetostr(dtpicker1.date)+'# and #'+datetostr(dtpicker2.date)+'#';
if edit1.Text <> '' then
adoquery1.SQL.Add('and refid = '''+edit1.Text+'''');
if combobox1.Text <> '' then
adoquery1.SQL.add('and provid = '''+copy(combobox1.Text,1,5)+'''');
adoquery1.Open;
if adoquery1.RecordCount > 0 then
begin
edit2.Text:=adoquery1.FieldValues['refid'];
edit3.Text:=adoquery1.FieldValues['handleman'];
edit4.Text:=adoquery1.FieldValues['accounts'];
dtpicker3.Date:=adoquery1.FieldValues['refudate'];
for i:=0 to combobox2.Items.Count-1 do
if copy(combobox2.Items.Strings[i],1,5) = adoquery1.FieldByName('provid').AsString then
begin
combobox2.ItemIndex:=i;
break;
end;
adoquery2.SQL.Text:='select filname from filiale where filid = '''+adoquery1.FieldValues['filid']+'''';
adoquery2.Open;
for i:=0 to combobox3.Items.Count-1 do
begin
if combobox3.Items.Strings[i] = adoquery2.FieldByName('filname').AsString then
begin
combobox3.ItemIndex:=i;
break;
end;
end;
stringgrid1.RowCount:=adoquery1.RecordCount+1;
arow:=1;
while not adoquery1.Eof do
begin
stringgrid1.Cells[1,arow]:=adoquery1.FieldValues['refid'];
stringgrid1.Cells[2,arow]:=adoquery1.FieldValues['provid'];
stringgrid1.Cells[3,arow]:=adoquery1.FieldValues['refudate'];
adoquery1.Next;
inc(arow);
end;
adoquery1.Close;
stringgrid1.Cols[0].Clear;
stringgrid1.Cells[0,1]:='*';
adoquery1.SQL.Text:='select refund1.refid,pluinfo.prname,refund1.refunum,'+
' refund1.refuprice from refund1 inner join pluinfo on refund1.prid = pluinfo.prid'+
' where refid = '''+edit2.Text+'''';
adoquery1.Open;
if adoquery1.RecordCount > 0 then
begin
stringgrid2.RowCount:=adoquery1.RecordCount+1;
for i:=1 to stringgrid2.RowCount-1 do
begin
stringgrid2.Cells[1,i]:=adoquery1.FieldValues['refid'];
stringgrid2.Cells[2,i]:=adoquery1.FieldValues['prname'];
stringgrid2.Cells[3,i]:=adoquery1.FieldValues['refunum'];
stringgrid2.Cells[4,i]:=adoquery1.FieldValues['refuprice'];
stringgrid2.Cells[5,i]:=floattostr(strtofloat(stringgrid2.Cells[3,i])*strtofloat(stringgrid2.Cells[4,i]));
adoquery1.Next;
end;
end;
adoquery1.Close;
end
else begin
edit2.Text:='';
edit3.Text:='';
edit4.Text:='';
combobox2.ItemIndex:=-1;
combobox3.ItemIndex:=-1;
end;
end;
procedure Tfrmrefund.SpeedButton2Click(Sender: TObject);
var
ayear,amonth,adate:word;
smonth,sdate,maxid:string;
i:integer;
begin
dtpicker3.Date:=date;
combobox2.Enabled:=true;combobox2.ItemIndex:=-1;
combobox3.Enabled:=true;combobox3.ItemIndex:=-1;
edit3.Enabled:=true;edit3.Text:='';
edit4.Text:='';
dtpicker3.Enabled:=true;
edit1.Enabled:=false;
dtpicker1.Enabled:=false;
dtpicker2.Enabled:=false;
combobox1.Enabled:=false;
speedbutton1.Enabled:=false;
speedbutton2.Enabled:=false;
speedbutton5.Enabled:=true;
speedbutton6.Enabled:=true;
speedbutton7.Enabled:=false;
speedbutton9.Enabled:=false;
decodedate(date,ayear,amonth,adate);
smonth:=inttostr(amonth);sdate:=inttostr(adate);
if length(smonth) < 2 then smonth:= '0'+smonth;
if length(sdate) < 2 then sdate:='0'+sdate;
maxid:=inttostr(ayear)+smonth+sdate;
adoquery1.SQL.Text:='select max(refid) as maxid from refund where refid like '''+maxid+'%''';
adoquery1.Open;
if adoquery1.FieldValues['maxid'] = null then
edit2.Text:=maxid+'0001'
else
edit2.Text:=inttostr(strtoint64(adoquery1.FieldValues['maxid'])+1);
adoquery1.Close;
for i:=1 to stringgrid2.RowCount-1 do
stringgrid2.Rows[i].Clear;
stringgrid2.RowCount:=2;
stringgrid1.Cols[0].Clear;
end;
procedure Tfrmrefund.SpeedButton5Click(Sender: TObject);
var
i:integer;
sprovide,sfiliale:string;
totalacc:real;
begin
if edit2.Text = '' then
begin
showmessage('单据编号不能为空');
exit;
end;
if combobox2.Text = '' then
begin
showmessage('供应商不能为空!');
exit;
end;
if combobox3.Text = '' then
begin
showmessage('分店号不能为空');
exit;
end;
if edit3.Text = '' then
begin
showmessage('经手人不能为空');
exit;
end;
totalacc:=0;
for i:=1 to stringgrid2.RowCount-1 do
begin
if stringgrid2.Cells[1,i] = '' then
begin
showmessage('第'+inttostr(i)+'行商品编号不能为空');
exit;
end;
if stringgrid2.Cells[3,i] = '' then
begin
showmessage('第'+inttostr(i)+'行商品数量不能为空');
exit;
end;
if stringgrid2.Cells[4,i] = '' then
begin
showmessage('第'+inttostr(i)+'行商品进价不能为空');
exit;
end;
if stringgrid2.Cells[5,i] <> '' then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -