📄 ustocktype.pas
字号:
with cdssort.IndexDefs.AddIndexDef do
begin
Fields := 'type'; //
Options := [];
end;
cdssort.IndexDefs.Update;
cdssort.Open;
Gridbase.Visible:=false;
dbgrid1.Visible:=true;
setdbgrid(dbgrid1,3);
end;
screen.Cursor := crdefault;
end;
procedure TFmStockType.FormShow(Sender: TObject);
var
t_sql:string;
datas:olevariant;
begin
inherited;
///////调类别
t_sql:='select * from [goods_type]';
GetDataToComBoX(cbtype,t_sql,'type');
cbtype.ItemIndex := -1;
///////////////////////////////
cmbmstorage.Items.Add('本仓库'+shopid);
////////////////是否为总仓库
t_sql:='select managerid from stock_manager where storageid='+''''+trim(shopid)+'''';
datas:= null;
ipubtemp.ty_query(t_sql,datas);
if varisnull(datas) then
begin
ps:=true;
end else
begin
ps:=false;
end;
///////////////////////////
if ps then
begin
t_sql:='select storage_no from [storage] where storage_type<>'+''''+'门店仓库'+''''+' and storage_no<>'+''''+trim(shopid)+'''';
cdspart.Close;
cdspart.Data:=null;
datas:=null;
ipubtemp.ty_query(t_sql,datas);
if not varisnull(datas) then
begin
cdspart.Data:=datas;
cdspart.Open;
datas:=null;
while not cdspart.Eof do
begin
cmbmstorage.Items.Add('配送仓库'+trim(cdspart.fieldbyname('storage_no').AsString));
cdspart.Next;
end;
cdspart.Close;
cdspart.Data:=null;
end;
end;
cmbmstorage.ItemIndex := 0;
cmbmstorageChange(cmbmstorage);
cmbmstorage.ItemIndex := -1;
////////////////////////////
dbgCur:=dbgrid1;
cmbtop.ItemIndex:=0;
tempsql:='select top '+trim(cmbtop.Text);
tables:=' max(id) as id ,sum(stock_amount) as stock_amount,type,brand,breed,storage_no,storage_name from vSelectGoods';
groups:=' group by type,brand,breed,storage_no,storage_name';
cdssort.Close;
cdssort.Data:=null;
Gridbase.FixedCols:=2;
end;
procedure TFmStockType.BitBtn2Click(Sender: TObject);
begin
inherited;
with TfmSetColumn.Create(Self) do
try
showmodal;
finally
free;
end;
if Gridbase.Visible then
inistringgrid(true);
end;
procedure TFmStockType.btnpagedownClick(Sender: TObject);
var
temp:widestring;
datas:oleVariant;
begin
inherited;
if not cdssort.Active then exit;
screen.Cursor := crhourglass;
cdssort.DisableControls;
try
temp:=tempsql+tables+tj+' and id>='+inttostr(LocalCount)+groups;
try
datas:=adisp.GetRecord(temp);
except
application.MessageBox('服务器发生故障!',pchar(application.Title),mb_iconwarning);
screen.Cursor := crdefault;
exit;
end;
if not varisnull(datas) then
begin
cdssort.Close;
cdssort.Open;
cdssort.AppendData(datas,true);
cdssort.Last;
LocalCount := GetKeyFieldValue('id',cdssort); //传入具体字段
////////////////////////////////
with cdssort.IndexDefs.AddIndexDef do
begin
Fields := 'type'; //
Options := [];
end;
cdssort.IndexDefs.Update;
cdssort.Open;
////////////////////////////////////// dmmain.cdsquery.Last;
//重新打开
cdssort.EnableControls;
setdbgrid(dbgrid1,3);
end else
begin
//不再有数据
cdssort.EnableControls; //ydy 必须要
btnpagedown.Enabled := false;
screen.Cursor := crdefault;
exit;
end;
except
end;
gridbase.Visible:=false;
dbgrid1.Visible:=true;
screen.Cursor := crdefault;
end;
procedure TFmStockType.N3Click(Sender: TObject);
begin
inherited;
dbgrid1.Visible:=true;
Gridbase.Visible:=false;
end;
procedure TFmStockType.N4Click(Sender: TObject);
begin
inherited;
if not cdssort.Active then
begin
application.MessageBox('请先查询数据!',pchar(application.Title),mb_iconinformation);
bitbtn1.SetFocus;
exit;
end;
dbgrid1.Visible:=false;
gridbase.FixedCols:=1;
Gridbase.Visible:=true;
inistringgrid(true);
end;
procedure TFmStockType.cmbmstorageChange(Sender: TObject);
var
t_sql:string;
datas:olevariant;
begin
inherited;
t_sql:='select storageid from stock_manager where managerid='+''''+trim(copy(trim(cmbmstorage.Text),pos('仓库',trim(cmbmstorage.Text))+4,length(trim(cmbmstorage.Text))))+'''';
GetDataToComBoX(cmbstorages,t_sql,'storageid');
cmbstorages.Items.Add('全部仓库');
cmbstorages.ItemIndex:=-1;
end;
procedure TFmStockType.ckbtypeClick(Sender: TObject);
begin
inherited;
ckbcmb(ckbtype,cbtype);
CBTypeChange(cbtype);
end;
procedure TFmStockType.ckbbrandClick(Sender: TObject);
begin
inherited;
ckbcmb(ckbbrand,cbbrand);
cbbrandchange(cbbrand);
end;
procedure TFmStockType.ckbbreedClick(Sender: TObject);
begin
inherited;
ckbcmb(ckbbreed,cbbreed);
end;
procedure TFmStockType.CbmstorageClick(Sender: TObject);
begin
inherited;
ckbcmb(cbmstorage,cmbmstorage);
end;
procedure TFmStockType.cbstoragesClick(Sender: TObject);
begin
inherited;
ckbcmb(cbstorages,cmbstorages);
end;
procedure TFmStockType.BitBtn3Click(Sender: TObject);
var
p:Tpoint;
begin
inherited;
GetCursorPos(P);
BitBtn3MouseDown(sender,mbLeft,[ssLeft],p.X,p.Y);
end;
procedure TFmStockType.BitBtn3MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
p:Tpoint;
begin
inherited;
GetCursorPos(P);
PopupMenu2.Popup(P.x,P.y);
end;
procedure TFmStockType.DBGrid1TitleClick(Column: TColumn);
begin
inherited;
if not cdssort.Active then exit;
if trim(column.Field.AsString)='' then exit;
sortgrid(column.Field.FieldName,cdssort,dbgrid1,column);
end;
procedure TFmStockType.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
inherited;
setdbgrid(dbgrid1,3);
end;
procedure TFmStockType.CBTypeChange(Sender: TObject);
var
t_sql:string;
begin
inherited;
if dmmain.cDSquery.Active then dmmain.cDSquery.Close;
//调品牌
t_sql:='select distinct brand from [goods_code] where type ='+''''+trim(cbtype.text)+'''';
GetDataToComBoX(cbBrand,t_sql,'brand');
cbBrand.ItemIndex := -1;
cbbreed.Clear;
end;
procedure TFmStockType.cbBrandChange(Sender: TObject);
var
t_sql:string;
begin
inherited;
//调品种
if dmmain.cDSquery.Active then dmmain.cDSquery.Close;
if cbtype.Text = '' then exit;
t_sql:='select distinct breed from [goods_code] where brand ='+''''+trim(cbbrand.text)+'''' +' and type =' +''''+trim(cbtype.text)+'''';
GetDataToComBoX(cbBreed,t_sql,'breed');
cbBreed.ItemIndex := -1;
end;
procedure TFmStockType.GridbaseDrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
var
s:string;
r:TRect;
begin
inherited ;
with Sender as Tstringgrid do
begin
if gdSelected in State then
Canvas.Brush.Color:= clTeal; //clyellow;//clRed;
Canvas.TextRect(Rect,Rect.Left,Rect.Top,' '+Cells[ACol,ARow]);
if gdFocused in State then
Canvas.DrawFocusRect(Rect);
end;
with Sender as Tstringgrid do
begin
Canvas.FillRect(Rect);
s:=Cells[ACol,ARow];
r:=Rect;
DrawText(Canvas.Handle,PChar(s),Length(s),r,DT_CENTER or DT_SINGLELINE or DT_VCENTER);
end;
end;
procedure TFmStockType.btnprintClick(Sender: TObject);
begin
inherited;
if trim(gridbase.Cells[1,gridbase.RowCount-1])<>'' then
begin
fastrepxf:=tfastrepxf.Create(self);
fastrepxf.filenames:='OrderGoods.ini';
//fastrepxf.RepSGrid.RangeEnd := reCount;
GetCopyGrid(fastrepxf.SGridData,gridbase);
fastrepxf.SGridData.Enabled:=true;
fastrepxf.ShowModal;
fastrepxf.Free;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -