📄 ustockin.pas
字号:
end;
end;
adoquery1.Close;
end;
end;
procedure Tfrmstockin.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
totalacc:=totalacc+strtofloat(stringgrid2.Cells[5,i]);
end;
if totalacc <> 0 then
edit4.Text:=floattostr(totalacc);
if edit4.Text = '' then
begin
showmessage('商品总进价不能为空');
exit;
end;
adoquery1.SQL.Text:='select stockid from stockin where stockid = '''+edit2.Text+'''';
adoquery1.Open;
if adoquery1.RecordCount > 0 then
begin
showmessage('单据编号重复');
exit;
end;
adoquery1.Close;
sprovide:=copy(combobox2.Text,1,5);
adoquery2.SQL.Text:='select filid from filiale where filname = '''+combobox3.Text+'''';
adoquery2.Open;
sfiliale:=adoquery2.Fields[0].AsString;
adoquery2.Close;
try
adoquery1.Connection.BeginTrans;
adoquery1.SQL.Text:='insert into stockin values("'+edit2.Text+'","'+sprovide+'",'
+'"'+datetostr(dtpicker3.Date)+'","'+edit3.Text+'","'+sfiliale+'","'+edit4.Text+'")';
adoquery2.Connection.BeginTrans;
for i:=1 to stringgrid2.RowCount-1 do
begin
adoquery2.SQL.Text:='insert into stockin1 values("'+edit2.Text+'","'+stringgrid2.Cells[1,i]+'",'
+'"'+stringgrid2.Cells[3,i]+'","'+stringgrid2.Cells[4,i]+'")';
adoquery2.ExecSQL;
adoquery3.SQL.Text:='select prid,busanum from busary where filid = '''
+sfiliale+''' and prid = '''+stringgrid2.Cells[1,i]+'''';
adoquery3.Open;
if adoquery3.RecordCount > 0 then
begin
adoquery3.Edit;
adoquery3.FieldByName('busanum').AsFloat:=adoquery3.FieldByName('busanum').AsFloat+strtofloat(stringgrid2.Cells[3,i]);
adoquery3.Post;
adoquery3.Close;
end
else begin
adoquery3.Close;
adoquery3.SQL.Text:='insert into busary (filid,prid,busanum) values'+
'("'+sfiliale+'","'+stringgrid2.Cells[1,i]+'",'+stringgrid2.Cells[3,i]+')';
adoquery3.ExecSQL;
adoquery3.Close;
end;
adoquery3.SQL.Text:='update pluinfo set newprice = '+stringgrid2.Cells[4,i]+' where prid = '''+stringgrid2.Cells[1,i]+'''';
adoquery3.ExecSQL;
adoquery3.Close;
end;
adoquery1.ExecSQL;
adoquery2.Connection.CommitTrans;
adoquery1.Connection.CommitTrans;
adoquery2.Close;
adoquery1.Close;
showmessage('保存成功!');
edit1.Enabled:=true;combobox1.Enabled:=true;
dtpicker1.Enabled:=true;dtpicker2.Enabled:=true;
edit2.Enabled:=false;
edit3.Enabled:=false;
combobox2.Enabled:=false;
combobox3.Enabled:=false;
dtpicker3.Enabled:=false;
speedbutton1.Enabled:=true;
speedbutton2.Enabled:=true;
speedbutton5.Enabled:=false;
speedbutton6.Enabled:=false;
speedbutton7.Enabled:=true;
speedbutton8.Enabled:=false;
speedbutton9.Enabled:=true;
except
adoquery2.Connection.RollbackTrans;
adoquery1.Connection.RollbackTrans;
adoquery2.Close;
adoquery1.Close;
end;
end;
procedure Tfrmstockin.SpeedButton6Click(Sender: TObject);
var
i:integer;
begin
edit1.Enabled:=true;
combobox1.Enabled:=true;
dtpicker1.Enabled:=true;
dtpicker2.Enabled:=true;
edit2.Enabled:=false; edit2.Text:='';
edit3.Enabled:=false; edit3.Text:='';
edit4.Text:='';
combobox2.Enabled:=false; combobox2.ItemIndex:=-1;
combobox3.Enabled:=false; combobox3.ItemIndex:=-1;
dtpicker3.Enabled:=false;
speedbutton1.Enabled:=true;
speedbutton2.Enabled:=true;
speedbutton5.Enabled:=false;
speedbutton6.Enabled:=false;
speedbutton7.Enabled:=true;
speedbutton8.Enabled:=false;
speedbutton9.Enabled:=true;
for i:=1 to stringgrid2.RowCount-1 do
stringgrid2.Rows[i].Clear;
stringgrid2.Options:=stringgrid2.Options-[goediting];
stringgrid2.RowCount:=2;
end;
procedure Tfrmstockin.StringGrid2SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
var
arect:trect;
begin
if speedbutton5.Enabled = true then
begin
if ((acol = 3) or (acol = 4)) then
stringgrid2.Options:=stringgrid2.Options+[goediting]
else
stringgrid2.Options:=stringgrid2.Options-[goediting];
if ((acol = 1) or (acol = 2)) then
begin
arect:=stringgrid2.CellRect(acol,arow);
arect.Left:=arect.Left+stringgrid2.Left;
arect.Top:=arect.Top+stringgrid2.Top;
dxbuttonedit1.Left:=arect.Left+1;
dxbuttonedit1.Top:=arect.Top+1;
dxbuttonedit1.Height:=stringgrid2.RowHeights[arow];
dxbuttonedit1.Width:=stringgrid2.ColWidths[acol]+1;
dxbuttonedit1.Visible:=true;
dxbuttonedit1.Text:=stringgrid2.Cells[acol,arow];
dxbuttonedit1.SetFocus;
end;
if arow <> stringgrid2.RowCount-1 then
if stringgrid2.Cells[1,stringgrid2.RowCount-1] = '' then
begin
stringgrid2.Rows[stringgrid2.RowCount-1].Clear;
if stringgrid2.RowCount > 2 then
stringgrid2.RowCount:=stringgrid2.RowCount-1;
end;
end;
end;
procedure Tfrmstockin.dxButtonEdit1Exit(Sender: TObject);
begin
dxbuttonedit1.Text:='';
dxbuttonedit1.Visible:=false;
end;
procedure Tfrmstockin.N1Click(Sender: TObject);
var
arow:integer;
begin
if speedbutton5.Enabled then
begin
arow:=stringgrid2.RowCount-1;
if stringgrid2.Cells[1,arow] <> '' then
stringgrid2.RowCount:=stringgrid2.RowCount+1;
end
else
showmessage('请先点击添加按钮');
end;
procedure Tfrmstockin.N2Click(Sender: TObject);
var
i:integer;
begin
if speedbutton5.Enabled then
begin
if stringgrid2.RowCount > 2 then
begin
for i:=stringgrid2.Row to stringgrid2.RowCount-2 do
stringgrid2.Rows[i]:=stringgrid2.Rows[i+1];
stringgrid2.rows[stringgrid2.RowCount-1].Clear;
stringgrid2.RowCount:=stringgrid2.RowCount-1;
end
else
stringgrid2.Rows[1].Clear;
end
else
showmessage('请先点击添加按钮');
end;
procedure Tfrmstockin.dxButtonEdit1ButtonClick(Sender: TObject;
AbsoluteIndex: Integer);
begin
application.CreateForm(tfrmfilprod,frmfilprod);
frmfilprod.whosel:='stockin';
frmfilprod.ShowModal;
frmfilprod.Release;
end;
procedure Tfrmstockin.SpeedButton9Click(Sender: TObject);
begin
self.Close;
end;
procedure Tfrmstockin.SpeedButton8Click(Sender: TObject);
begin
Application.CreateForm(Tfrmchobook, frmchobook);
frmchobook.ShowModal;
frmchobook.Release;
end;
procedure Tfrmstockin.StringGrid2KeyPress(Sender: TObject; var Key: Char);
var
i,pnum,acol:integer;
str:string;
begin
acol:=stringgrid2.Col;
if ((not (key in ['0'..'9'])) and (key <> '.') and (key <>#8 ) and (key <>#3)) then
begin
showmessage('请输入数字或小数点');
key:=chr(0);
end
else begin
str:=stringgrid2.Cells[acol,stringgrid2.Row];
pnum:=0;
for i:=1 to length(str) do
if str[i] = '.' then inc(pnum);
if ((pnum >0) and (key = '.')) then
key:=chr(0);
end;
end;
procedure Tfrmstockin.StringGrid2KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
acol,arow:integer;
begin
acol:=stringgrid2.Col; arow:=stringgrid2.row;
if (acol = 4) then
begin
if (stringgrid2.Cells[4,arow] <> '') then
begin
if stringgrid2.Cells[3,arow] = '' then
begin
showmessage('请输入商品数量');
stringgrid2.Cells[4,arow]:= '';
stringgrid2.col:=3;
exit;
end
else
stringgrid2.Cells[5,arow]:=floattostr(strtofloat(stringgrid2.Cells[3,arow]) * strtofloat(stringgrid2.Cells[4,arow]));
end
else
stringgrid2.Cells[5,arow]:='';
end;
if ((acol = 3) and (stringgrid2.Cells[4,arow] <> '')) then
begin
stringgrid2.Cells[5,arow]:=floattostr(strtofloat(stringgrid2.Cells[3,arow]) * strtofloat(stringgrid2.Cells[4,arow]));
end;
end;
procedure Tfrmstockin.StringGrid2Exit(Sender: TObject);
var
totalacc:real;
i:integer;
begin
totalacc:=0;
for i:=1 to stringgrid2.RowCount-1 do
if stringgrid2.Cells[5,i] <> '' then
totalacc:=totalacc+strtofloat(stringgrid2.Cells[5,i]);
if totalacc <> 0 then
edit4.Text:=floattostr(totalacc);
end;
procedure Tfrmstockin.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
if not speedbutton9.Enabled then
begin
canclose:=false;
showmessage('请先保存数据然后退出');
end;
end;
procedure Tfrmstockin.SpeedButton7Click(Sender: TObject);
begin
if stringgrid2.cells[1,1]<>'' then
begin
adoquery1.SQL.Text:='select stockin1.prid,pluinfo.prname,stockin1.stocknum,'
+'stockin1.stoprice from stockin1 inner join pluinfo on stockin1.prid = '
+'pluinfo.prid where stockin1.stockid = '''+edit2.Text+'''';
adoquery2.SQL.Text:='select stockin.stockid,stockin.stockdate,stockin.handleman,'
+'filiale.filname,provinfo.provname from (stockin inner join filiale on '
+'stockin.filid = filiale.filid) inner join provinfo on stockin.provid = '
+'provinfo.provid where stockin.stockid = '''+edit2.Text+'''';
rvproject1.Execute;
rvproject1.Close;
end
else
showmessage('请先查询要打印的数据!');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -