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

📄 drepair.pas

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

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
  TDRepairForm = class(TmbForm)
    lblReceiver: TLabel;
    edtReceiver: TfrComboEdit;
    lblproblem: TLabel;
    edtDetection: TEdit;
    edtproblem: TEdit;
    lblRunKM: TLabel;
    edtRunKM: TEdit;
    Label1: TLabel;
    edtRPType: TfrComboEdit;
    procedure previewClick(Sender: TObject);
    procedure DBGrid1DblClick(Sender: TObject);
    procedure cmdEditClick(Sender: TObject);
  private
    { Private declarations }
     nOldRunKM,nRunKM:real;
     sOldProblem,sProblem,sOldDetection,sDetection,sOldRPType,sOldReceiver:String;
     procedure InitInfo;override;
     procedure InsertDetail;override;
     procedure InsertMaster(sInvono:string);override;
     procedure UpdateMaster;override;
     procedure ShowMasterSpecial(bAdd:boolean);override;
  public
    { Public declarations }
  end;

var
  DRepairForm: TDRepairForm;

implementation

uses datamodule1, report2, selBill, SelectGoods;

{$R *.DFM}

procedure TDRepairForm.InitInfo;
begin
  inherited;
  nStoreId:=-1;
  nCusfileid:=0;
end;

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

procedure TDRepairForm.InsertDetail;
var
  sSql:string;
begin
  with dataE2 do
  begin
    sSql:='( :billid, :itemno, :goodsid, :units, :qty, :price, :disc, :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('memo1').asstring;
    adoCmd.parameters[8].value:=queryDetail.fieldbyname('cost').ascurrency;
    adoCmd.execute;
  end;
end;

procedure TDRepairForm.UpdateMaster;
var
  sSql:string;
  i:integer;
begin
  sMasterMemo:=trim(edtMemo.text);
  sProblem:=Trim(edtproblem.Text);
  sDetection:=Trim(edtDetection.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 +' cusFileid= :cusFileid ';
      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  nOldRunKM <> StrToFloat(edtRunKM.Text) then
    begin
      if i >0 then adoCmd.CommandText :=adoCmd.CommandText +',';

      adoCmd.CommandText :=adoCmd.CommandText +' RunKM= :RunKM ';
      adoCmd.Parameters[i].value:=StrToFloat(edtRunKM.Text);
      inc(i);
    end;

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

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

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

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

    if  sOldRPType <> Trim(edtRPType.Text)  then
    begin
      if i >0 then adoCmd.CommandText :=adoCmd.CommandText +',';

      adoCmd.CommandText :=adoCmd.CommandText +' RPType= :RPType ';
      adoCmd.Parameters[i].value:=Trim(edtRPType.Text);
      inc(i);
    end;

    if  sOldReceiver <> Trim(edtReceiver.Text)  then
    begin
      if i >0 then adoCmd.CommandText :=adoCmd.CommandText +',';

      adoCmd.CommandText :=adoCmd.CommandText +' Receiver= :Receiver ';
      adoCmd.Parameters[i].value:=Trim(edtReceiver.Text);
      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 TDRepairForm.previewClick(Sender: TObject);
begin
  inherited;
  //FormRpt1.Printporder(false);
end;

procedure TDRepairForm.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);
    nRunKM:=adoquery1.fieldbyname('RunKM').AsFloat;
    sProblem:=trim(adoquery1.fieldbyname('Problem').asstring);
    sDetection:=trim(adoquery1.fieldbyname('Detection').asstring);

    edtMemo.text:=sMastermemo;
    edtRunKM.Text:=FloatToStr(nRunKM);
    edtproblem.Text:=sProblem;
    edtDetection.Text:=sDetection;
    edtRPType.Text:=trim(adoquery1.fieldbyname('RPType').asstring);
    edtReceiver.Text:=trim(adoquery1.fieldbyname('Receiver').asstring);

    nCusId:=adoquery1.fieldbyname('Cusfileid').asinteger;
    sSql:= 'select * from cusFile where cusFileid= :cusFileid';

    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('CheckNo').asstring;

    edtName.text:=s;
    adoQuery1.close;

  end
  else begin  //add emptye record,so clear last infomation,set to default
    edtRunKm.Text:='';
    edtProblem.text:='';
    edtDetection.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 TDRepairForm.DBGrid1DblClick(Sender: TObject);
begin
  inherited;
  if cmdSave.Enabled then
    if (dbGrid1.selectedindex = 0) and (dbGrid1.columns[0].FieldName='code')  then
      SelectGoodsForm.ShowModal;
end;

procedure TDRepairForm.cmdEditClick(Sender: TObject);
begin
  inherited;
  nOldRunKM:=nRunKM;
  sOldProblem:=sProblem;
  sOldDetection:=sDetection;
  sOldRPType:=edtRPType.Text;
  sOldReceiver:=edtReceiver.text;
end;

end.

⌨️ 快捷键说明

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