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

📄 ufunction.~pas

📁 相关的销售服务管理行业的一个软件
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
unit Ufunction;





interface
 uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ComCtrls, DBCtrls, StdCtrls, Mask, ExtCtrls, Buttons, ToolWin, Grids,
  DBGridEh,adodb,checklst,SYS_DataModal,uzdj,u_dm;
procedure  reset( LstSet:TCheckListBox; TBName:string; itype,con:String);
procedure Seek(DGrid:TDBGridEh; Basetb,itype, Datatb, condi :string);
procedure   readset(LstSet:TCheckListBox;TBName,itype,con:string);
procedure fresh( LstSet :TCheckListBox;itype,sort:integer;ww:string);
function MyGetCode(iType : integer;bAdd :Boolean) : string;
procedure  ButEnabled(Tool:TToolBar; arr:array of  boolean);
//////////////////////2002-04-09从库存中掉调入的函数
function FullGd(Qry:TADOQuery;GdEh:TDBGridEh;sTblName:String;Md:integer;Cktag:string): Boolean;
    //填置DBGrid的表头——在Show事件中使用。如不用则SetItem无法使用。
function SaveCol(stblName:String;GDEh:TDBGridEh;Md:integer;Cktag:string):Boolean;
procedure FillComboBox(ComboBox:TCustomComboBox;TableName:String;FieldName:String);
    //填充ComboBox
function Full_Front_Edit(Back_Edit:TCustomEdit;Front_Edit:TCustomEdit;Tree_Sel:TfrmSel_Base):Boolean;overload;
    //填前面的Edit

function Full_Back_Edit(Back_Edit:TCustomEdit;Front_Edit:TCustomEdit;Tree_Sel:TfrmTree_Sel):Boolean;overload;
    //填后面的Edit
function HaveError(Back_Edit:TCustomEdit;Front_Edit:TCustomEdit):Boolean;
    //前后Edit是否一致
procedure setDBGridEhTile(Qtemp:TADOQuery;fromidx,toidx:integer);
function GetGdCode():String;
    //选择物品编码
function SetItem(Qry:TADOQuery):Boolean;
    //设置GridEh的表头显示的项目


type
  Tww = class(Tobject)
     ww:string;
  private
    { Private declarations }
  public
    { Public declarations }
  end;
    //设置GridEh的表头显示的项目
implementation
var
ww:Tww;
function FullGd(Qry:TADOQuery;GdEh:TDBGridEh;sTblName:String;Md:integer;Cktag:string): Boolean;
var
  TmpCol:TColumnEh;
begin
  result:=true;
  GdEh.Columns.Clear;
  Qry.Close;
  Qry.SQL.Clear;
  case md of
    1:
      if Cktag<>'' then
        Qry.SQL.Text:='select * from S_QrDetail where (reporder='+#39+sTblName+#39+') and (location=''d'') and (kc_cktag='+#39+Cktag+#39+')'
      else
        Qry.SQL.Text:='select * from S_QrDetail where (reporder='+#39+sTblName+#39+') and (location=''d'') and (kc_cktag is null)';
    2:Qry.SQL.Text:='select * from S_QrDetail where (reporder='+#39+sTblName+#39+') and (location<>''d'') and (kc_cktag='+#39+Cktag+#39+')';
    3:Qry.SQL.Text:='select * from S_QrDetail where reporder='+#39+sTblName+#39;
  end;
  Qry.SQL.Add(' order by repitem asc');      //iorder
  Qry.Open;
  while not Qry.Eof do
  begin
    TmpCol:=GdEh.Columns.Add;
    TmpCol.FieldName:=Qry.FieldByName('dispfield').AsString;
    if not GdEh.ReadOnly then
      if Qry.FieldByName('dispfield').AsString='nGoodName' then
      begin
        TmpCol.AlwaysShowEditButton := true;
        TmpCol.ButtonStyle := (cbsEllipsis);//cbsDropDown);
      end;
    if Qry.FieldByName('dispfield').AsString='nFsJine' then
    begin
{      if GdEh.Columns.Count > 1 then begin
        GdEh.Columns[0].Footer.ValueType := (fvtStaticText);
        GdEh.Columns[0].Footer.Value:='合计:';
      end;}
      TmpCol.Footer.FieldName := Qry.FieldByName('dispfield').AsString;
      TmpCol.Footer.ValueType := (fvtSum);
    end;
    TmpCol.Title.Caption:=Qry.FieldByName('dispname').AsString;
    TmpCol.Alignment:=IntToAli(Qry.FieldByName('align').AsString);
    TmpCol.Width:=Qry.FieldByName('kc_dgwidth').AsInteger;
    if not Qry.FieldByName('ifshow').AsBoolean then
      TmpCol.Visible := false;
    Qry.Next;
  end;
end;
procedure FillComboBox(ComboBox:TCustomComboBox;TableName:String;FieldName:String);
begin
  ComboBox.Items.Clear;
  with DM.ADOQry do
  begin
    Close;
    SQL.Text:='Select distinct '+FieldName+' from '+TableName+' where '+fieldName+'<>'+''''+''+'''';
    Open;
    ComBoBox.Items.Clear;
    While not Eof do
    begin
      ComboBox.Items.Add(FieldByName(FieldName).AsString);
      Next;
    end;
  end;
end;

function SaveCol(stblName:String;GDEh:TDBGridEh;Md:integer;Cktag:string):Boolean;
var
  i:integer;
begin
  result:=true;
  try
    with DM.ADOQgridset do
    begin
      for i:=0 to GdEh.Columns.Count-1 do
      begin
        Close;
        SQL.Clear;
        SQL.Text:='update S_QrDetail set kc_dgwidth=';
        SQL.Add(inttostr(GdEh.Columns[i].width));  //iorder
        SQL.Add(',dispname='+#39+GDEh.Columns[i].Title.Caption+#39);
        case md of
          1:SQL.add(' where (reporder='+#39+sTblName+#39+') and (location=''d'') and (kc_cktag='+#39+Cktag+#39+')');
          2:SQL.add(' where (reporder='+#39+sTblName+#39+') and (location<>''d'') and (kc_cktag='+#39+Cktag+#39+')');
          3:SQL.add(' where (reporder='+#39+sTblName+#39+')');
        end;
        SQL.Add(' and (dispfield='+#39+GdEh.Columns[i].FieldName+#39+')');
        ExecSQL;
      end;
    end;
  except
    result:=false;
  end;
end;
function Full_Front_Edit(Back_Edit:TCustomEdit;Front_Edit:TCustomEdit;Tree_Sel:TfrmTree_Sel):Boolean;
var
  Code_name:String;
begin
  result:=true;
  try
    Code_name:=FindName(Back_Edit.Text,Tree_Sel);
    if trim(Front_Edit.Text)<>Code_name then
      Front_Edit.Text:=Code_Name;
  except
    result:=false;
  end;
end;
//==========================================================
function Full_Front_Edit(Back_Edit:TCustomEdit;Front_Edit:TCustomEdit;Tree_Sel:TfrmSel_Base):Boolean;overload;
var
  Code_name:String;
begin
  result:=true;
  try
    Code_name:=FindName(Back_Edit.Text,Tree_Sel);
    if trim(Front_Edit.Text)<>Code_name then
      Front_Edit.Text:=Code_Name;
  except
    result:=false;
  end;
end;
//==========================================================
function Full_Back_Edit(Back_Edit:TCustomEdit;Front_Edit:TCustomEdit;Tree_Sel:TfrmTree_Sel):Boolean;
var
  TCode:String;
begin
  result:=true;

  try
    TCode:=FindTCode(Front_Edit.Text,Tree_Sel);
    if Back_Edit.Text<>TCode then
    begin
      Back_Edit.Text:=TCode;
    end;
  except
    result:=false;
  end;
end;
//==========================================================
function Full_Back_Edit(Back_Edit:TCustomEdit;Front_Edit:TCustomEdit;Tree_Sel:TfrmSel_Base):Boolean;overload;
var
  TCode:String;
begin
  result:=true;
  try
    TCode:=FindTCode(Front_Edit.Text,Tree_Sel);
    if Back_Edit.Text<>TCode then
    begin
      Back_Edit.Text:=TCode;
    end;
  except
    result:=false;
  end;
end;
function HaveError(Back_Edit:TCustomEdit;Front_Edit:TCustomEdit):Boolean;
begin
  result:=false;
  if (Front_Edit.Text<>'') and (Back_Edit.Text='') then
  begin
    Application.MessageBox('输入有误,请重试','提示',64);
    Front_Edit.SetFocus;
    result:=true;
  end;
end;
procedure setDBGridEhTile(Qtemp:TADOQuery;fromidx,toidx:integer);
var
  I,J,item:integer;
  str1,str2:string;
begin
  with Qtemp do
    begin
      Sort:='RepItem ASC';
      First;
      item:=Qtemp.fieldbyname('repitem').asinteger;
//------------------------------------向前移动----------------------------------
      if fromidx > toidx then
        begin
          Locate('RepItem',item+toidx,[loCaseInsensitive]);
          str1:=FieldByName('DispField').asstring;

          Locate('RepItem',item+fromidx,[loCaseInsensitive]);
          str2:=FieldByName('DispField').asstring;
          Edit;
          FieldByName('RepItem').asinteger:=toidx+item;
          Post;

          for i:=fromidx-1 downto toidx+1 do
            begin
              Locate('RepItem',i+item,[loCaseInsensitive]);
              edit;
              FieldByName('RepItem').asinteger:=item+i+1;
              post;
            end;

          Locate('DispField',str1,[loCaseInsensitive]);
          Edit;
          FieldByName('RepItem').asinteger:=toidx+item+1;
          Post;
        end;
//----------------------------------向后移动------------------------------------
     if fromidx < toidx then
        begin
          Locate('RepItem',item+toidx,[loCaseInsensitive]);
          str1:=FieldByName('DispField').asstring;

          Locate('RepItem',item+fromidx,[loCaseInsensitive]);
          Edit;
          FieldByName('RepItem').asinteger:=toidx+item;
          Post;

          for i:=fromidx+1 to toidx-1 do
            begin
              Locate('RepItem',i+item,[loCaseInsensitive]);
              edit;
              FieldByName('RepItem').asinteger:=item+i-1;
              post;
            end;

          Locate('DispField',str1,[loCaseInsensitive]);
          Edit;
          FieldByName('RepItem').asinteger:=toidx+item-1;
          Post;
        end;
    end;
end;
function GetGdCode():String;
begin
  Result:='';
  ClearSelForm;
  frmSel_Goods.Show;

  while frmSel_Goods.active do
    Application.ProcessMessages;

  if frmSel_Goods.SB<>sbHide then
  begin
    frmSel_Goods.Close;
    frmSel_Goods.SB:=sbNone;
    Exit;
  end;

⌨️ 快捷键说明

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