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

📄 checkinfounit.pas

📁 仓库管理系统 貌似是ACCESS的数据库
💻 PAS
字号:
unit CheckInfoUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, Buttons, ToolWin, ComCtrls, Grids, DBGrids, StdCtrls,
  Mask, DBCtrls;

type
  TfrmCheckInfo = class(TForm)
    ControlBar1: TControlBar;
    CoolBar2: TCoolBar;
    sbtnFirst: TSpeedButton;
    sbtnPrior: TSpeedButton;
    sbtnNext: TSpeedButton;
    sbtnLast: TSpeedButton;
    Panel2: TPanel;
    Label4: TLabel;
    Label3: TLabel;
    Bevel2: TBevel;
    Label7: TLabel;
    Label8: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    dbGrdWarehouse: TDBGrid;
    Label6: TLabel;
    Label5: TLabel;
    Label2: TLabel;
    Label9: TLabel;
    Label14: TLabel;
    Label19: TLabel;
    SaveBtn: TBitBtn;
    CloseBtn: TBitBtn;
    edtWareDate: TEdit;
    edtWareName: TEdit;
    edtMaterialModel: TEdit;
    edtMaterialUnit: TEdit;
    edt_MaterialName: TEdit;
    edtMaterialType: TEdit;
    edt_MaterialID: TEdit;
    edtMaterialSpecs: TEdit;
    edtAccountNum: TEdit;
    edtAccountPrice: TEdit;
    edtAccountMoney: TEdit;
    edtFactNum: TEdit;
    edtFactPrice: TEdit;
    edtFactMoney: TEdit;
    edtLoseSpillNum: TEdit;
    edtLoseSpillPrice: TEdit;
    edtLoseSpillMoney: TEdit;
    procedure sbtnFirstClick(Sender: TObject);
    procedure sbtnPriorClick(Sender: TObject);
    procedure sbtnNextClick(Sender: TObject);
    procedure sbtnLastClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure dbGrdWarehouseCellClick(Column: TColumn);
    procedure edtFactNumKeyPress(Sender: TObject; var Key: Char);
    procedure SaveBtnClick(Sender: TObject);
  private
    str_sql:string;
    procedure SaveCheckInfo(var WarehouseName,MaterialID,MaterialName,
      MaterialModel,MaterialSpecs,MaterialUnit,MaterialType,AccountNum,AccountPrice,
      AccountMoney,FactNum,FactPrice,FactMoney,LoseSpillNum,LoseSpillPrice,LoseSpillMoney: string);
    procedure updateWarehouse(var WarehouseName,MaterialName,MaterialType,MaterialUnit,MaterialNum,MaterialPrice,MaterialMoney:String);
  public
    { Public declarations }
  end;

var
  frmCheckInfo: TfrmCheckInfo;

implementation

uses DM_Unit;

{$R *.dfm}

procedure TfrmCheckInfo.sbtnFirstClick(Sender: TObject);
begin
  DM.DataSetFirst(DM.sdsWare);
end;

procedure TfrmCheckInfo.sbtnPriorClick(Sender: TObject);
begin
  DM.DataSetPrior(DM.sdsWare);
end;

procedure TfrmCheckInfo.sbtnNextClick(Sender: TObject);
begin
  DM.DataSetNext(DM.sdsWare);
end;

procedure TfrmCheckInfo.sbtnLastClick(Sender: TObject);
begin
  DM.DataSetLast(DM.sdsWare);
end;

procedure TfrmCheckInfo.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  DM.sdsWare.Close;
end;

procedure TfrmCheckInfo.FormCreate(Sender: TObject);
begin
  DM.sdsWare.Open;
end;

procedure TfrmCheckInfo.dbGrdWarehouseCellClick(Column: TColumn);
begin
  if DM.sdsWare.RecordCount<>0 then
  begin
    edtWareDate.Text := formatdatetime('yyyy-mm-dd',now);
    edtWareName.Text := DM.sdsWare.FieldByName('WarehouseName').AsString;
    edt_MaterialID.Text := DM.sdsWare.FieldByName('MaterialID').AsString;
    edt_MaterialName.Text := DM.sdsWare.FieldByName('MaterialName').AsString;
    edtMaterialModel.Text := DM.sdsWare.FieldByName('MaterialModel').AsString;
    edtMaterialSpecs.Text := DM.sdsWare.FieldByName('MaterialSpecs').AsString;
    edtMaterialType.Text := DM.sdsWare.FieldByName('MaterialType').AsString;
    edtMaterialUnit.Text := DM.sdsWare.FieldByName('MaterialUnit').AsString;
    edtAccountNum.Text := DM.sdsWare.FieldByName('MaterialNum').AsString;
    edtAccountPrice.Text := DM.sdsWare.FieldByName('MaterialPrice').AsString;
    edtAccountMoney.Text := DM.sdsWare.FieldByName('MaterialMoney').AsString;
    edtFactNum.Text := DM.sdsWare.FieldByName('MaterialNum').AsString;
    edtFactPrice.Text := DM.sdsWare.FieldByName('MaterialPrice').AsString;
    edtFactMoney.Text := DM.sdsWare.FieldByName('MaterialMoney').AsString;
  end;
end;

procedure TfrmCheckInfo.edtFactNumKeyPress(Sender: TObject; var Key: Char);
var
  Money,Num: Integer;
begin
  if edtAccountNum.Text='' then Exit;
  if edtFactNum.Text='' then Exit;
  if edtFactPrice.Text='' then Exit;
  Num  := StrToInt(edtFactNum.Text) - StrToInt(edtAccountNum.Text);
  Money :=Num * StrToInt(edtFactPrice.Text);
  edtLoseSpillNum.Text := IntToStr(Num);
  edtLoseSpillPrice.Text := edtFactPrice.Text;
  edtLoseSpillMoney.Text := IntToStr(Money);
end;

procedure TfrmCheckInfo.SaveCheckInfo(var WarehouseName, MaterialID,
  MaterialName, MaterialModel, MaterialSpecs,MaterialUnit, MaterialType,
   AccountNum, AccountPrice, AccountMoney, FactNum, FactPrice,FactMoney,
   LoseSpillNum, LoseSpillPrice, LoseSpillMoney: string);
var
  InNO,CheckID: string;
begin
  try
    DM.OfferTypeID('select CheckID from wms_CheckInfo where CheckID like'+
      #39+'KC'+formatdatetime('yyyymmdd',now)+'%'+#39,InNo);
    CheckID := 'RK'+formatdatetime('yyyymmdd',now)+'000'+InNo;
    str_sql := 'insert into wms_CheckInfo (CheckID,CheckDate,WarehouseName,'+
      'MaterialID,MaterialName,MaterialModel,MaterialSpecs,MaterialUnit,MaterialType,'+
      'AccountNum,AccountPrice,AccountMoney,FactNum,FactPrice,FactMoney,LoseSpillNum,'+
      'LoseSpillPrice,LoseSpillMoney) values('+
    #39+CheckID+#39+','+#39+formatdatetime('yyyy-mm-dd',now)+#39+','+#39+WarehouseName+#39+','+
    #39+MaterialID+#39+','+#39+MaterialName+#39+','+#39+MaterialModel+#39+','+#39+
    MaterialSpecs+#39+','+#39+MaterialUnit+#39+','+ #39+MaterialType+#39+
    ','+AccountNum+','+AccountPrice+','+AccountMoney+','+FactNum+','+
    FactPrice+','+FactMoney+','+LoseSpillNum+','+LoseSpillPrice+','+LoseSpillMoney+')';
    DM.sdsCheckInfo.Close;
    DM.sdsCheckInfo.DataSet.CommandText :=  str_sql;
    DM.sdsCheckInfo.Execute;
  except
  on e : exception do
  begin
    Application.MessageBox(pchar('错误:数据写入数据库失败.错误代码:' + e.Message),
                         '连接错误',MB_OK+MB_ICONWARNING);
    abort;
  end;

  end;
end;

procedure TfrmCheckInfo.SaveBtnClick(Sender: TObject);
var
  AWarehouseName, AMaterialID,
  AMaterialName, AMaterialModel, AMaterialSpecs,AMaterialUnit, AMaterialType,
  AAccountNum, AAccountPrice, AAccountMoney, AFactNum, AFactPrice,AFactMoney,
  ALoseSpillNum, ALoseSpillPrice, ALoseSpillMoney: string;
begin
  AWarehouseName := edtWareName.Text;
  AMaterialID  := edt_MaterialID.Text;
  AMaterialName := edt_MaterialName.Text;
  AMaterialModel := edtMaterialModel.Text;
  AMaterialSpecs := edtMaterialSpecs.Text;
  AMaterialUnit := edtMaterialUnit.Text;
  AMaterialType := edtMaterialType.Text;
  AAccountNum   := edtAccountNum.Text;
  AAccountPrice := edtAccountPrice.Text;
  AAccountMoney := edtAccountMoney.Text;
  AFactNum := edtFactNum.Text;
  AFactPrice := edtFactPrice.Text;
  AFactMoney := edtFactMoney.Text;
  ALoseSpillNum := edtLoseSpillNum.Text;
  ALoseSpillPrice := edtLoseSpillPrice.Text;
  ALoseSpillMoney := edtLoseSpillMoney.Text;
  SaveCheckInfo(AWarehouseName, AMaterialID,
  AMaterialName, AMaterialModel, AMaterialSpecs,AMaterialUnit, AMaterialType,
  AAccountNum, AAccountPrice, AAccountMoney, AFactNum, AFactPrice,AFactMoney,
  ALoseSpillNum, ALoseSpillPrice, ALoseSpillMoney);

  updateWarehouse(AWarehouseName, AMaterialName,AMaterialType,
  AMaterialUnit, ALoseSpillNum, ALoseSpillPrice, ALoseSpillMoney);
  Application.MessageBox('系统信息:数据保存成功:',
                         '系统信息',MB_OK+MB_ICONWARNING);
end;

procedure TfrmCheckInfo.updateWarehouse(var WarehouseName, MaterialName,MaterialType,
  MaterialUnit, MaterialNum, MaterialPrice, MaterialMoney: String);
var
  Money:Integer;
begin
  try
    Money :=StrToInt(MaterialNum) * StrToInt(MaterialPrice);
    str_sql := 'update wms_warehouse set MaterialUnit='+#39+MaterialUnit+#39+',MaterialPrice='+MaterialPrice+
                   ',MaterialMoney= MaterialMoney +'+ IntToStr(Money) + ',MaterialNum=MaterialNum + ' +MaterialNum+
                   ' where MaterialName='+#39+MaterialName+#39+' and WarehouseName='+#39+WarehouseName+#39+
                   ' and MaterialType='+#39+MaterialType+#39;
    DM.sdsCheckInfo.Close;
    DM.sdsCheckInfo.DataSet.CommandText :=  str_sql;
    DM.sdsCheckInfo.Execute;
  except
  on e : Exception do
  begin
    Application.MessageBox(pchar('错误:数据写入数据库失败.错误代码:' + e.Message),
                         '连接错误',MB_OK+MB_ICONWARNING);
    abort;
  end;
  end;
end;

end.

⌨️ 快捷键说明

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