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

📄 iogas.pas

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

interface

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

type
  TIOGasForm = class(TmbForm)
    empTrans: TfrComboEdit;
    Label1: TLabel;
    Label2: TLabel;
    empRec: TfrComboEdit;
    Label3: TLabel;
    empCount: TfrComboEdit;
    empClientOpr: TEdit;
  private
    { Private declarations }
     nEmpCount,nEmpRec,nEmpTrans:integer;
     nOldEmpCount,nOldEmpRec,nOldEmpTrans:integer;  //未修改前的值
     procedure InitInfo;override;
     procedure InsertDetail;override;
     procedure InsertMaster(sInvono:string);override;
     procedure UpdateMaster;override;
     procedure ShowMasterSpecial(bAdd:boolean);override;
  public
    { Public declarations }
  end;

var
  IOGasForm: TIOGasForm;

implementation

uses datamodule1;

{$R *.dfm}
procedure TIOGasForm.InitInfo;
begin
  inherited;
  nStoreId:=-1;
end;

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

procedure TIOGasForm.InsertDetail;
var
  sSql:string;
begin
  with dataE2 do
  begin
    sSql:='( :billid, :itemno, :goodsid, :units, :qtySelf, :qtyTest, :qtyChgValve, :QtyChgKey, :qtyBads, :QtyPaint, :qtyClean, :QtyVacuum, ';
    sSql:=sSql+' :qtySelfOut, :QtyOut, :QtyBadsOut, :price,0, :disc,0,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:=queryDetail.fieldbyname('qtySelf').asinteger;
    adoCmd.parameters[5].value:=queryDetail.fieldbyname('qtytest').asinteger;
    adoCmd.parameters[6].value:=queryDetail.fieldbyname('qtyChgValve').asinteger;
    adoCmd.parameters[7].value:=queryDetail.fieldbyname('qtyChgKey').asinteger;
    adoCmd.parameters[8].value:=queryDetail.fieldbyname('qtyBads').asinteger;
    adoCmd.parameters[9].value:=queryDetail.fieldbyname('qtyPaint').asinteger;
    adoCmd.parameters[10].value:=queryDetail.fieldbyname('qtyClean').asinteger;
    adoCmd.parameters[11].value:=queryDetail.fieldbyname('qtyVacuum').asinteger;
    adoCmd.parameters[12].value:=queryDetail.fieldbyname('qtySelfOut').asinteger;
    adoCmd.parameters[13].value:=queryDetail.fieldbyname('qty').asinteger;
    adoCmd.parameters[14].value:=queryDetail.fieldbyname('qtyBadsOut').asinteger;
    adoCmd.parameters[15].value:=queryDetail.fieldbyname('price').ascurrency;
    adoCmd.parameters[16].value:=queryDetail.fieldbyname('disc').asboolean;// asinteger;
    adoCmd.parameters[17].value:=queryDetail.fieldbyname('memo1').asstring;
    adoCmd.parameters[18].value:=queryDetail.fieldbyname('cost').ascurrency;

    adoCmd.execute;
    //update cusbill
  end;
end;

procedure TIOGasForm.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 +',';

      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 TIOGasForm.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;

    nCusId:=adoquery1.fieldbyname('ClientId').asinteger;
    sSql:= 'select * from client where clientId= :clientd';

    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;

end.

⌨️ 快捷键说明

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