⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit_outstore.pas

📁 飞恒进销存(超市批发)管理系统V5.1(含源程序) 语言:Delphi 6/7 相关控件:FastReport 2.4以上, Ehlib 3.4以上 1.数据库为fhe2db_V51.da
💻 PAS
📖 第 1 页 / 共 3 页
字号:
       begin
         if outmp1.state in[ dsEdit,dsInsert] then outmp1.post end
       else
         outmp1.applyupdates;

       outmp1.close;
     end;


     myInvoNo:=edtInvoNo.text;
     inc(nId);

     //关闭编码动态查询结果集
     if query1.active then query1.close;

     with dataModule2.outmp1 do
     begin
          filter:='[InvoNo]='''+myInvono+'''';
          filtered:=true;
          open;
     end;
end;

procedure TFormOutStore.edtInvoNOKeyPress(Sender: TObject; var Key: Char);
begin
  if key=chr(13) then
    if edtbarcode1.visible then edtBarcode1.SetFocus else dbBarcode.SetFocus ;
end;

procedure TFormOutStore.edtBarcode1KeyPress(Sender: TObject;var Key: Char);
begin
  if key=chr(13) then
     dbBarcode.setfocus;
end;

procedure TFormOutStore.rbnUnit3KeyPress(Sender: TObject; var Key: Char);
begin
     if key=char(13) then dbSaleprice.setfocus;
end;

Function TFormOutStore.ChkNoStore:Boolean;
var
  nQty:real;
begin
  result:=true; //ok,有足够库存,或忽略错误
  if DataPub.bNoStore then
  begin
    with dataModule2.tableStore do
    begin
      nQty:=Fieldbyname('Perqty').asfloat;
      if rbnUnit2.checked then //零
        nQty:=Fieldbyname('Qty').asfloat*nQty+Fieldbyname('LastQty').asfloat
      else
        nQty:=Fieldbyname('Qty').asfloat;
    end;

    if dataModule2.ouTmp1.fieldbyname('outQty').asinteger>nQty then
    if dlgMessage.showmodal=mrCancel then
//    if application.messageBox('忽略错误,继续执行','库存缺货',MB_OKCANCEL)=ID_CANCEL then
    begin
      dataModule2.ouTmp1.edit;
      dataModule2.ouTmp1.fieldbyname('outQty').asinteger:=0;
      DBBarcode.setfocus;
      result:=false;
    end ;
  end;//end of chknowstre
end;

procedure TFormOutStore.Query1CalcFields(DataSet: TDataSet);
begin
     with query1 do
        FieldByName('codename').asstring:=' '+trim(FieldByName('barcode').asstring)+' '+trim(FieldByName('name').asstring);
end;

procedure TFormOutStore.gbxUnitExit(Sender: TObject);
var
   nPerqty:real;
   s:string;
begin
  //非仓库版,改销售价
  if datapub.hotelspe > 10 then
  begin
      dataModule2.outmp1.edit;
      datamodule2.Outmp1['cal_qty']:=1;
      with dataModule2.tableStore do
          nPerqty:=Fieldbyname('Perqty').asfloat;

      if rbnUnits.checked then
         datamodule2.Outmp1['Units']:=rbnUnits.caption;
      if rbnUnit2.checked then
         datamodule2.Outmp1['Units']:=rbnUnit2.caption;

      //datamodule2.Outmp1['Unit1']:=datamodule2.Outmp1['Units'];

      if rbnUnit3.checked then
      begin
        with dataModule2.tableStore do
             nPerqty:=Fieldbyname('Perqty').asfloat;
         datamodule2.Outmp1['units']:=rbnUnits.caption;
         //datamodule2.Outmp1['Unit1']:=rbnUnit2.caption;
         datamodule2.Outmp1['cal_qty']:=nPerQty;
      end;

      stUnits.caption:=datamodule2.Outmp1['Units'];

      //对于无历史价,改变售价,根据相应的单位
      ChgSalePrice;

      dbSalePrice.setfocus;
  end;
end;

procedure TFormOutStore.DBMemo1KeyPress(Sender: TObject; var Key: Char);
begin
     if key=chr(13) then  cmdAdd.SetFocus
end;

procedure TFormOutStore.Button1Click(Sender: TObject);
begin
  close;
end;

procedure TFormOutstore.addempty;
begin
  with dataModule2 do
  begin
    outmp1.append;
    inc(nId);
    //    if dataPub.hotelspe<>huanchen then
    if dataPub.nDatabaseTypeTmp<>DataAccess then
       Outmp1['Id']:=nId;;

    Outmp1['Invo']:=myInvoNo;
    Outmp1['seq']:=0;
    Outmp1['Invono']:=myInvoNo;
    outmp1['barcode']:='';
    outmp1['name']:='';
    outmp1['SalePrice']:=0;
    outmp1['OldPrice']:=0;
    outmp1['OutQty']:=0;
    outmp1['units']:='';
    outmp1['unit1']:='箱';
    outmp1['unit2']:='支';
    outmp1['perqty']:=1;
    outmp1['memo1']:='';
    outmp1['pro_date']:=date;
    outmp1['exp_date']:=date;
  end; //end of  datamodule2
end;

procedure TFormOutStore.ChgSaleprice ;
var
  nSalePrice:real;
  s:string;
begin
 // nSalePrice:=datamodule2.outmp1['oldprice'];

  with datamodule2.tablestore do
  begin
    if not rbnUnits.checked then //按零数单位
    begin
      str(FieldByName('InPrice2').ascurrency:8:2,s);
      if not DataPub.bWholeSale  then
         nSalePrice:=FieldByName('saleprice2').asfloat //零 零售
      else
         nSalePrice:=FieldByName('speprice2').asfloat  //零 批发
    end  else
    begin
      str(FieldByName('InPrice').ascurrency:8:2,s);
      if not DataPub.bWholeSale  then
         nSalePrice:=FieldByName('saleprice').asfloat //件 零售
      else
         nSalePrice:=FieldByName('specprice').asfloat  //件 批发
    end;
  end;

  stPrice.caption:=trim(s);
  str(nSalePrice:8:2,s);
  stPrice.caption:=stPrice.caption+'/'+trim(s);

  if (length(myInvoNO)<2) or (datamodule2.outmp1['oldprice']<=0) then
  begin
    datamodule2.outmp1.edit;
    datamodule2.outmp1['saleprice']:=nSalePrice;
  end;

end;
{
// update cusbill
          if (length(myInvoNO)>2)  and (length(seekvalue)>3) then
          begin
          with tblCusBill do
          begin
             if findkey([myInvoNo,seekvalue]) then
//             if locate('ID;Barcode',varArrayOf([myInvoNo,seekvalue]),options) then
             begin
//                nPrice:=FieldByname('salePrice').asfloat;
//                nPrice:=outmp1.FieldByname('salePrice').asfloat;
                if  FieldByname('salePrice').asfloat<>outmp1.FieldByname('salePrice').asfloat then
                begin
                 edit;
                 FieldByname('salePrice').asfloat:=outmp1.FieldByname('salePrice').asfloat;
                 //post;
                 end
             end
             else
             begin
                Append;
                FieldByName('ID').asstring:=myInvono;
                FieldByName('Barcode').asstring:=seekvalue;
                FieldByname('salePrice').asfloat:=outmp1.FieldByname('salePrice').asfloat;
                //post;
             end;
          end; // end of tableCusBill
          end;
}
{
procedure TFormOutStore.DBExp_dateExit(Sender: TObject);
var
   s:string;
begin
     if not queryExp.eof then
     begin
         s:=queryExp.fieldbyname('qtyNow').asstring+queryExp.fieldbyname('units').asstring;
         stQty1.caption:=s;
         stExp_date.caption:=dateTostr(queryExp.fieldbyname('pro_date').asdatetime)+' '+dateTostr(queryExp.fieldbyname('Exp_date').asdatetime);
         with datamodule2.outmp1 do
         begin
              edit;
              fieldbyname('invo').asstring:=queryExp.fieldbyname('invono').asstring;
              fieldbyname('seq').asinteger:=queryExp.fieldbyname('seq').asinteger;
         end;
     end else
     with datamodule2.outmp1 do
     begin
       edit;
       fieldbyname('exp_date').asdatetime:=date;
     end;
end;
}

procedure TFormOutStore.lblCompanyClick(Sender: TObject);
begin
     if FormShowCompany.showmodal=IDOK then
     begin
        edtInvoNo.text:=FormShowCompany.companyid;
        edtInvono.setfocus;
//        edtInvoNoExit(sender);
     end;
end;

procedure TFormOutStore.DBBarcodeChange(Sender: TObject);
var
  seekvalue,seekvalue1:string;
  sLocateOptions:TLocateOptions;
  nTimes,nKey:integer;
begin
  nTimes:=Length(dbBarcode.text);

  //空中回到主分类
  if nTimes=0 then
    if (dbGrid1.DataSource<>datamodule2.dsKind) or DataModule2.tblKinds.filtered  then
    begin
      with datamodule2.tblKinds do
      begin
        filter:='';
        filtered:=false;
        first;
      end;
      dbGrid1.DataSource:=datamodule2.dsKind;
      dbGrid1.refresh;
    end;//end of <>dskind

  if (nTimes>0 ) and (nTimes < DataPub.nSysLevel1) then
    with datamodule2.tblKinds do
    begin
      seekvalue:=copy(dbBarcode.text,nTimes,1);
      nKey:=ord(seekvalue[1])+1;
      seekvalue1:=char(nkey);
      filter:='[type]>='''+seekvalue+''''+' and [type]<'''+seekvalue1+'''';
      filtered:=true;
    end;

   //enter level2
   if (nTimes=DataPub.nSysLevel1) then
   begin
     dbGrid1.DataSource:=datamodule2.dsType;
     seekValue1:=dbBarcode.text;
     with datamodule2.tblType do
     begin
          filter:='';
          filtered:=false;
     end;
     with datamodule2.tblKinds do
          locate('type',seekvalue1,sLocateOptions);
     dbGrid1.refresh;
   end;

   //if level2>=2 then filter
   if (nTimes>DataPub.nSysLevel1 ) and (nTimes<DataPub.nSysLevel2) then
     with datamodule2.tblType do
     begin
       seekvalue:=copy(dbBarcode.text,nTimes,1);
       nKey:=ord(seekvalue[1])+1;
       seekvalue1:=char(nkey);
       filter:='[code1]>='''+seekvalue+''''+' and [code1]<'''+seekvalue1+'''';
       filtered:=true;
     end;

   //enter level3
   if (nTimes=DataPub.nSysLevel2) and (dataPub.nSysLevel3>dataPub.nSysLevel2) then
   begin
     seekvalue:=copy(dbBarcode.text,1,dataPub.nSysLevel1);
     seekvalue1:=copy(dbBarcode.text,dataPub.nSysLevel1+1,dataPub.nSyslevel2-dataPub.nSyslevel1);
     dbGrid1.DataSource:=datamodule2.dsType2;
     with datamodule2.tblType do
     begin
          filter:='';
          filtered:=false;
          locate('code1',seekvalue1,sLocateOptions);
     end;
     dbGrid1.refresh;
   end;

   // enter store level
   if (nTimes>=DataPub.nSysLevel3) then
   begin
     dbGrid1.DataSource:=dsStoreQ;
     seekvalue:=DBBarcode.text;
     if (nTimes=DataPub.nSysLevel3) or (not query1.active) then
     begin
       if query1.active then query1.close;
       query1.filtered:=false;
       seekvalue1:=trim(query1.sql.text) ;//sql未变,不必重新初始化
       if pos(':barcode0',seekvalue1) <= 0 then
       begin
         query1.sql.clear;
         seekvalue1:='select barcode,name,barcode1 from '+DataPub.sStorename+' where barcode like :barcode0 order by barcode';
         query1.sql.add(seekvalue1);
       end;
       query1.params[0].asstring:=seekvalue+'%';

       query1.open;
     end else
     begin
          nKey:=ord(seekvalue[nTimes])+1;
          seekvalue1:=copy(dbBarcode.text,1,nTimes-1)+char(nkey);
          query1.filter:='[barcode]>='''+seekvalue+''''+' and [barcode]<'''+seekvalue1+'''';
          query1.filtered:=true;
     end;
     dbGrid1.refresh;
   end;// end of fourth key

end;

procedure TFormOutStore.edtBarcode1Exit(Sender: TObject);
begin
  if datapub.bZone then
    edtBarcode1.text:=trim(Uppercase(edtbarcode1.text));
end;

procedure TFormOutStore.rbnUnit2Click(Sender: TObject);
begin
  if datapub.hotelspe > 10 then
    chgSalePrice;
end;

procedure TFormOutStore.DBOutQtyExit(Sender: TObject);
begin
  ChkNoStore
end;

procedure TFormOutStore.edtBarcode1Change(Sender: TObject);
var
  seekvalue,seekvalue1:string;
  nTimes:integer;
begin
   seekvalue:=uppercase(trim(edtBarcode1.text));
   nTimes:=Length(seekvalue);

   if (nTimes<1) or datapub.bZone then exit;

   // first press a PY code
   if (nTimes=1) then
   begin
     dbGrid1.DataSource:=dsStoreQ;
     if query1.active then query1.close;
     query1.filtered:=false;
     seekvalue1:=trim(query1.sql.text) ;//sql未变,不必重新初始化
     if pos(':barcode1',seekvalue1) <= 0 then
     begin
       query1.sql.clear;
       query1.sql.add('select barcode,barcode1,name from store where barcode1 like :barcode1 order by barcode1');
     end;
     query1.params[0].asstring:='%'+seekvalue+'%';
     query1.open;  end
   else   begin
     query1.filter:='';
     query1.filtered:=true;
   end;

   dbGrid1.refresh;
end;

procedure TFormOutStore.Query1FilterRecord(DataSet: TDataSet;
  var Accept: Boolean);
var
  sTmp:string;
begin
  //只对拼音等编码进行人工过滤
  if not dataPub.bZone and ( length(trim(edtBarcode1.text)) > 0 ) then
  begin
    sTmp:=dataSet.FieldByName('barcode1').asstring;
    if pos(uppercase(edtBarcode1.text),sTmp) >0 then Accept:=true
    else Accept:=false;
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -