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

📄 unit_outstore.pas

📁 飞恒进销存(超市批发)管理系统V5.1(含源程序) 语言:Delphi 6/7 相关控件:FastReport 2.4以上, Ehlib 3.4以上 1.数据库为fhe2db_V51.da
💻 PAS
📖 第 1 页 / 共 3 页
字号:
  dbGridInBooks.refresh;

  edtBarcode1.text:='';
  edtInvoNo.setfocus;
end;

procedure TFormOutStore.DBBarcodeExit(Sender: TObject);
var
   seekValue,s,sNowQty:string;
   nSalePrice:real;
begin
     // barcode use chinese abstract
     seekValue:=DBBarCode.text;

     if Length(seekvalue)>DataPub.nSysLevel3 then
     with datamodule2.tableStore do
     begin
       if findkey([seekvalue]) then
       begin
            //set unit  string;
            stName.caption:=trim(fieldbyname('name').asstring)+'('+fieldbyname('units').asstring+')';

            //显示零数
            nNowQty1:=fieldbyname('Lastqty').asfloat;
            str(nNowQty1:8:0,sNowQty);
            stQty1.caption:=trim(sNowQty);
            //显示件数
            nNowQty:=fieldbyname('qty').asfloat;
            str(nNowQty:8:2,sNowQty);
            stQty.caption:=trim(sNowQty);

            rbnUnits.caption:=Fieldbyname('units').asstring;
            rbnUnit2.caption:=Fieldbyname('unit2').asstring;
            rbnUnit3.caption:=rbnUnits.caption+'/'+rbnUnit2.caption;
            stPerQty.caption:=rbnUnits.caption+'='+trim(Fieldbyname('Perqty').asstring)+rbnUnit2.caption;

            // 显示 售价/进价
            if datapub.bOutUnit2 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;

            //零售设置
            if not DataPub.bWholeSale  then
              nSalePrice:=FieldByName('Saleprice').asfloat;

            //for warehosue manage special
            if ( datapub.hotelspe < 10 ) then
               nSalePrice:=FieldByName('inprice').asfloat;

            //正大不显示进价
            if dataPub.hotelspe=ZhenDa then
              s:='0';

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

            dataModule2.outmp1.edit;

            //刚新加的条目、或编码已变,要设置各字段值,以及历史价格
            if (datamodule2.Outmp1['outQty']=0) or (datamodule2.Outmp1['Name']<>Fieldbyname('name').asstring) then
            begin
              datamodule2.Outmp1['Invono']:=myInvoNo;

              datamodule2.Outmp1['Name']:=Fieldbyname('name').asstring;
              if datapub.bOutUnit2 then
                datamodule2.Outmp1['units']:=Fieldbyname('unit2').asstring
              else
                datamodule2.Outmp1['units']:=Fieldbyname('units').asstring;

              //物品件数名称
              datamodule2.Outmp1['unit1']:=Fieldbyname('units').asstring;
              //物品零数名称
              datamodule2.Outmp1['unit2']:=Fieldbyname('unit2').asstring;
              datamodule2.Outmp1['outQty']:=1;
              datamodule2.Outmp1['perqty']:=Fieldbyname('Perqty').asfloat;
              datamodule2.Outmp1['cal_qty']:=1;

              //按条形码进行打印,而任采用自编码输入
              if dataPub.bPrintBarcode then
                datamodule2.Outmp1['barcode1']:=Fieldbyname('Barcode1').asstring;

              // get old price if have
              if length(myInvoNO)>2 then        // seek customer's bill
              begin
                if queryBill.active then queryBill.close;
                //分区价格
                if dataPub.bZone and (edtBarcode1.text<>'') then
                  queryBill.params[0].asstring:=edtbarcode1.text
                else
                  queryBill.params[0].asstring:=myInvoNo;
                queryBill.params[1].asstring:=seekvalue;
                queryBill.open;
                //对于不是自动更新客户价,无价时显示0
                if not querybill.eof then
                begin
                  nSalePrice:=querybill.fieldbyname('saleprice').asfloat;
                  if nSaleprice=0 then nSaleprice:=0.1;
                  datamodule2.Outmp1['oldPrice']:=nSalePrice;
                end else if not datapub.bPenStyle then nSalePrice:=0;
              end;//end of >2

              //set saleprice
              datamodule2.Outmp1['salePrice']:=nSaleprice;

            end; // end of outqty=0

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

            if stUnits.caption=rbnUnits.caption then rbnUnits.checked:=true
               else rbnUnit2.Checked:=true;
            if datamodule2.Outmp1['cal_qty']>1 then rbnUnit3.checked:=true;

            if (DataPub.bWholeSale)  and (DataPub.HotelSpe=YongShen) then
               datamodule2.Outmp1['memo1']:=FloatToStr(Fieldbyname('saleprice').asfloat);

            dbOutQty.setfocus;
            nNowQty:=Fieldbyname('qty').asinteger; //现有库存件数
       end
       else begin
            DBBarcode.setfocus;//编码可能错误,不可离开
            nNowQty:=0;
            end;
     end
     else begin  //对于短编码,名称为空,可以离开此焦点
       dataModule2.outmp1.edit;
       datamodule2.Outmp1['Name']:=''
     end;//end of if seekvalue>1

     if not cmdDelete.enabled then cmdDelete.enabled:=true;
     if not cmdConfirm.enabled then cmdConfirm.enabled:=true;

end;

procedure TFormOutStore.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  with dataModule2 do
  begin
   if Outmp1.state in [dsEdit,dsInsert] then
     if dataPub.nDatabaseTypetmp=DataAccess then
       outmp1.post
     else
       Outmp1.cancelUpdates;

     outmp1.close;
     tableStore.close;
  end;

  action:=caFree;
end;

procedure TFormOutStore.DBGrid1Click(Sender: TObject);
begin
//     DBBarcode.text:=DataPub.tablestore['codename'];
end;

procedure TFormOutStore.DBEdit1Click(Sender: TObject);
var
   seekvalue,sTmp:string;
   myKey:char;
   nTimes,nLevel:integer;
begin
  //left mouse click select a code
   sTmp:=trim(dbEdit1.text);
   nTimes:=pos(' ',sTmp);
   seekvalue:=copy(sTmp,1,nTimes-1);
   if length(seekvalue)>0 then
   begin
     sTmp:=dbBarcode.text;;
     if sTmp='' then
       if datamodule2.outmp1.fieldbyname('invono').asstring <='' then
          addempty;
     DataModule2.outmp1.edit;
     if ( dbGrid1.DataSource = datamodule2.dsKind) or (  dbGrid1.DataSource =DSStoreQ) then
       DataModule2.outmp1['barcode']:=seekvalue
     else   DataModule2.outmp1['barcode']:=sTmp+seekvalue;

     dbBarcode.setfocus;
   end;
{  seekvalue:=dbBarcode.text;
  //first press key
  if (seekvalue='') then
  begin
    dbGrid1.DataSource:=datamodule2.dsKind;
    dbGrid1.refresh;
     // for first sale,
    if datamodule2.outmp1.fieldbyname('invono').asstring <='' then
    addempty;
  end;

  nTimes:=length(seekvalue);
  if nTimes <= DataPub.nSysLevel3  then
  begin
    if dbGrid1.DataSource=datamodule2.dsKind then
    begin
      sTmp:=dataModule2.tblKinds.fieldbyname('type').asstring;
      nLevel:=dataPub.nSysLevel1;
      if nLevel>0 then //第一级长度>=2
      begin
        DataModule2.outmp1.edit;
        DataModule2.outmp1['barcode']:=seekvalue+copy(sTmp,1,nLevel);
      end;
      myKey:=sTmp[nLevel+1];
    end;

    if dbGrid1.DataSource=datamodule2.dstype then
    begin
      sTmp:=DataModule2.tbltype.fieldbyname('code1').asstring;
      nLevel:=dataPub.nSysLevel2-dataPub.nSysLevel1-1;
      if nLevel>0 then //第一级长度>=2
      begin
        DataModule2.outmp1.edit;
        DataModule2.outmp1['barcode']:=seekvalue+copy(sTmp,1,nLevel);
      end;
      myKey:=sTmp[nLevel+1];
    end;

    DbBarcodekeypress(sender,mykey);

    DataModule2.outmp1.edit;
    DataModule2.outmp1['barcode']:=DataModule2.outmp1.fieldbyname('barcode').asstring+mykey;
  end
  else
      with datamodule2 do
      begin
         outmp1.edit;
         outmp1['barcode']:=self.query1.fieldbyname('barcode').asstring;
         Outmp1['Name']:=self.query1.Fieldbyname('name').asstring;
         Outmp1['OutQty']:=0;
         dbBarcode.setfocus;
      end; //end of if nTime<2
  }
end;

procedure TFormOutStore.FormCreate(Sender: TObject);
var
   s:string;
begin
  DataPub.SetSize1(self,dbGridInBooks,0,1);
  DataPub.SetSize1(self,dbGridInBooks,1,1);
  DataPub.SetSize1(self,Bevel2,1,1);
  dbGridInBooks.Columns[1].width :=DataPub.SetSize2(self,dbGridInBooks.columns[1].width,1,2);
  if dataPub.hotelspe=ZhenDa then //编码加宽
  begin
    dbGridInBooks.Columns[0].width :=DataPub.SetSize2(self,dbGridInBooks.columns[6].width,1,2);
    Query1Barcode.DisplayWidth :=20;
    Query1Barcode.size :=20;
    stBarcode.Width :=stBarcode1.width+stBarcode.width;
    DbBarcode.Width :=stBarcode.width;
    stBarcode.left:=stBarcode1.Left;
    DbBarcode.left :=stBarcode.left;
    stBarcode1.visible:=false;
    edtBarcode1.visible:=false; end
  else
    dbGridInBooks.Columns[6].width :=DataPub.SetSize2(self,dbGridInBooks.columns[6].width,1,2);

  DataPub.SetSize1(self,cmdAdd,3,1);
  DataPub.SetSize1(self,Panel1,0,1);
  dbGrid1.Rowcount:=panel1.height div 24;

  edtInvoNo.text:='1';
  myName:='无';

  sDept:='';
  sSaler:='';
  sBuyer:='无';
  sWarehouseman:='';
  sOthers:='出仓';
  nNowQty:=0;
  nNowQty1:=0;
  MaskEdit1.text:=dateTostr(date);

  myInvoNo:=edtInvoNo.text;

  bError:=false; //未发生写入错误
  ErrorInvono:='';

  // get max outmp1 's id, not is 1
  nId:=dataModule2.GetMaxOutid;

  inc(nid);

  with Datamodule2 do
  begin
       if outmp1.active then
       begin
         if outmp1.state in [dsinsert,dsEdit] then
         begin
            outmp1.post;
            //outmp1.applyupdates;
         end;
         outmp1.close;
       end;
       outmp1.Open;
//       addempty;
       if not tableStore.active then tableStore.open;
   end;

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

  //many store
  if Query1.active then Query1.close;
  Query1.sql.clear;
  s:='select barcode,name,barcode1 from '+DataPub.sStorename+' where barcode like :barcode0 order by barcode';
  Query1.sql.add(s);

end;

procedure TFormOutStore.cmdDeleteClick(Sender: TObject);
begin
     Datamodule2.outmp1.delete;
     if dataModule2.Outmp1.recordCount<1 then
       begin
        cmdDelete.enabled:=false;
        cmdConfirm.enabled:=false;
        edtInvoNo.setfocus;
       end;
end;


procedure TFormOutStore.DBBarcodeEnter(Sender: TObject);
var
   seekvalue:string;
begin
     seekvalue:=dbBarcode.text;
     //first press key
     if (seekvalue='') then
     begin
        dbGrid1.DataSource:=datamodule2.dsKind;
        dbGrid1.refresh;
        // for first sale,
        if datamodule2.outmp1.fieldbyname('invono').asstring <='' then
           addempty;
     end;
end;


procedure TFormOutStore.FormActivate(Sender: TObject);
begin
     edtInvono.SetFocus ;
     with datamodule2.tblKinds do
     begin
          filter:='';
          filtered:=false;
          dbGrid1.DataSource:=datamodule2.dsKind;
          dbGrid1.refresh;
     end;
end;

procedure TFormOutStore.DBSalePriceKeyPress(Sender: TObject;
  var Key: Char);
begin
  if key=chr(13) then
  begin
    if dbSalePrice.text='0' then
       dbMemo1.setfocus
    else
       cmdAdd.SetFocus;
  end;
end;

procedure TFormOutStore.DBOutQtyKeyPress(Sender: TObject; var Key: Char);
begin
  if key=chr(13) then
    if datapub.hotelspe>10 then
    begin
     if rbnUnit2.checked then rbnUnit2.SetFocus else rbnUnits.setfocus
     end
    else cmdAdd.setfocus;
end;

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


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

procedure TFormOutStore.edtInvoNOExit(Sender: TObject);
begin
      dbGrid1.DataSource:=datamodule2.dsKind;
      with datamodule2.tblKinds do
      begin
          filter:='';
          filtered:=false;
      end;
      dbGrid1.refresh;

     if dataModule2.Outmp1.recordCount<1 then
       begin
        cmdDelete.enabled:=false;
        cmdConfirm.enabled:=false;
       end
     else
     with dataModule2 do
     begin
        cmdDelete.enabled:=true;
        cmdConfirm.enabled:=true;

       if dataPub.nDatabaseTypeTmp=DataAccess then

⌨️ 快捷键说明

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