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

📄 u_function.pas

📁 这是一个用条码录入的数据的进销存(只对成品)---做童装的
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{-----------------------------------------------------------------------------
   ProjectName:   琪比小美屋产品进销存
   --------------------------------
   描      述:
   Unit Name:     U_Function
   Author:        Luky_99
   Date:          07-07-2004
   Purpose:
   History:

  版权所有 (C) 2003-2004 源丰科技  Luky_99
-----------------------------------------------------------------------------}


unit U_Function;

interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, adodb, inifiles, WinSkinData;

const
  Version = '1.0';
  CopyRight = '启明科技有限公司 版权所有 (V1.0)';
  Email = 'huangxiaomin163@163.net';
  Tel = '13059507498';
  TheOwer = 'Jason';

type
  TCompanry = record
    ZH_Companryname: string;
    EN_Companryname: string;
    CompanryNo: string;
    Reginfo: string;
    Projectname: string;
  end;

type
  Titem = record
    ITemNO: string;
    ItemName: string;
    HandCount: integer;
    Price: Real;
  end;

type
  TGroup = record
    Groupno: string;
    Groupname: string;
  end;

type
  TCustomer = record
    Custno: string;
    Custname: string;
    MaxNo: integer;
    Areano: string;
    Areaname: string;
    Shopname: string;
    Address: string;
    Tel: string;
    Fax: string;
    Email: string;
    Contactman: string;
    Zkrate: Real;
  end;
type
  TProduct = record
    NF: string;
    JDNo: string;
    JDname: string;
    Groupno: string;
    Groupname: string;
    ItemNo: string;
    ItemName: string;
    Brandno: string;
    Brandname: string;
    Custno: string;
    Custname: string;
    Handcount: integer;
    Price: Real;
  end;

type
  Tjd = record
    jdno: string;
    JDname: string;
  end;

type
  TBrand = record
    brandNO: string;
    BrandName: string;
  end;
var
  TheCompanry: TCompanry;
  userid, Username, Userpower: string;

  DbUserid, Dbpassword, Dbname, Dbserver, CurComputername: string;
  Activedbname, Oldname: string;
  ActiveConnect: TadoConnection;
  CurReportTitle: string;
  ISConnected: Boolean;

  TheCustomer: TCustomer;
  TheItem: TItem;
  TheGroup: TGroup;
  Theproduct: TProduct;
  TheJD: TJD;
  TheBrand: TBrand;

function Connectdb(var AdoCon: Tadoconnection; Adbname: string): Boolean;
procedure Readfromini(var Aserver, Aname, Auserid, Apassword: string);
procedure WriteToIni(const aServerName, aDatabaseName, aUserName, aPassword: string);
procedure DBConnectExecute(aClass: TForm);
procedure Opensql(query: Tadoquery; Vsql: string);
function Execsql(Vsql: string): boolean;

function GetCurrComputername(): string;
procedure GetCompanryName(var Acompanry: TCompanry);

function loginsys(AUserid, password: string): boolean;
procedure Addoperatlog(AFormName, Aoperate: string);
function ParentDir(ChildDir: string): string;
function myTrim(const Str: string): string;

function GetIteminfo(const ATM: string; var AItem: TItem): boolean;
function GetGroupinfo(const ATM: string; var AGroup: TGroup): Boolean;
function GetCustinfo(const ATM: string; var ACustomer: TCustomer; custno: string = ''): Boolean;

function CreateBillNo(const Flag: string): string;
function GetProductinfo(const ProductTM: string; var AProduct: TProduct): Boolean;
function getJDinfo(const ATM: string; var Ajd: TJD): boolean;
function GetBrandinfo(const Atm: string; var ABrand: TBrand): Boolean;

function GetiteminfoA(const Aitemno: string; var Theitem: TItem): Boolean;
//Function GetgroupinfoA(Const AGroupno

implementation

function GetiteminfoA(const Aitemno: string; var Theitem: TItem): Boolean;
var Tempquery: Tadoquery;
  TempStr: string;
begin
Result:=False;
  Tempquery := TAdoquery.Create(nil);
  Tempquery.Connection := ActiveConnect;
  with Tempquery do
  begin
    Close;
    Sql.text := 'Select * from Iitem where itemno=''' + Aitemno + '''';
    open;
    if RecordCount = 1 then
    begin
    Theitem.ITemNO:=Trim(Fieldbyname('Itemno').AsString);
    Theitem.ItemName:=Trim(Fieldbyname('Itemname').AsString);
    Theitem.HandCount:=Fieldbyname('HandCount').AsInteger;
    Theitem.Price:=Fieldbyname('HandCount').AsFloat;
    Result:=True;
    end
    else
    Begin
    Theitem.ITemNO:='';
    Theitem.ItemName:='';
    Theitem.HandCount:=0;
    Theitem.Price:=0;
    end;
  end;
end;

function GetBrandinfo(const Atm: string; var ABrand: TBrand): Boolean;
var Tempquery: Tadoquery;
  TempStr: string;
begin
  Result := False;
  TempStr := Copy(Atm, 6, 1);
  Tempquery := TAdoquery.Create(nil);
  Tempquery.Connection := ActiveConnect;
  with Tempquery do
  begin
    try
      opensql(Tempquery, 'Select * from IBrand where Brandno=''' + Tempstr + '''');
      if Tempquery.RecordCount = 1 then
      begin
        ABrand.brandNO := Fieldbyname('Brandno').AsString;
        ABrand.BrandName := Fieldbyname('Brandname').AsString;
        Result := True;
      end
      else
      begin
        ABrand.brandNO := '';
        ABrand.BrandName := '';
      end;
    finally
      Close;
      free;
    end;
  end;
end;

function getJDinfo(const ATM: string; var Ajd: TJD): boolean;
var Tempquery: Tadoquery;
  TempStr: string;
begin
  Result := False;
  TempStr := Copy(Atm, 2, 1);
  Tempquery := TAdoquery.Create(nil);
  Tempquery.Connection := ActiveConnect;
  with Tempquery do
  begin
    try
      opensql(Tempquery, 'Select * from IJD where JDNO=''' + Tempstr + '''');
      if Tempquery.RecordCount = 1 then
      begin
        Ajd.jdno := Fieldbyname('JDNO').AsString;
        Ajd.JDname := Fieldbyname('JDNAme').AsString;
        Result := True;
      end
      else
      begin
        Ajd.jdno := '';
        Ajd.JDname := '';
      end;
    finally
      Close;
      free;
    end;
  end;
end;


function GetProductinfo(const ProductTM: string; var AProduct: TProduct): Boolean;
begin
  Result := False;
  case strtoint(Copy(ProductTm, 1, 1)) of
    4: AProduct.NF := '2004';
    5: AProduct.NF := '2005';
    6: AProduct.NF := '2006';
    7: AProduct.NF := '2007';
    8: AProduct.NF := '2008';
    9: AProduct.NF := '2009';
    0: AProduct.NF := '2010';
    1: AProduct.NF := '2011';
    2: AProduct.NF := '2012';
    3: AProduct.NF := '2013';
  end;
  //季度
  Getjdinfo(ProductTM, thejd);
  AProduct.JDNo := Thejd.jdno;
  AProduct.JDname := Thejd.JDname;
  // 组别
  Getgroupinfo(ProductTM, TheGroup);
  AProduct.Groupno := TheGroup.Groupno;
  AProduct.Groupname := TheGroup.Groupname;
  //款式
  Getiteminfo(ProductTM, theitem);
  AProduct.ItemNo := Theitem.ItemNo;
  AProduct.ItemName := Theitem.ItemName;
  AProduct.Handcount := theitem.HandCount;
  AProduct.Price := Theitem.Price;
  //客户
  GetCustinfo(Producttm, thecustomer);
  Aproduct.Custno := Thecustomer.Custno;
  Aproduct.Custname := Thecustomer.Custname;
  //品牌
  Getbrandinfo(ProductTM, Thebrand);
  Aproduct.Brandno := TheBrand.brandNO;
  Aproduct.Brandname := TheBrand.BrandName;
  Result := True;
end;


function CreateBillNo(const Flag: string): string;
begin
  if Uppercase(Flag) = 'ORDER' then
  begin
    Result := Thecustomer.Custno + '-' + inttostr(thecustomer.MaxNo);
    Execsql('Update Icustomer set Maxno=' + Inttostr(thecustomer.MaxNo + 1)
      + ' where custno=''' + TheCustomer.Custno + '''');
  end;
end;

function Getspacepos(const AproductTm: string): integer;
begin
  Result := pos(' ', copy(AproductTm, 6, length(AproductTm)));
end;

function GetCustinfo(const ATM: string; var ACustomer: TCustomer; custno: string = ''): Boolean;
var Tempquery: Tadoquery;
  TempStr: string;
begin
  Result := False;
  TempStr := Copy(Atm, Getspacepos(Atm) + 6, length(Atm) - (Getspacepos(Atm) + 4));
//  Showmessage(TempStr);
//  Showmessage(inttostr(Getspacepos(Atm)));
//  Showmessage(inttostr(Getspacepos(Atm)+1));
  Tempquery := TAdoquery.Create(nil);
  Tempquery.Connection := ActiveConnect;
  with Tempquery do
  begin
    try
      if Custno = '' then
      begin
        opensql(Tempquery, 'Select * from ICustomer where Custno=''' + Tempstr + '''');
        if Tempquery.RecordCount = 1 then
        begin
          ACustomer.Custno := Trim(Fieldbyname('Custno').AsString);
          Acustomer.Custname := Trim(Fieldbyname('Custname').AsString);
          Acustomer.MaxNo := Fieldbyname('Maxno').asinteger;
          Acustomer.Areano := Trim(Fieldbyname('Areano').AsString);
          Acustomer.Areaname := Trim(Fieldbyname('Areaname').AsString);
          Acustomer.Shopname := Trim(Fieldbyname('Shopname').AsString);
          Acustomer.Address := Trim(Fieldbyname('Address').AsString);
          Acustomer.Tel := Trim(Fieldbyname('Tel').AsString);
          Acustomer.Fax := Trim(Fieldbyname('Fax').AsString);
          Acustomer.Email := Trim(Fieldbyname('Email').AsString);
          Acustomer.Contactman := Trim(Fieldbyname('Contactman').AsString);
          Acustomer.Zkrate := Fieldbyname('zkrate').AsFloat;
          Result := True;
        end
        else
        begin
          ACustomer.Custno := '';
          Acustomer.Custname := '';
          Acustomer.MaxNo := 0;

⌨️ 快捷键说明

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