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

📄 sharefun.pas

📁 服装厂管理系统源程序压缩包, 请耐心阅读提供的文件包含的内容
💻 PAS
📖 第 1 页 / 共 3 页
字号:
        sql.text:='SELECT * FROM ' + tablename;
        sql.text:=sql.Text+' where ('+ fieldname +'='+''''+ fieldvalue+''''+')';
        try
                open;
        except
                Messagedlg('操作数据库失败![GetMaxID]',mterror,[mbok],0);
                tmpado.Close;
                tmpado.Free;
                exit;
        end;
        result:=recordcount >0;
   end;
   tmpado.Close;
   tmpado.Free;
end;


//clean spacebar in string
procedure ClearSpaceBar(var instr:string);
var
        i:integer;
begin
        if trim(instr)= '' then  begin instr:=''; exit; end;
        repeat
                i:=pos(' ',instr);
                if i>0 then Delete(instr,i,1);
        until i = 0;
end;

//clean spacebar in string
function MemComp(str1,str2:string;nLen:integer):integer;
var i:integer;
begin
        for i:=0 to nLen-1 do
        begin
                if str1[i]>str2[i] then begin result:=1;exit;end;
                if str1[i]<str2[i] then begin result:=-1;exit;end;
        end;
        result:=0;
end;

//取串口通讯参数
procedure GetCominfo();
begin
       //comunication port
       IcReader_info.ComPort := ReadIniFile(WsInteger,'communication','CommPort');
       //baund
       IcReader_info.baund  := ReadIniFile(WsInteger,'communication','baund');
       IcReader_info.ICType := ReadIniFile(WsString,'communication','Cardtype');
end;

//取终端系统使用领域类别
procedure GetTerminalInfo();
begin
       SysConfig.TerminalID    := ReadIniFile(WsInteger,'TERIMALTYPE','TEMID');
       SysConfig.TerminalName  := ReadIniFile(WsString,'TERIMALTYPE','TEMNAME');
end;


//取系统配置参数
procedure GetSysConfig();
var
tmpstr:string;
begin
       SysConfig.SYSFLAGNO   :=ReadIniFile(WsString,'SYSTEM','SYSFLAGNO');
       SysConfig.CURRENTPOSNO :=ReadIniFile(WsInteger,'SYSTEM','CURRENTPOSNO');

       //数据库信息
       SysConfig.DBTYPE     :=ReadIniFile(WsInteger,'DB','DBTYPE');
       SysConfig.DBName     :=ReadIniFile(WsString,'DB','Data Source');
       SysConfig.SECURITY   :=ReadIniFile(WsString,'DB','Persist Security Info');
       SysConfig.DBACCOUNT  :=ReadIniFile(WsString,'DB','User ID');
       SysConfig.DBPASSWORD :=ReadIniFile(WsString,'DB','Password');
       SysConfig.ServerName :=ReadIniFile(WsString,'DB','Server');
       SysConfig.DBTimeOut  :=ReadIniFile(WsInteger,'DB','TimeOut');


        case SysConfig.DBTYPE of
         0:     //Access *.mdb
             begin
               tmpstr:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+SysConfig.DBName+';';
               tmpstr :=tmpstr + 'Persist Security Info=False;Jet OLEDB:Database Password='+SysConfig.DBPASSWORD+';';
               tmpstr :=tmpstr + 'Persist Security Info=True;';
             end;
//         1:     //Excel  *.xls
//             if not CreateDSN_EXCEL(DSN,DataBase,spath,'D&N Time SoftWare') then exit;
         2:     //SQL Server
             begin
               tmpstr:='Provider=SQLOLEDB.1;Password='+SysConfig.DBPASSWORD+';';
               tmpstr :=tmpstr + 'Persist Security Info=True;User ID='+SysConfig.DBACCOUNT+';';
               tmpstr :=tmpstr + 'Initial Catalog='+SysConfig.DBName+';Data Source='+SysConfig.ServerName+';Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;';
             end;

        end;
       Sysconfig.DBCONNECTSTRING:= tmpstr;
end;


function WriteIniFile(WsType:integer;Section:string;Ident:string;DestValue:Variant):boolean;
var
  DelphiIni: TIniFile;
begin
  result:=false;
  DelphiIni := TIniFile.Create(AppPath+'\DNConfig.ini');
  try
          case WsType of
          WsString:
                DelphiIni.WriteString(Section,Ident,DestValue);
          WsInteger:
                DelphiIni.WriteInteger(Section,Ident,DestValue);
          WsFloat:
                  DelphiIni.WriteFloat(Section,Ident,DestValue);
          WsDate:
                  DelphiIni.WriteDate (Section,Ident,DestValue);
          WsDateTime:
                  DelphiIni.WriteDateTime (Section,Ident,DestValue);
          WsBool:
                  DelphiIni.WriteBool(Section,Ident,DestValue);
          WsTime:
                  DelphiIni.WriteTime(Section,Ident,DestValue);
          else
                DelphiIni.Free;
                exit;
          end;
  except
        DelphiIni.Free;
        MessageDlg('Write ini file error!',mterror,[mbok],0);
        exit;
  end;
  DelphiIni.Free;
  result:=true;
end;


function ReadIniFile(WsType:integer;Section:string;Ident:string):variant;
var
  DelphiIni: TIniFile;
begin
  DelphiIni := TIniFile.Create(AppPath+'\DNConfig.ini');
  try
          case WsType of
          WsString:
                ReadIniFile:=DelphiIni.ReadString(Section,Ident,'');
          WsInteger:
                ReadIniFile:=DelphiIni.ReadInteger(Section,Ident,0);
          WsFloat:
                ReadIniFile:=DelphiIni.ReadFloat(Section,Ident,0.0);
          WsDate:
                ReadIniFile:=DelphiIni.ReadDate (Section,Ident,now());
          WsDateTime:
                ReadIniFile:=DelphiIni.ReadDateTime (Section,Ident,now());
          WsBool:
                ReadIniFile:=DelphiIni.ReadBool(Section,Ident,false);
          WsTime:
                ReadIniFile:=DelphiIni.ReadTime(Section,Ident,now());
          else
                DelphiIni.Free;
                exit;
          end;
  except
        DelphiIni.Free;
        MessageDlg('Read ini file error!',mterror,[mbok],0);
        exit;
  end;
  DelphiIni.Free;
end;

function IniFileDeleteKey(Section:string;Ident:string):boolean;
var
  DelphiIni: TIniFile;
begin
  IniFileDeleteKey:=false;
  DelphiIni := TIniFile.Create(AppPath+'\DNConfig.ini');
  try
        DelphiIni.DeleteKey(Section,Ident);
  except
        DelphiIni.Free;
        MessageDlg('Ini file Delete key error!',mterror,[mbok],0);
        exit;
  end;
  DelphiIni.Free;
  IniFileDeleteKey:=true;
end;

//右向取字符串
function Right_Str(indata:string;count:integer):string;
var
 strlength:integer;
begin
 if trim(indata)='' then begin result:='';exit; end;
 strlength:=length(indata);
 result:=copy(indata,strlength-count+1,count);
end;         

//取指定时间的对应的最大天数
function GetDays(inDate:TDate):integer;
var YY,MM,DD:word;
begin
  DecodeDate(inDate,YY,MM,DD);
  DecodeDate(IncMonth(EncodeDate(YY,MM,1))-1,YY,MM,DD);
  result:=DD;
end;
//取上月最大的日期
function GetLastMonthMaxDate(inDate:TDate):TDate;
var YY,MM,DD:word;
begin
  DecodeDate(inDate,YY,MM,DD);
  result:=EncodeDate(YY,MM,1)-1;
end;

//以TreeView形式显示部门信息
procedure DispDepInf(TV:TTreeView;ParentNode:TTreeNode;NodeName:string;stateid:integer);
var i:integer;
    myRs :TADOQuery;
begin
   TV.Items.AddChild(ParentNode,NodeName);
   for i:=0 to TV.Items.Count-1 do
   if TV.Items.Item[i].Text= NodeName then
   begin
      TV.Items.Item[i].StateIndex:=Stateid;

      myRs:=TADOQuery.Create(nil); 
      with myRS do
      begin
           Connection :=DataMod.ADOCon;
           SQL.Add('select * from department where updepid=:v_updepid');
           Parameters.ParamValues['v_updepid']:=stateid; 
           try
                Open;
           except
                MessageDlg('处理部门信息失败!',mterror,[mbok],0);
                Free;
                exit;
           end;
           if recordcount=0 then begin Free; exit;end;
           First;
           while not eof do
           begin
              DispDepInf(TV,TV.Items.Item[i],trim(FieldValues['depname']),FieldValues['depid']);
              next;
           end;
           free;
        end;   //end with
   end; //end if 
end;


//判断金额的输入格式是否正确
function ToMoney(inText:string;var OutText:string):boolean;
var je:real;
begin
  result:=true;
  if inText=''    then  begin  OutText:='0.00'; exit; end;
  if inText='0'   then  begin  OutText:='0.00'; exit; end;
  if inText='.'   then  begin  OutText:='0.00'; exit; end;
  if inText='0.'  then  begin  OutText:='0.00'; exit; end;
  if inText='.0'  then  begin  OutText:='0.00'; exit; end;
  if inText='.00' then  begin  OutText:='0.00'; exit; end;
  if inText='0.0' then  begin  OutText:='0.00'; exit; end;
  try
    je:=strtofloat(inText);
    OutText:=format('%.02f',[je]);
  except
    result:=false;
    showmessage('金额格式不对[0.00]!');
  end;
end;


procedure DrawItem(obj:TLabel);
var
  Flags: Longint;
  Rc:TRect;
  MyCanvas:TCanvas;
  Logo:string;
begin
// procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
  Logo:='━━ D&&N Times Software ━━ ';
  MyCanvas:=obj.Canvas;
  rc:=obj.ClientRect;
  MyCanvas.Font.Size:=20;
  MyCanvas.Brush.Style := bsClear;
  MyCanvas.Font.Name:='华文行楷';
//  MyCanvas.Font.Name:='Wingdings 2';//'华文行楷';
  MyCanvas.Font.Color := clBtnHighlight;
  Flags:=DT_SINGLELINE or DT_RIGHT or DT_BOTTOM ;
  OffsetRect(Rc,0,4);
  DrawText(MyCanvas.Handle, PChar(Logo), Length(Logo), Rc, Flags);
  MyCanvas.Font.Color:=clBtnShadow;
  OffsetRect(Rc,-1,-1);
  DrawText(MyCanvas.Handle, PChar(Logo), Length(Logo), Rc, Flags);

  Flags:=DT_SINGLELINE or DT_VCENTER or DT_CENTER;
  OffsetRect(Rc,1,1);
  MyCanvas.Font.Color := clBtnHighlight;
//  sysconfig.COMPANYANME
  DrawText(MyCanvas.Handle, PChar('fdsafdsafdsfdsa'), Length('fdsafdsafdsfdsa'), Rc, Flags);
  MyCanvas.Font.Color:=clBtnShadow;
  OffsetRect(Rc,-1,-1);
  DrawText(MyCanvas.Handle, PChar('fdsafdsafdsfdsa'), Length('fdsafdsafdsfdsa'), Rc, Flags);
end;


procedure showform_dbconfig;
begin
  Form_DBConfig:=TForm_DBConfig.Create(Application);
  if Form_DBConfig.ShowModal=mrCancel then
  begin
    Form_Sflash.Close;
    DataMod.ADOCon.Close;
    CloseMe:=true;
    Application.Terminate;
  end
  else
  if Not DataMod.OpenDatabase()then
  begin
    Form_Sflash.Close;
    DataMod.ADOCon.Close;
    CloseMe:=true;
    Application.Terminate;
  end;
end;

//Ado表内的字段值的查找
function findRec(tablename,fieldname,recvalue:string;var info:string):boolean;
var
Adoq_temp:TAdoquery;
begin
   result:=false;
   Adoq_temp:=TAdoquery.Create(nil);
   Adoq_temp.Connection:=DataMod.ADOCon;
   with Adoq_temp do
   begin
       Close;
       SQL.Clear;
       SQL.Add('select * from '+tablename+' where '+ fieldname +'='+''''+ recvalue+'''');
       try
          Open;
          result:=not (recordcount<1);
       except
          info:='提示:   查找记录值失败!!!';
          Close;
          Free;
          exit;
       end;
       Close;
       Free;
   end;
end;


end.


⌨️ 快捷键说明

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