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

📄 iinstore.pas

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

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Unitmb, Grids, DBGridEh, StdCtrls, Buttons, ComCtrls, ExtCtrls, ToolWin,
  Mask, DBCtrlsEh, DBLookupEh, Menus, ImgList,adodb,db, DBGrids, FR_Ctrls,
  DBCtrls, dbcgrids;

type
  TIInStoreForm = class(TmbForm)
    procedure previewClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure DBGrid1DblClick(Sender: TObject);
  private
    { Private declarations }
     procedure InitInfo;override;
     procedure InsertDetail;override;
     procedure InsertMaster(sInvono:string);override;
     procedure UpdateMaster;override;
     procedure ShowMasterSpecial(bAdd:boolean);override;
  public
    { Public declarations }
  end;

var
  IInStoreForm: TIInStoreForm;

implementation

uses datamodule1, report2, selBill, SelectGoods;

{$R *.DFM}

procedure TIInStoreForm.InitInfo;
begin
  inherited;
  nStoreId:=-1;
end;

procedure TIInStoreForm.InsertMaster(sInvoNo:string);
begin
  with dataE2 do
    InsertIInstore(nTableId,nBillid,nCusid,nEmployid,nStoreid,edtBillDate.date,edtInvoNo.text,edtmemo.text);
end;

procedure TIInStoreForm.InsertDetail;
var
  sSql:string;
begin
  with dataE2 do
  begin
    if nTableId =1 then
      sSql:='( :billid, :itemno, :goodsid, :units, :qty, :price,0, :disc, :xBillId, :xItemNo,0, :memo1)'
    else
      sSql:='( :billid, :itemno, :goodsid, :units, :qty, :price,0, :disc, :xBillId, :xItemNo,0, :memo1, :cost)';
    adoCmd.commandtext:='insert into '+myTable+'D values '+sSql;
    adoCmd.parameters[0].value:=nBillId;
    adoCmd.parameters[1].value:=queryDetail.fieldbyname('itemno').asinteger;
    adoCmd.parameters[2].value:=nGoodsId;
    adoCmd.parameters[3].value:=queryDetail.fieldbyname('units').asstring;
    adoCmd.parameters[4].value:=nQty;
    adoCmd.parameters[5].value:=queryDetail.fieldbyname('price').ascurrency;
    adoCmd.parameters[6].value:=queryDetail.fieldbyname('disc').asboolean;// asinteger;
    adoCmd.parameters[7].value:=queryDetail.fieldbyname('xBillId').asinteger;
    adoCmd.parameters[8].value:=queryDetail.fieldbyname('xItemNo').asinteger;
    adoCmd.parameters[9].value:=queryDetail.fieldbyname('memo1').asstring;
    if nTableId = 11 then
       adoCmd.parameters[10].value:=queryDetail.fieldbyname('cost').ascurrency;
    adoCmd.execute;
    //update cusbill
    if (nTableId = 11) and (queryDetail.fieldbyname('price').ascurrency>0) then
      UpdateCusbill(nCusId,nGoodsId,queryDetail.fieldbyname('price').ascurrency,queryDetail.fieldbyname('disc').AsBoolean);
  end;
end;

procedure TIInStoreForm.UpdateMaster;
var
  sSql:string;
  i:integer;
begin
  sMasterMemo:=trim(edtMemo.text);

  //dynamic sql sentence
  i:=0;
  with dataE2 do
  begin
    adoCmd.CommandText:='update '+mytable+' set ';

    if  nEmployId <> nOldEmployId then
    begin
      adoCmd.CommandText :=adoCmd.CommandText +' Employid= :employid ';
      adoCmd.Parameters[i].value:=nEmployId;
      inc(i);
    end;

    if  nCusId <> nOldCusId then
    begin
      if i >0 then adoCmd.CommandText :=adoCmd.CommandText +',';

      if nTableid < 10 then
        adoCmd.CommandText :=adoCmd.CommandText +' vendorId= :cusid '
      else
        adoCmd.CommandText :=adoCmd.CommandText +' ClientId= :cusid ';
      adoCmd.Parameters[i].value:=nCusId;
      inc(i);
    end;

    if  nOldStoreId <> nStoreid then
    begin
      if i >0 then adoCmd.CommandText :=adoCmd.CommandText +',';

      adoCmd.CommandText :=adoCmd.CommandText +' Storeid= :stroeId ';
      adoCmd.Parameters[i].value:=nStoreId;
      inc(i);
    end;

    if  sMasterMemo <> sOldMasterMemo then
    begin
      if i >0 then adoCmd.CommandText :=adoCmd.CommandText +',';

      adoCmd.CommandText :=adoCmd.CommandText +' Memo= :Memo ';
      adoCmd.Parameters[i].value:=sMastermemo;
      inc(i);
    end;

    if i>0 then
    begin
      adoCmd.CommandText :=adoCmd.CommandText +' where BillId= :Billid ';
      adoCmd.parameters[i].value:=nBillid;
      adoCmd.Execute ;
    end;
  end; //dataE2
end;

procedure TIInStoreForm.previewClick(Sender: TObject);
begin
  inherited;
  //FormRpt1.Printporder(false);
end;

procedure TIInStoreForm.FormCreate(Sender: TObject);
begin
  inherited;
  if nTableid=11 then
  begin
    LblFormName.Caption :='出仓单';
    caption:=lblFormName.caption;
    lblName.caption:='客  户'
  end;
end;

procedure TIInStoreForm.ShowMasterSpecial(bAdd:boolean);
var
  s,sSql:string;
begin
  with DataE2 do
  if not bAdd then
  begin
    nStoreId:=adoquery1.fieldbyname('storeId').asinteger;
    nEmployId:=adoquery1.fieldbyname('EmployId').asinteger;
    sMasterMemo:=trim(adoquery1.fieldbyname('Memo').asstring);

    edtMemo.text:=sMastermemo;

    if nTableid=1 then
    begin
      nCusId:=adoquery1.fieldbyname('VendorId').asinteger;
      sSql:= 'select * from vendor where vendorId= :vendorid';
      if (adoquery1.fieldbyname('takeAmt').asfloat >0) or (adoquery1.fieldbyname('RtnAmt').asfloat >0) then
          cmdEdit.Enabled :=false
      else
          if not cmdEdit.enabled then cmdEdit.Enabled :=true;
      end
    else begin
      nCusId:=adoquery1.fieldbyname('ClientId').asinteger;
      sSql:= 'select * from client where clientId= :clientd';

      //非现款销售,已支付或退货单不可修改
      if (adoquery1.fieldbyname('RtnAmt').asfloat >0) or
        ((adoquery1.fieldbyname('takeAmt').asfloat >0) and   ( adoquery1.fieldbyname('SaleType').asinteger = 0)) then
          cmdEdit.Enabled :=false
      else
        if not cmdEdit.enabled then cmdEdit.Enabled :=true;
    end;

    s:='';
    if tblStore.Locate('storeid',nstoreId,[loPartialKey])
      then s:=tblStore.fieldbyname('name').asstring;
    edtStore.text:=s;

    s:='';
    if OpenTable('select * from employ where EmployId= :employid',nEmployid) then
      s:=adoquery1.fieldbyname('name').asstring;

    edtEmp.text:=s;
    adoQuery1.close;

    s:='';
    if OpenTable(sSql,nCusid) then
      s:=adoquery1.fieldbyname('ShortName').asstring;

    edtName.text:=s;
    adoQuery1.close;

  end
  else begin  //add emptye record,so clear last infomation,set to default
    edtEmp.Text:='';

    s:='';
    nStoreId:=1;
    if tblStore.Locate('storeid',nstoreId,[loPartialKey])
      then s:=tblStore.fieldbyname('name').asstring;
    edtStore.text:=s;

    s:='';
    nEmployId:=1;
    if OpenTable('select * from employ where EmployId= :employid',nEmployid) then
      s:=adoquery1.fieldbyname('name').asstring;

    edtEmp.text:=s;
    adoQuery1.close;
  end;

end;

procedure TIInStoreForm.DBGrid1DblClick(Sender: TObject);
begin
  inherited;
  if cmdSave.Enabled then
  begin
    if SelectGoodsForm.NewStatus='O' then
    if nCusid=-1 then
    begin
      Application.MessageBox('请选择客户!','提示',64);
      exit;
    end
    else SelectGoodsForm.NewCusId:=nCusId;
    if (dbGrid1.selectedindex = 0) and (dbGrid1.columns[0].FieldName='code')  then
      SelectGoodsForm.ShowModal;
  end;
end;

end.

⌨️ 快捷键说明

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