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

📄 datamrp.pas

📁 飞恒进销存(超市批发)管理系统(含源程序) 语言:Delphi 6/7 相关控件:FastReport 2.4以上, Ehlib 3.4以上
💻 PAS
📖 第 1 页 / 共 4 页
字号:

       querycfg.open;
       if not querycfg.eof then
       begin
         s:=querycfg.fieldbyname('mInvono').asstring;
         if s='' then nTmp:=0 else  nTmp:=strToint(s);
         if nTmp > nOrderSeq then nOrderseq:=nTmp;
       end;

     end ;//end of b7seq

     queryCfg.close;
     querycfg.sql.clear;
     querycFg.sql.add('update cfg set invoseq= :invoseq,inseq= :inseq,orderseq= :orderSeq');
     querycfg.params[0].asinteger:=nInvoseq;
     querycfg.params[1].asinteger:=nInseq;
     querycfg.params[2].asinteger:=nOrderseq;
     querycfg.execsql
  end; //end of datamoudle

end;

Function TDataPub.Int2ToStrPad0(N:LongInt;ch:char;Len:integer):string;
begin
     Fmtstr(Result,'%d',[n]);
     While Length(Result)<Len do
           Result:=ch+Result;
     //           Result:='0'+Result;
end;


Function TDataPub.StrPadCh(sStr:string;ch:char;Len:integer):string;
begin
  Result:=sStr;
  While Length(Result)<Len do
           Result:=Result+ch;
end;

Function TDataPub.MoneyToStr(nAmount:real):string;
var
   n,j,nPositon:integer;
   sAmount:string;
   sTmp:string;
   sResutl,sResult:string;
   bInt:boolean;
begin
     sResult:='';
     str(nAmount:9:0,sAmount);
     sAmount:=trim(sAmount);
     n:=length(sAmount);

     //已为整
     if nAmount=0 then bInt:=true else bInt:=false;

     for j:=n downto 1 do
     begin
       sTmp:=copy(sAmount,j,1);
       nPositon:=(n-j+1);

       if not bInt then
         if sTmp[1]='0' then
           continue
         else begin bInt:=true;
           case nPositon of
           2,3:     sResult:='整';
           4,5,6,7: sResult:='元整';
           8,9:     sResult:='万元整';
           end;
         end;

       case sTmp[1] of
       '0':sResutl:='零';
       '1':sResutl:='壹';
       '2':sResutl:='贰';
       '3':sResutl:='叁';
       '4':sResutl:='肆';
       '5':sResutl:='伍';
       '6':sResutl:='陆';
       '7':sResutl:='柒';
       '8':sResutl:='捌';
       '9':sResutl:='玖';
       end;
       case nPositon of
       1:sResutl:=sResutl+'分';
       2:sResutl:=sResutl+'角';
       3:sResutl:=sResutl+'元';
       4:sResutl:=sResutl+'拾';
       5:sResutl:=sResutl+'佰';
       6:sResutl:=sResutl+'仟';
       7:sResutl:=sResutl+'万';
       8:sResutl:=sResutl+'拾';
       9:sResutl:=sResutl+'佰';
       end;
       sResult:=sResutl+sResult;
     end;
     Result:='¥'+sResult;
end;

{
Function TDataPub.MoneyToStr(nAmount:real):string;
var
   n,j,nPositon:integer;
   sAmount:string;
   sTmp:string;
   sResutl,sResult:string;
begin
     sResult:='';
     str(nAmount:9:0,sAmount);
     sAmount:=trim(sAmount);
     n:=length(sAmount);
     for j:=n downto 1 do
     begin
       sTmp:=copy(sAmount,j,1);
       nPositon:=(n-j+1);
       case sTmp[1] of
       '0':sResutl:='零';
       '1':sResutl:='壹';
       '2':sResutl:='贰';
       '3':sResutl:='叁';
       '4':sResutl:='肆';
       '5':sResutl:='伍';
       '6':sResutl:='陆';
       '7':sResutl:='柒';
       '8':sResutl:='捌';
       '9':sResutl:='玖';
       end;
       case  nPositon of
       1:sResutl:=sResutl+'分';
       2:sResutl:=sResutl+'角';
       3:sResutl:=sResutl+'元';
       4:sResutl:=sResutl+'拾';
       5:sResutl:=sResutl+'佰';
       6:sResutl:=sResutl+'仟';
       7:sResutl:=sResutl+'万';
       8:sResutl:=sResutl+'拾';
       9:sResutl:=sResutl+'佰';
       end;
       sResult:=sResutl+sResult;
     end;
     Result:='¥'+sResult;
end;

}
function TDataPub.GetCredID(date1:TDatetime;n:integer):string;
var
   s,s1:string;
begin
    ShortDateFormat:='yyyy-mm-dd';
    s:=datetostr(date1);
    s1:=copy(s,1,4);
    s:=s1+copy(s,6,2);
    result:=s+int2StrPad0(n,5)
end;

Function TDataPub.SetSize(nSize,nType:integer):integer;
begin
  case nType of
  1:  result:=nNowFormHeight-nOrgFormHeight+nSize;//height
  2:  result:=nNowFormWidth-nOrgFormWidth+nSize;  //width
  3:  result:=(nNowFormHeight-nOrgFormHeight) div 2+nSize;//half height
  4:  result:=(nNowFormWidth-nOrgFormWidth) div 2+nSize;  //half width
  else
    result:=nNowFormHeight-nOrgFormHeight;
  end;
end;

procedure TDataPub.SetSize1(form1:TForm;control1:TControl;nType,nPercent:integer);
var
  i:integer;
begin
  for I := Form1.ComponentCount - 1 downto 0 do
  begin
    if (Form1.Components[I] is TButton) then
    begin
      if nType=3 then
        (Form1.Components[i] as TButton).left:=(nNowFormWidth-Form1.Width ) div nPercent+(Form1.Components[i] as TButton).left;
      if nType=4 then
        (Form1.Components[i] as TButton).top:=(nNowFormHeight-Form1.height ) div nPercent+(Form1.Components[i] as TButton).top;
    end;
  end;

  case ntype of
  0:Control1.height:=(nNowFormHeight-form1.Height ) div nPercent+Control1.Height;
  1:Control1.width:=(nNowFormWidth-Form1.Width ) div nPercent+Control1.width;
  end;
end;

Function TDataPub.SetSize2(form1:TForm;nSize,nType,nPercent:integer):integer;
begin
  case ntype of
  0:result:=(nNowFormHeight-form1.Height ) div nPercent+nSize;
  1:result:=(nNowFormWidth-Form1.Width ) div nPercent+nSize;
  else
  result:=nSize;
  end;
end;

procedure TDataPub.DecodeSelection;
begin
  if sSelection[1]='1' then bNostore:=true else bNoStore:=false;
  if sSelection[2]='1' then bExtraPage:=true else bExtraPage:=false;
  nSysPaper:=strtoint(sSelection[3]);
  nSysCopy:=strtoint(sSelection[4]);
  nSysLevel1:=strtoint(sSelection[5]); //各级编码的总长(含上级) - 1
  nSysLevel2:=nSysLevel1+strtoint(sSelection[6]);
  nSysLevel3:=nSysLevel2+strtoint(sSelection[7]);
  if sSelection[8]='1' then bCloseOut:=true else bCloseOut:=false;
  if sSelection[9]='1' then bPrintIn:=true else bPrintIn:=false;
  if sSelection[10]='1' then bPrintFrame:=true else bPrintFrame:=false;
  if sSelection[11]='1' then bFIFO:=true else bFIFO:=false;
  nSysItemPerPage:=strtoint(sSelection[12])*10+strtoint(sSelection[13]);
  if sSelection[14]='1' then PrintOption:=true else PrintOption:=false;
  if sSelection[15]='1' then bNetFresh:=true else bNetFresh:=false;
  nSysLine:=strtoint(sSelection[16]);
  nPageAdd:=strtoint(sSelection[17]);
  if sSelection[18]='1' then bZone:=true else bZone:=false;
  if sSelection[19]='1' then bPenStyle:=true else bPenStyle:=false;
  nPageWidth:=strtoint(sSelection[20])*100+strtoint(sSelection[21])*10+strtoint(sSelection[22]);
  nFontSize:=strtoint(sSelection[23])*10+strtoint(sSelection[24]);
  if sSelection[25]='1' then b7Seq:=true else b7Seq:=false;
  nSaveDataDay:=strtoint(sSelection[26])*100+strtoint(sSelection[27])*10+strtoint(sSelection[28]);
  if sSelection[29]='1' then bSafe:=true else bSafe:=false;
  if sSelection[30]='1' then bOutUnit2:=true else bOutUnit2:=false;
  nInpriceType:=strtoint(sSelection[31]);
  nSumbit:=strtoint(sSelection[32]);
  if sSelection[33]='1' then bPrnCusTel:=true else bPrnCusTel:=false;
  if sSelection[34]='1' then bAutoIO:=true else bAutoIO:=false;
  nBillStyle:=strtoint(sSelection[35]);
  if sSelection[36]='1' then bZeroProfit:=true else bZeroProfit:=false;
  if sSelection[37]='1' then bPrintBarcode:=true else bPrintBarcode:=false;
  nPageTopMargin:=strtoint(sSelection[38])*10+strtoint(sSelection[39]);
  nPageBottomMargin:=strtoint(sSelection[40])*10+strtoint(sSelection[41]);;
  if sSelection[42]='1' then bSalePos:=true else bSalePos:=false;  

  if nSaveDataDay=0 then nSaveDataDay:=999; //不册除数据
  if nSysLine=0 then nSysLine:=999;         //为0 不打印分隔线
end;

procedure TDataPub.EncodeHotel;
var
   fSys,fHotel:TextFile;
   s,sFileName,sFile1:string;
   nLength,i:integer;
begin
   AssignFile(fSys,'\sxm\data\飞恒.TXT');
   Reset(fSys);
   Readln(fSys,sFilename);
   closeFile(fSys);

   sFile1:=trim(sFilename)+'.txt';
   AssignFile(fHotel,sFile1);
   Reset(fHotel);
   readln(fHotel,s);
   closeFile(fHotel);

   nLength:=length(s);
   for i:=1 to nlength do
      s[i]:=chr( ord(s[i])xor ord(CopyRight[i mod 22+1]) xor ord(Software[i mod 16+1]) xor (ord(Developer[i mod 30])+i*2+8));

   sFile1:=trim(sFilename)+'.sys';
   AssignFile(fHotel,sFile1);
   ReWrite(fHotel);
   writeln(fHotel,s);
   closeFile(fHotel);

end;

procedure TDataPub.DecodeOneHotel ;
var
   fSys,fHotel:TextFile;
   s:string;
   ch:char;
   i,n:integer;
begin
   ReportPath:='c:\sxm\data\';
   s:='\sxm\data\飞恒软件.txt';
   if FileExists(s) then
     AssignFile(fSys,'\sxm\data\飞恒软件.txt')
   else
     AssignFile(fSys,'\sxm\data\飞恒.sys');
   Reset(fSys);
   Readln(fSys,s);
   Readln(fSys,hotelId);
   closeFile(fSys);

   //c:\sxm\data\  -> data\report 方便开发
   //\sxm\data\    -> data
   if uppercase(copy(s,1,2))='C:' then  ReportPath:='c:\sxm\data\report\';

   AssignFile(fHotel,s);
   Reset(fHotel);
   i:=1;
   n:=1;
   s:='';
   while not eof(fHotel) do
   begin
      read(fHotel,ch);
      ch:=chr( ord(ch) xor ord(CopyRight[i mod 22+1]) xor ord(Software[i mod 16+1]) xor (ord(Developer[i mod 30])+i*2+8));
      if ch='/' then
      begin
        if n=1 then HotelName:=s;
        if n=2 then InstallDate:=strTodate(s);
        if n=3 then HotelSpe:=StrToint(s);
        s:='';
        inc(n);
      end
      else
       s:=s+ch;

      inc(i);
   end;

   closeFile(fHotel);
end;

function TDataPub.ReadRegistry:string;
var
  sRegCode:string;
  Registry: TRegistry;
begin
  sRegCode:=RegisterCode(SerialNo(EncodeString(hotelName,EncodeKey)),hotelId);

  Registry:=TRegistry.Create;
  try
    Registry.OpenKey('\Software\ODBC\ODBC.INI\myMRP',False);
    result:=Registry.ReadString(HotelId);
  finally
    Registry.Free;
  end;
end;

function TDataPub.WriteRegistry:boolean;
var
  sRegCode:string;
  Registry: TRegistry;
begin
  result:=false;
  sRegCode:=RegisterCode(SerialNo(EncodeString(hotelName,#143#7#91#37)),hotelId);

  Registry:=TRegistry.Create;
  try
    Registry.OpenKey('\Software\ODBC\ODBC.INI\myMRP',False);
    Registry.WriteString(HotelId,sRegCode);
    result:=true;
  finally
    Registry.CloseKey ;
    Registry.Free;
  end;
end;

//对客户名称进行变换
function TDataPub.EncodeString(mCusName,mKey:string):string;
var
  I, J: Integer;
  s:string;
begin
  J := 1;
  s:='';
  for I := 1 to Length(mCusName) do
  begin
    s := s + Char(Ord(mCusName[I]) xor Ord(mKey[J]));
    if J + 1 <= Length(mKey) then
      Inc(J)
    else
      J := 1;
  end;
  { 自己加步骤 }
  result:=s;
end; { StringEncrypt }

//生成序列号,最后只取8位
function TDataPub.SerialNo(mString: string): string;
var
  I,n,k,m: Integer;
  S: string;
begin
  Result := '';
  S := '';
  m:=0;
  for I := 1 to Length(mString) do
  begin
    n:= m+ord(mString[I]) ;
    k:= n div 7;
    case k of
      0..9   : n:=k +48;
      10..35 : n:=k + 55;
    else
      n:=50;
    end;
    S := S + chr(n);
    m:=( m + n ) or (m-n);
  end;
  Result := s;
end; { StringToDisplay }

//由序列号生成注册号: 前8位为序列号,后7位为加密号
function TDataPub.RegisterCode(mString,mCusNo: string): string;
var
  I,n,k,m,j: Integer;
  S,ch: string;
begin
  Result := '';
  s:='';
  j:=1;
  for I:=1 to 8 do
  begin
    s := s + Char(Ord(mString[I]) xor (Ord(mCusNo[J])* Ord(mCusNo[3]) +1) );
    if J + 1 <= Length(mCusNo) then
      Inc(J)
    else
      J := 1;
  end;

  ch:=s;
  S := '';
  m:=0;
  for I := 1 to 7 do
  begin
    n:= m+ord( ord(mString[I]) xor ord(ch[8-I]) xor ord(ch[I])  ) ;
    k:= n div 7;
    case k of
      0..9   : n:=k +48;
      10..35 : n:=k + 55;
    else
      n:=53;
    end;
    S := S + chr(n);
    m:=( m + n ) or ( m - n   ) ;
  end;
  Result := copy(mString,1,5)+'-'+copy(mstring,6,3) + copy(s,1,2)+'-'+copy(s,3,5);
end; { StringToDisplay }

function TDataPub.GetLastMonth(xDate:TDatetime):Tdatetime;
var

⌨️ 快捷键说明

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