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

📄 dinout.pas

📁 飞恒进销存,从盒子上下来的,不知这里有没有.
💻 PAS
字号:
unit DInOut;

interface

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

type
  TDInOutForm = class(TmbForm)
    Label1: TLabel;
    edtIOType: TfrComboEdit;
    edtInOut: TEdit;
    procedure edtIOTypeButtonClick(Sender: TObject);
    procedure cmdSaveClick(Sender: TObject);
    procedure cmdEditClick(Sender: TObject);
    procedure edtNameButtonClick(Sender: TObject);
    procedure DBGrid1DblClick(Sender: TObject);
  private
    { Private declarations }
    nIoTypeId,nOldIoTypeId: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
  DInOutForm: TDInOutForm;

implementation
uses datamodule1, selPaytype, SelectGoods;
{$R *.dfm}

procedure TDInOutForm.InitInfo;
begin
  inherited;
  nStoreId:=-1;
  //nCusid:=100;
end;

procedure TDInOutForm.InsertDetail;
var
  sSql:string;
begin
  with dataE2 do
  begin
    sSql:='( billid, itemno, GoodsId, units, price, qty, BackQty, Disc, memo1)';
    sSql:=sSql+' values ( :billid, :itemno, :GoodsId, :units, :price, :qty,0,0, :memo1)';
    adoCmd.commandtext:='insert into '+myTable+'D '+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('price').asCurrency;;
    adoCmd.parameters[5].value:=nQty;
    adoCmd.parameters[6].value:=queryDetail.fieldbyname('memo1').asstring;

    adoCmd.execute;
  end;
end;

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

procedure TDInOutForm.UpdateMaster;
var
  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 +' RSUnit= :RSUnit ';
      adoCmd.Parameters[i].value:=nCusId;
      inc(i);
    end;

    if  nStoreId <> nOldStoreid 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  nIoTypeId <> nOldIoTypeid then
    begin
      if i >0 then adoCmd.CommandText :=adoCmd.CommandText +',';

      adoCmd.CommandText :=adoCmd.CommandText +' Typeid= :TypeId ';
      adoCmd.Parameters[i].value:=nIoTypeId;
      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 TDInOutForm.ShowMasterSpecial(bAdd:boolean);
var
  s,sSql:string;
  i:integer;
begin
  with DataE2 do
  if not bAdd then
  begin
    nEmployId:=adoquery1.fieldbyname('EmployId').asinteger;
    nStoreId:=adoquery1.fieldbyname('storeId').asinteger;
    nIOTypeId:=adoquery1.fieldbyname('TypeId').asinteger;
    sMasterMemo:=trim(adoquery1.fieldbyname('Memo').asstring);
    edtMemo.text:=sMastermemo;
    nCusId:=adoquery1.fieldbyname('RSUnit').asinteger;

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

    edtEmp.Text:=s;

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

    //edtName.text:=s;

    s:='';
    if OpenTable('select Typeid as id,name,case when isIn=1 then '''+'进仓类'+ ''' else '''+'出仓类'+''' end as other from IoType '+' where TypeId= :Typeid',nIoTypeId) then
      s:=adoQuery1.fieldbyname('name').asstring;
    edtIoType.text:=s;
    if s<>'' then  edtInOut.text:=adoQuery1.fieldbyname('other').asstring;

    if edtInOut.text='进仓类' then
      sSql:= 'select * from vendor where vendorId= :vendorid'
    else if edtInOut.text='出仓类' then
      sSql:= 'select * from client where clientId= :clientd';

    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
    //edtStore.Text:='';
    //edtEmp.Text:='';
    //edtIoType.Text:='';
    edtMemo.text:='';
    edtInout.text:='';

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

    edtEmp.Text:=s;

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

    s:='';
    nIoTypeId:=1;    
    if OpenTable('select Typeid as id,name,case when isIn=1 then '''+'进仓类'+ ''' else '''+'出仓类'+''' end as other from IoType '+' where TypeId= :Typeid',nIoTypeId) then
      s:=adoQuery1.fieldbyname('name').asstring;
    edtIoType.text:=s;
    if s<>'' then  edtInOut.text:=adoQuery1.fieldbyname('other').asstring;

    adoQuery1.close;
  end;
end;

procedure TDInOutForm.edtIOTypeButtonClick(Sender: TObject);
begin
  inherited;
  if not cmdSave.Enabled then exit;

  dlgselPayType.Newsql:='select Typeid as id,name,case when isIn=1 then '''+'进仓类'+ ''' else '''+'出仓类'+''' end as other from IoType ';
  dlgSelpaytype.Top :=self.top+(sender as TComboBox).Top +81;//toolbar1.height+edtInstore.Height+20 ;
  dlgSelpaytype.Left :=self.Left+(sender as TComboBox).left+4 ;
  if dlgselPayType.showmodal=mrok then
  with dataE2 do
  begin
    (sender as TComboBox).Text :=dlgselPayType.xName;
    nIOTypeId:=dlgSelPaytype.xid;
    edtInout.text:=dlgSelPaytype.xOther;
  end;

end;

procedure TDInOutForm.cmdSaveClick(Sender: TObject);
begin
  //because business type may be changed,we can do only by this Id
  //Here,use Outstoreid,=0 In,=1 Out
  if edtInout.text='出仓类' then
  begin
    dataE2.gTableId:=26; //27
    nTableid:=26;        //27
    nOutStoreId:=1
  end
  else begin
    dataE2.gTableId:=26;
    nTableid:=26;
    nOutStoreId:=0;
  end;

  inherited;
end;

procedure TDInOutForm.cmdEditClick(Sender: TObject);
begin
  inherited;
  if edtInout.text='出仓类' then
    nOldOutStoreId:=1
  else
    nOldOutStoreId:=0;
end;

procedure TDInOutForm.edtNameButtonClick(Sender: TObject);
begin
  sInOut:=Trim(edtInOut.text);
  if edtInout.text='出仓类' then
    SelectGoodsForm.NewStatus:='O'
  else
    SelectGoodsForm.NewStatus:='I';
  inherited;
end;

procedure TDInOutForm.DBGrid1DblClick(Sender: TObject);
begin
  inherited;
  if cmdSave.Enabled then
  begin
    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 + -