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

📄 czyda.~pas

📁 一个基于数据的药品行业管理系统,较全面,可供学习数据的开发人员参考消息
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:

procedure Tfrm_czyda.StringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
if (stringgrid1.Focused) and (arow<>0)  and (acol<>0) and
   (stringgrid1.Cells[1,arow]<>'')  then
   begin
   cell:=arow;
   coll:=acol ;
   end;
end;

procedure Tfrm_czyda.StringGrid1Click(Sender: TObject);
begin
     if (stringgrid1.Col>=coll) and (stringgrid1.Row>=cell) and (coll<>1) then
        begin
        if stringgrid1.Cells[stringgrid1.Col,stringgrid1.Row]='√' then
           stringgrid1.Cells[stringgrid1.Col,stringgrid1.Row]:=' '
         else
           stringgrid1.Cells[stringgrid1.Col,stringgrid1.Row]:='√'
         end;
end;


//加载功能选项
procedure Tfrm_czyda.treemenu;
var strsql,strtmp:string;
    menucount:Integer;
    i,n,j:integer;
    node,node1,node2,node3:ttreenode;
    menuitems:array of string;
begin
 j:=0;
 {for i:=0 to 5 do
 begin
   node1:=treeview1.Items.AddChild(node,);
   node.ImageIndex:=11;
   node.SelectedIndex:=1;
   for j:=0 to frm_main.MainMenu1.Items[i].Count-1 do
   begin
     if frm_main.MainMenu1.Items[i].Items[j].Caption<>'-' then
     begin
     node2:=treeview1.Items.AddChild(node1,frm_main.MainMenu1.Items[i].Items[j].Caption);
     node2.ImageIndex:=0;
     node2.SelectedIndex:=1;
     for k:=0 to frm_main.MainMenu1.Items[i].Items[j].Count-1 do
     begin
     if frm_main.MainMenu1.Items[i].Items[j].items[k].Caption<>'-' then
     begin
     node3:=treeview1.Items.AddChild(node2,frm_main.MainMenu1.Items[i].Items[j].Items[k].Caption);
     node3.ImageIndex:=0;
     node3.SelectedIndex:=1;
     end;
     end;
     end;
   end;
  end;
end;  }
  strsql:='select * from menulist order by menucode';
  with data do
  begin
    aq1.Connection:=adoc1;
    aq1.Close;
    aq1.SQL.Clear;
    aq1.SQL.Add(strsql);
    aq1.open;
    if aq1.Recordset.recordcount>0 then
    begin
      menucount:=aq1.RecordCount;
      setlength(menuitems,menucount);
      //setlength(nodes,menucount);
      node:=treeview1.Items.Add(nil,'系统功能列表');
      node.ImageIndex:=0;
      node.SelectedIndex:=1;
      node.SelectedIndex:=0;
      aq1.first;
      while not aq1.eof do
      begin
        for i:=0 to menucount-1 do
        begin
          menuitems[i]:=trim(aq1.Fields.Fieldbyname('menucode').value);
          if length(trim(aq1.Fields.Fieldbyname('menucode').value))=1 then
          begin
          node1:=treeview1.Items.Addchild(node,trim(aq1.Fields.Fieldbyname('menuname').Value));
          node1.ImageIndex:=11;
          end
          else
          if length(trim(aq1.Fields.Fieldbyname('menucode').value))=2 then
          begin
          if copy(trim(aq1.Fields.Fieldbyname('menucode').value),1,1)=copy(menuitems[i],1,1) then
          node2:=treeview1.Items.Addchild(node1,trim(aq1.Fields.Fieldbyname('menuname').Value));
          node2.ImageIndex:=11;
          end
          else
          if length(trim(aq1.Fields.Fieldbyname('menucode').value))=3 then
          begin
          if copy(trim(aq1.Fields.Fieldbyname('menucode').value),1,1)=copy(menuitems[i],1,1) then
          node3:=treeview1.Items.Addchild(node2,trim(aq1.Fields.Fieldbyname('menuname').Value));
          node3.ImageIndex:=11;
          end;
          aq1.next;
           end;
        end;
     end;
 end;  end;

procedure Tfrm_czyda.TreeView1GetSelectedIndex(Sender: TObject;
  Node: TTreeNode);
begin
 if treeview1.Selected.count>0 then
   treeview1.Selected.ImageIndex:=11;
end;

{procedure Tfrm_czyda.TreeView1Expanded(Sender: TObject; Node: TTreeNode);
var i:integer;
    sqlstr,sqlstr2:string;
begin
sqlstr:='select t1.menuname,t2.czybh,t3.price,t3.prin,t3.rw,t3.sh '+
' from menulist t1,czyda t2,userpower t3 '+
' where t1.menucode=t3.menucode and t3.czybh=t2.czybh and '+
' t1.menuname='''+trim(treeview1.Selected.Text)+'''  and '+
' t3.czybh='''+copy(txtczyqx.Items[txtczyqx.itemindex],1,4)+'''';
sqlstr2:='select t1.menuname,t2.czybh,t3.price,t3.prin,t3.rw,t3.sh '+
' from menulist t1,czyda t2,userpower t3 '+
' where t1.menucode=t3.menucode and t3.czybh=t2.czybh and '+
' t1.menuname='''+trim(treeview1.Selected.Text)+'''  and '+
' t3.czybh='''+copy(txtczyqx.Items[txtczyqx.itemindex],1,4)+'''';
if treeview1.Selected.count>0 then
   treeview1.Selected.ImageIndex:=11;
with data do
begin
aq1.Connection:=adoc1;
if txtczyqx.ItemIndex<=0 then
begin
sqlstr:='select menuname '+
' from menulist  where menuname='''+trim(treeview1.Selected.Text)+'''';
aq1.Close;
aq1.sql.Clear;
aq1.SQL.Add(sqlstr);
//aq1.Parameters.ParamByName('menuname').Value:=trim(treeview1.Selected.Text);
aq1.Open;
if aq1.Recordset.RecordCount>0 then
begin
  stringgrid1.RowCount:=aq1.RecordCount+1;
  while not aq1.Eof do
  begin
  for i:=1 to stringgrid1.RowCount-1 do
  stringgrid1.Cells[1,i]:=trim(aq1.Fields.Fieldbyname('menuname').Value);
  aq1.Next;
  end;
end;
end
else
begin
aq1.Close;
aq1.sql.Clear;
aq1.SQL.Add(sqlstr);
//aq1.Parameters.ParamByName('menuname').Value:=trim(treeview1.Selected.Text);
aq1.Open;
if aq1.Recordset.RecordCount>0 then
begin
  stringgrid1.RowCount:=aq1.RecordCount+1;
  while not aq1.Eof do
  begin
  for i:=1 to stringgrid1.RowCount-1 do
  begin
  stringgrid1.Cells[1,i]:=trim(aq1.Fieldbyname('menuname').Value);
  if trim(aq1.Fieldbyname('price').Value)='1' then
  stringgrid1.Cells[2,i]:='√'
  else
  stringgrid1.Cells[2,i]:=' ';
  if trim(aq1.Fieldbyname('rw').Value)='1' then
  stringgrid1.Cells[3,i]:='√'
  else
  stringgrid1.Cells[3,i]:=' ';
  if trim(aq1.Fieldbyname('prin').Value)='1' then
  stringgrid1.Cells[4,i]:='√'
  else
  stringgrid1.Cells[4,i]:=' ';
    if trim(aq1.Fieldbyname('sh').Value)='1' then
  stringgrid1.Cells[5,i]:='√'
  else
  stringgrid1.Cells[5,i]:=' ';
  aq1.Next;
  end
  end;
  end;
  end;
end;
end; }

procedure Tfrm_czyda.TreeView1Click(Sender: TObject);
var i:integer;
    sqlstr,sqlstr2:string;
begin
for i:=1 to stringgrid1.RowCount do
stringgrid1.Rows[i].Clear;
sqlstr:='select t1.menuname,t2.czybh,t3.price,t3.prin,t3.rw,t3.sh '+
' from menulist t1,czyda t2,userpower t3 '+
' where t1.menucode=t3.menucode and t3.czybh=t2.czybh and '+
' t1.menuname='''+trim(treeview1.Selected.Text)+'''  and '+
' t3.czybh='''+copy(txtczyqx.Items[txtczyqx.itemindex],1,4)+'''';
sqlstr2:='select t1.menuname,t2.czybh,t3.price,t3.prin,t3.rw,t3.sh '+
' from menulist t1,czyda t2,userpower t3 '+
' where t1.menucode=t3.menucode and t3.czybh=t2.czybh and '+
' t1.menuname='''+trim(treeview1.Selected.Text)+'''  and '+
' t3.czybh='''+copy(txtczyqx.Items[txtczyqx.itemindex],1,4)+'''';
if treeview1.Selected.count>0 then
   treeview1.Selected.ImageIndex:=11;
with data do
begin
aq1.Connection:=adoc1;
{if txtczyqx.ItemIndex<=0 then
begin
sqlstr:='select menuname '+
' from menulist  where menuname='''+trim(treeview1.Selected.Text)+'''';
aq1.Close;
aq1.sql.Clear;
aq1.SQL.Add(sqlstr);
//aq1.Parameters.ParamByName('menuname').Value:=trim(treeview1.Selected.Text);
aq1.Open;
if aq1.Recordset.RecordCount>0 then
begin
  stringgrid1.RowCount:=aq1.RecordCount+1;
  while not aq1.Eof do
  begin
  for i:=1 to stringgrid1.RowCount-1 do
  stringgrid1.Cells[1,i]:=trim(aq1.Fields.Fieldbyname('menuname').Value);
  aq1.Next;
  end;
end;
end }
//else
//begin
aq1.Close;
aq1.sql.Clear;
aq1.SQL.Add(sqlstr);
//aq1.Parameters.ParamByName('menuname').Value:=trim(treeview1.Selected.Text);
aq1.Open;
if aq1.Recordset.RecordCount>0 then
begin
  stringgrid1.RowCount:=aq1.RecordCount+1;
  while not aq1.Eof do
  begin
  for i:=1 to stringgrid1.RowCount-1 do
  begin
  stringgrid1.Cells[1,i]:=trim(aq1.Fieldbyname('menuname').Value);
  if trim(aq1.Fieldbyname('price').Value)='1' then
  stringgrid1.Cells[2,i]:='√'
  else
  stringgrid1.Cells[2,i]:=' ';
  if trim(aq1.Fieldbyname('rw').Value)='1' then
  stringgrid1.Cells[3,i]:='√'
  else
  stringgrid1.Cells[3,i]:=' ';
  if trim(aq1.Fieldbyname('prin').Value)='1' then
  stringgrid1.Cells[4,i]:='√'
  else
  stringgrid1.Cells[4,i]:=' ';
  if trim(aq1.Fieldbyname('sh').Value)='1' then
  stringgrid1.Cells[5,i]:='√'
  else
  stringgrid1.Cells[5,i]:=' ';
  aq1.Next;
  end;
  end;
end
else
begin
  if treeview1.Selected.Level<>0 then
  stringgrid1.Cells[1,1]:=treeview1.Selected.Text;

  end;
  end;
//end;
end;

{procedure Tfrm_czyda.stringpower;
var i:integer;
    sqlstr,sqlstr2:string;
begin
sqlstr:='select t1.menuname,t2.czybh,t3.price,t3.prin,t3.rw,t3.sh '+
' from menulist t1,czyda t2,userpower t3 '+
' where t1.menucode=t3.menucode and t3.czybh=t2.czybh and '+
' t1.menuname='''+trim(treeview1.Selected.Text)+'''  and '+
' t3.czybh='''+copy(txtczyqx.Items[txtczyqx.itemindex],1,4)+'''';
sqlstr2:='select t1.menuname,t2.czybh,t3.price,t3.prin,t3.rw,t3.sh '+
' from menulist t1,czyda t2,userpower t3 '+
' where t1.menucode=t3.menucode and t3.czybh=t2.czybh and '+
' t1.menuname='''+trim(treeview1.Selected.Text)+'''  and '+
' t3.czybh='''+copy(txtczyqx.Items[txtczyqx.itemindex],1,4)+'''';
if treeview1.Selected.count>0 then
   treeview1.Selected.ImageIndex:=11;
with data do
begin
aq1.Connection:=adoc1;
{if txtczyqx.ItemIndex<=0 then
begin
sqlstr:='select menuname '+
' from menulist  where menuname='''+trim(treeview1.Selected.Text)+'''';
aq1.Close;
aq1.sql.Clear;
aq1.SQL.Add(sqlstr);
//aq1.Parameters.ParamByName('menuname').Value:=trim(treeview1.Selected.Text);
aq1.Open;
if aq1.Recordset.RecordCount>0 then
begin
  stringgrid1.RowCount:=aq1.RecordCount+1;
  while not aq1.Eof do
  begin
  for i:=1 to stringgrid1.RowCount-1 do
  stringgrid1.Cells[1,i]:=trim(aq1.Fields.Fieldbyname('menuname').Value);
  aq1.Next;
  end;
end;
end
//else
//begin
aq1.Close;
aq1.sql.Clear;
aq1.SQL.Add(sqlstr);
//aq1.Parameters.ParamByName('menuname').Value:=trim(treeview1.Selected.Text);
aq1.Open;
if aq1.Recordset.RecordCount>0 then
begin
  stringgrid1.RowCount:=aq1.RecordCount+1;
  while not aq1.Eof do
  begin
  
  for i:=1 to stringgrid1.RowCount-1 do
  begin
  stringgrid1.Cells[1,i]:=trim(aq1.Fieldbyname('menuname').Value);
  if trim(aq1.Fieldbyname('price').Value)='1' then
  stringgrid1.Cells[2,i]:='√'
  else
  stringgrid1.Cells[2,i]:=' ';
  if trim(aq1.Fieldbyname('rw').Value)='1' then
  stringgrid1.Cells[3,i]:='√'
  else
  stringgrid1.Cells[3,i]:=' ';
  if trim(aq1.Fieldbyname('prin').Value)='1' then
  stringgrid1.Cells[4,i]:='√'
  else
  stringgrid1.Cells[4,i]:=' ';
    if trim(aq1.Fieldbyname('sh').Value)='1' then
  stringgrid1.Cells[5,i]:='√'
  else
  stringgrid1.Cells[5,i]:=' ';
  aq1.Next;
  end
  end;
  end;
  end;
end;
end; }

procedure Tfrm_czyda.txtczyqxChange(Sender: TObject);
var i:integer;
    sqlstr,sqlstr2:string;
begin
for i:=1 to stringgrid1.RowCount-1 do
stringgrid1.Rows[i].Clear;
sqlstr:='select t1.menuname,t2.czybh,t3.price,t3.prin,t3.rw,t3.sh '+
' from menulist t1,czyda t2,userpower t3 '+
' where t1.menucode=t3.menucode and t3.czybh=t2.czybh and '+
' t1.menuname='''+trim(treeview1.Selected.Text)+'''  and '+
' t3.czybh='''+copy(txtczyqx.Items[txtczyqx.itemindex],1,4)+'''';
sqlstr2:='select t1.menuname,t2.czybh,t3.price,t3.prin,t3.rw,t3.sh '+
' from menulist t1,czyda t2,userpower t3 '+
' where t1.menucode=t3.menucode and t3.czybh=t2.czybh and '+
' t1.menuname='''+trim(treeview1.Selected.Text)+'''  and '+
' t3.czybh='''+copy(txtczyqx.Items[txtczyqx.itemindex],1,4)+'''';
if treeview1.Selected.count>0 then
   treeview1.Selected.ImageIndex:=11;
with data do
begin
aq1.Connection:=adoc1;

aq1.Close;
aq1.sql.Clear;
aq1.SQL.Add(sqlstr);
//aq1.Parameters.ParamByName('menuname').Value:=trim(treeview1.Selected.Text);
aq1.Open;
if aq1.Recordset.RecordCount>0 then
begin
  stringgrid1.RowCount:=aq1.RecordCount+1;
  while not aq1.Eof do
  begin
  for i:=1 to stringgrid1.RowCount-1 do
  begin
  stringgrid1.Cells[1,i]:=trim(aq1.Fieldbyname('menuname').Value);
  if trim(aq1.Fieldbyname('price').Value)='1' then
  stringgrid1.Cells[2,i]:='√'
  else
  stringgrid1.Cells[2,i]:=' ';
  if trim(aq1.Fieldbyname('rw').Value)='1' then
  stringgrid1.Cells[3,i]:='√'
  else
  stringgrid1.Cells[3,i]:=' ';
  if trim(aq1.Fieldbyname('prin').Value)='1' then
  stringgrid1.Cells[4,i]:='√'
  else
  stringgrid1.Cells[4,i]:=' ';
  if trim(aq1.Fieldbyname('sh').Value)='1' then
  stringgrid1.Cells[5,i]:='√'
  else
  stringgrid1.Cells[5,i]:=' ';
  aq1.Next;
  end;
  end;
end
else
begin
  stringgrid1.Cells[1,1]:=treeview1.Selected.Text;

  end;
  end;
//end;
end;

procedure Tfrm_czyda.TreeView1Expanded(Sender: TObject; Node: TTreeNode);
begin
treeview1.Items[0].Selected;
end;

procedure Tfrm_czyda.TreeView1Expanding(Sender: TObject; Node: TTreeNode;
  var AllowExpansion: Boolean);
begin
treeview1.Items[1].Selected;
end;

end.

⌨️ 快捷键说明

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