📄 unitmb.pas
字号:
exit;
end;//end of <>dskind
if (nTimes>0 ) and (nTimes < nSysLevel1) then
with dataE2.tblType do
begin
seekvalue1:=strTailInc(seekvalue);
filter:='[type]>='''+seekvalue+''''+' and [type]<'''+seekvalue1+'''';
filtered:=true;
//大类的第一个字符不匹配,不显示提示
bTips:=not dataE2.tblType.eof;
exit;
end;
//不提示,则退出
if not bTips then exit;
//enter level2
if (nTimes=nSysLevel1) then
begin
sType:=copy(seekvalue,1,nSysLevel1);
dbGoods.DataSource:=dataE2.dsType1;
with dataE2.tblType1 do
begin
filter:='[type]='''+sType+'''';
filtered:=true;
//大类的第后面字符不匹配,不显示提示
bTips:=not dataE2.tblType1.eof;
end;
//with dataE2.tblType do
// locate('type',seekvalue,sLocateOptions);
dbGoods.refresh;
exit;
end;
//if level2>=2 then filter
if (nTimes>nSysLevel1 ) and (nTimes<nSysLevel2) then
with dataE2.tblType1 do
begin
sType:=copy(seekvalue,1,nSysLevel1);
seekvalue:=copy(seekvalue,nSysLevel1+1,nSyslevel2-nSyslevel1);
seekvalue1:=strTailInc(seekvalue);
filter:='[type]='''+sType+''' and [code1]>='''+seekvalue+''''+' and [code1]<'''+seekvalue1+'''';
filtered:=true;
exit;
end;
//enter level3
if (nTimes=nSysLevel2) and (nSysLevel3>nSysLevel2) then
begin
sType:=copy(seekvalue,1,nSysLevel1);
sCode1:=copy(seekvalue,nSysLevel1+1,nSyslevel2-nSyslevel1);
dbGoods.DataSource:=dataE2.dsType2;
with dataE2.tblType2 do
begin
filter:='[type]='''+sType+''' and [code1]='''+sCode1+'''';
filtered:=true;
//locate('code1',seekvalue1,sLocateOptions);
end;
dbGoods.refresh;
exit;
end;
//if level2>=2 then filter
if (nTimes>nSysLevel2 ) and (nTimes<nSysLevel3) then
with dataE2.tblType2 do
begin
sType:=copy(seekvalue,1,nSysLevel1);
sCode1:=copy(seekvalue,nSysLevel1+1,nSyslevel2-nSyslevel1);
//seekvalue:=copy(seekvalue,nSysLevel1+1,nSyslevel2-nSyslevel1);
seekvalue1:=strTailInc(seekvalue);
filter:='[type]='''+sType+''' and [code1]='''+sCode1+''' and [code2]>='''+seekvalue+''' and [code2]<'''+seekvalue1+'''';
filtered:=true;
exit;
end;
if (nTimes>=nSysLevel3) then
begin
dbGoods.DataSource:=dsQGoods;
if nTimes=nSysLevel3 then
begin
queryGoods.filtered:=false;
queryGoods.parameters[0].value:=seekvalue+'%';
if queryGoods.active then queryGoods.close;
queryGoods.open;
end else
begin
s:=''; //2005-11-29 修正编码第三位是9的话,
i:=Length(seekvalue); //在编码提示框就不会显示的问题
if i > 1 then
s:=copy(seekvalue,i,1);
if s='9' then //判断最后一位是否为9
seekvalue1:='9'+LeftStr(seekvalue,i-2)
else
seekvalue1:=StrTailInc(seekvalue);
queryGoods.filter:='[code]>='''+seekvalue+''''+' and [code]<'''+seekvalue1+'''';
queryGoods.filtered:=true;
end;
dbGoods.refresh;
end;// end of fourth key
end; //selectedindex=0
end;
procedure TmbForm.DBGrid1ColEnter(Sender: TObject);
begin
if (dbGrid1.selectedindex = 0) and (dbGrid1.columns[0].FieldName='code') then
sOldCode:=dbGrid1.Columns[0].Field.asstring;
end;
procedure TmbForm.DBGrid1CellClick(Column: TColumnEh);
begin
{ if (dbGrid1.selectedindex = 0) and (dbGrid1.columns[0].FieldName='code') then
sOldCode:=dbGrid1.Columns[0].Field.asstring;
with dataE2 do
//if (dbGrid1.selectedindex = 3) and (dbGrid1.columns[3].FieldName='disc') then
begin
queryDetail.edit;
//if QueryDetail.FieldByName('disc').AsBoolean then //原是零数,click 是件数
if QueryDetail.FieldByName('units').AsString=sSchUnits then
begin
//queryDetail.FieldByName('units').asstring:=sSchUnits;
queryDetail.FieldByName('price').asfloat:=nSchPrice;
end else begin
//queryDetail.FieldByName('units').asstring:=sSchUnit2;
queryDetail.FieldByName('price').asfloat:=nSchPrice2;
end;
end; }
end;
procedure TmbForm.PrintClick(Sender: TObject);
begin
if dataE2.queryDetail.Active then
FormRpt1.Printreport(nTableId,true);
end;
procedure TmbForm.PreviewClick(Sender: TObject);
begin
if dataE2.queryDetail.Active then
FormRpt1.Printreport(nTableId,false);
end;
procedure TmbForm.cmdSearchClick(Sender: TObject);
begin
dlgSelBill1.xTableName :=myTable;
if dlgSelBill1.ShowModal=mrok then
with dataE2 do
if OpenTable('select * from '+myTable+' where billid= :billid',nBillid) then
begin
nBillId:=AdoQuery1.fieldbyname('billId').asinteger;
edtBillDate.date :=AdoQuery1.fieldbyname('billdate').asdatetime;
edtInvoNo.text :=AdoQuery1.fieldbyname('InvoNo').asstring;
ShowMasterSpecial(false);
//open detail
if queryDetail.active then queryDetail.close;
queryDetail.parameters[0].value:=nBillId;
queryDetail.open;
end;
end;
procedure TmbForm.DBGrid1Enter(Sender: TObject);
begin
// sOldCode:=DataE2.queryDetail.fieldbyname('code').asstring;
end;
procedure TmbForm.AddCalcField(ADOSet1: TADOQuery; sFieldName: string; sMode: Char =
'D');
var
NewField: TField;
i: integer;
begin
ADOSet1.Close;
for i := 0 to ADOSet1.Fields.Count - 1 do
ADOSet1.Fields[0].Free; //释放所有的静态字段
//open detail
adoSet1.parameters[0].value:=888888;
adoSet1.open;
adoSet1.close;
//根据FieldDefs的字段信息动态的生成静态字段
for i := 0 to ADOSet1.FieldDefs.Count - 1 do
ADOSet1.FieldDefs.Items[i].CreateField(ADOSet1);
case sMode of
'S': NewField := TStringField.Create(ADOSet1);
//创建一个TStringField类型的字段
'T': NewField := TDateTimeField.Create(ADOSet1);
'D', 'F': NewField := TFloatField.Create(ADOSet1);
'I': NewField := TIntegerField.Create(ADOSet1);
'M': NewField := TMemoField.Create(ADOSet1);
'C': NewField := TCurrencyField.Create(ADOSet1);
'V': NewField := TVariantField.Create(ADOSet1);
'O': NewField := TObjectField.Create(ADOSet1);
'B': NewField := TBooleanField.Create(ADOSet1);
else
Exit;
end;
//NewField.Size:=5;
NewField.FieldName := sFieldName;
NewField.FieldKind := fkCalculated; //设置这个这字段为计算字段
NewField.DataSet := ADOSet1; //把这个字段加到DataSet上
end;
procedure TmbForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
with dataE2 do
begin
if queryDetail.Active then
queryDetail.Close;
tblType.filter :='';
tblType.filtered :=false;
tblType1.filter :='';
tblType1.filtered :=false;
tblType2.filter :='';
tblType2.filtered :=false;
end;
end;
procedure TmbForm.dbGoodsCellClick(Column: TColumnEh);
begin
with dataE2 do
if (dbGrid1.selectedindex = 0) and (dbGrid1.columns[0].FieldName='code') and (dbGoods.DataSource=dsQGoods) then
begin
queryDetail.Edit;
queryDetail.FieldByName('code').value:=queryGoods.fieldbyname('code').asstring;
end;
end;
procedure TmbForm.SetDBComboBox;
begin
with dataE2.QueryTmp do
begin
close;
SQL.Clear;
SQL.Add('select * from Goods where code= :code or barcode= :barcode');
Parameters[0].Value:=dataE2.queryDetail.fieldbyname('code').asstring;
Parameters[1].Value:=dataE2.queryDetail.fieldbyname('code').asstring;
Prepared:=true;
open;
if not eof then
begin
iGoodsid:=fieldbyname('Goodsid').AsInteger;
nInprice:=fieldbyname('inprice').ascurrency;
nInprice2:=fieldbyname('inprice2').ascurrency;
sSchUnits:=fieldbyname('units').asstring;
sSchUnit2:=fieldbyname('unit2').asstring;
nSpePrice:=fieldbyname('SpePrice').ascurrency; //件
nSpePrice2:=fieldbyname('speprice2').ascurrency; //支
case nTableId of
0,1,2,21,24,25,26,27: begin
nSchPrice:=fieldbyname('inprice').ascurrency;
nSchPrice2:=fieldbyname('inprice2').ascurrency;
end;
10,11,12,18: begin
//if dataE2.bBatchSale then //批发
begin
nSchPrice:=fieldbyname('SpePrice').ascurrency; //件
nSchPrice2:=fieldbyname('speprice2').ascurrency; //支
nCost1:=fieldbyname('inprice').ascurrency;
nCost2:=fieldbyname('inprice2').ascurrency;//end
{else begin
nSchPrice:=fieldbyname('Saleprice').ascurrency;
nSchPrice2:=fieldbyname('saleprice2').ascurrency;
nCost1:=fieldbyname('inprice').ascurrency;
nCost2:=fieldbyname('inprice2').ascurrency;}
end;
end;
end; //end of case
end;
end;
end;
procedure TmbForm.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumnEh; State: TGridDrawState);
begin
//是否用双单位并且不是收付款单
if (dataE2.bTwoUnit) and (nTableId mod 10 <>3) and (cmdSave.Enabled)
and (dataE2.queryDetail.fieldbyname('Name').AsString<>'') then
begin
if (gdFocused in State) then
begin
if dbGrid1.selectedindex = 3 then
begin
DBComboBoxEh1.Left := Rect.Left + DBGrid1.Left;//+50;
DBComboBoxEh1.Top := Rect.Top + DBGrid1.top;
DBComboBoxEh1.Width := Rect.Right - Rect.Left;
DBComboBoxEh1.Height := Rect.Bottom - Rect.Top;
DBComboBoxEh1.Visible := True;
DBComboBoxEh1.SetFocus;
SetDBComboBox;
DBComboBoxEh1.Items.Clear;
DBComboBoxEh1.Items.add(sSchUnits);
DBComboBoxEh1.Items.add(sSchUnit2);
{if dataE2.bOutUnit2 and (nTableId=11) then //出仓零数价优先
DBComboBoxEh1.Text:=sSchUnit2
else
DBComboBoxEh1.Text:=sSchUnits
//DBComboBoxEh1.ReadOnly:=true;}
if dataE2.queryDetail.fieldbyname('disc').AsBoolean then
DBComboBoxEh1.itemindex:=1 //dataE2.queryDetail.fieldbyname('units').Asstring;//sSchUnit2
else
DBComboBoxEh1.itemindex:=0;//sSchUnits;
end;
end;
end;
if (gdFocused in State) then
if (dbGrid1.selectedindex = 0) and (cmdSave.Enabled) and dataE2.bTwoUnit then
if (nTableId in [0,1,2,10,11,12]) then
begin
SetDBComboBox;
GetStock(false);
stQty.Caption:=FloatToStr(rQty)+sSchUnits+' '+FloatToStr(rQty1)+sSchUnit2;
stInprice.Caption:=FloatToStr(nInprice)+'/'+sSchUnits+
' '+FloatToStr(nSpePrice)+'/'+sSchUnits;
end;
end;
procedure TmbForm.DBComboBoxEh1Change(Sender: TObject);
begin
if (DBComboBoxEh1.Items.Count>0) and (DBComboBoxEh1.ItemIndex<>-1) then
with dataE2 do
begin
if queryDetail.Active then
begin
queryDetail.Edit;
if DBComboBoxEh1.ItemIndex = 0 then
begin
QueryDetail.FieldByName('disc').AsBoolean:=false;
if nTableId <> 30 then
queryDetail.FieldByName('price').asfloat:=nSchPrice;
if ( nTableId=11 ) or ( nTableid= 12 ) or (nTableid=18) then
queryDetail.FieldByName('price').asfloat:=GetLastSalePrice(nCusId,iGoodsid,QueryDetail.FieldByName('disc').AsBoolean);
if ( nTableId=11 ) or ( nTableid= 12 ) or (nTableid=18) then
queryDetail.fieldbyname('cost').value:=nCost1;
queryDetail.FieldByName('units').AsString:=DBComboBoxEh1.Items[DBComboBoxEh1.ItemIndex];
if (nTableId in [0,1,2,10,11,12]) then
stInprice.Caption:=FloatToStr(nInprice)+'/'+sSchUnits+
' '+FloatToStr(nSpePrice)+'/'+sSchUnits end
else
if DBComboBoxEh1.ItemIndex = 1 then
begin
QueryDetail.FieldByName('disc').AsBoolean:=true;
if nTableId <> 30 then
queryDetail.FieldByName('price').asfloat:=nSchPrice2;
if ( nTableId=11 ) or ( nTableid= 12 ) or (nTableid=18) then
queryDetail.FieldByName('price').asfloat:=GetLastSalePrice(nCusId,iGoodsid,QueryDetail.FieldByName('disc').AsBoolean);
if ( nTableId=11 ) or ( nTableid= 12 ) or (nTableid=18) then
queryDetail.fieldbyname('cost').value:=nCost2;
queryDetail.FieldByName('units').AsString:=DBComboBoxEh1.Items[DBComboBoxEh1.ItemIndex];
if (nTableId in [0,1,2,10,11,12]) then
stInprice.Cap
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -