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

📄 untmaintainvs.~pas

📁 1、通过串口连接手机或短信终端发送短信; 2、内置Access数据库
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
  ClearStringGrid1;
  DM1.QryMaintain.Close;
  DM1.QryMaintain.SQL.Text := sSQL;
  DM1.QryMaintain.Open;
  if DM1.QryMaintain.RecordCount>0 then
  begin
    DM1.QryMaintain.First;
    StringGrid1.RowCount := DM1.QryMaintain.RecordCount;
  end;
  i := 0;
  While not DM1.QryMaintain.Eof do
  begin
    if RadioButton1.Checked then
    begin
      if GroupBoxVS.Caption='联系人分组表' then
      begin
        StringGrid1.Cells[0,i] := DM1.QryMaintain.FieldByname('组名').AsString;
        StringGrid1.Cells[1,i] := DM1.QryMaintain.FieldByname('组ID').AsString;
      end else if GroupBoxVS.Caption='公司人员表' then
      begin
        StringGrid1.Cells[0,i] := DM1.QryMaintain.FieldByname('名称').AsString;
        StringGrid1.Cells[1,i] := DM1.QryMaintain.FieldByname('公司ID').AsString;
      end;
    end else
    begin
      if GroupBoxVS.Caption='联系人分组表' then
      begin
        StringGrid1.Cells[0,i] := DM1.QryMaintain.FieldByname('姓名').AsString;
        StringGrid1.Cells[1,i] := DM1.QryMaintain.FieldByname('联系人ID').AsString;
      end else if GroupBoxVS.Caption='公司人员表' then
      begin
        StringGrid1.Cells[0,i] := DM1.QryMaintain.FieldByname('姓名').AsString;
        StringGrid1.Cells[1,i] := DM1.QryMaintain.FieldByname('联系人ID').AsString;
      end;
    end;
    DM1.QryMaintain.Next;
    Inc(i);
  end;
  DM1.QryMaintain.Close;

  ClearStringGrid2;
  if RadioButton1.Checked then sSQL := sSQLg else sSQL := sSQLp;
  DM1.QryMaintain.Close;
  DM1.QryMaintain.SQL.Text := sSQL;
  DM1.QryMaintain.Open;
  if DM1.QryMaintain.RecordCount>0 then
  begin
    DM1.QryMaintain.First;
    StringGrid2.RowCount := DM1.QryMaintain.RecordCount;
  end;
  i := 0;
  While not DM1.QryMaintain.Eof do
  begin
    if RadioButton1.Checked then
    begin
      if GroupBoxVS.Caption='联系人分组表' then
      begin
        StringGrid2.Cells[0,i] := DM1.QryMaintain.FieldByname('组名').AsString;
        StringGrid2.Cells[1,i] := DM1.QryMaintain.FieldByname('组ID').AsString;
      end else if GroupBoxVS.Caption='公司人员表' then
      begin
        StringGrid2.Cells[0,i] := DM1.QryMaintain.FieldByname('名称').AsString;
        StringGrid2.Cells[1,i] := DM1.QryMaintain.FieldByname('公司ID').AsString;
      end;
    end else
    begin
      if GroupBoxVS.Caption='联系人分组表' then
      begin
        StringGrid2.Cells[0,i] := DM1.QryMaintain.FieldByname('姓名').AsString;
        StringGrid2.Cells[1,i] := DM1.QryMaintain.FieldByname('联系人ID').AsString;
      end else if GroupBoxVS.Caption='公司人员表' then
      begin
        StringGrid2.Cells[0,i] := DM1.QryMaintain.FieldByname('姓名').AsString;
        StringGrid2.Cells[1,i] := DM1.QryMaintain.FieldByname('联系人ID').AsString;
      end;
    end;
    DM1.QryMaintain.Next;
    Inc(i);
  end;
  DM1.QryMaintain.Close;
end;

procedure TFrmMaintainVS.ClearStringGrid1;
begin
  StringGrid1.RowCount := 0;
  if StringGrid1.RowCount=1 then
  begin
    StringGrid1.Cells[0,0] :='';
    StringGrid1.Cells[1,0] :='';
  end;
end;

procedure TFrmMaintainVS.ClearStringGrid2;
begin
  StringGrid2.RowCount := 0;
  if StringGrid2.RowCount=1 then
  begin
    StringGrid2.Cells[0,0] :='';
    StringGrid2.Cells[1,0] :='';
  end;
end;

procedure TFrmMaintainVS.RadioButton1Click(Sender: TObject);
begin
  RefreshLabels;
  RefreshComboBox1;
  if ComboBox1.Items.Count>0 then ComboBox1.ItemIndex := 0;
  RefreshStringGrids;
end;

procedure TFrmMaintainVS.RadioButton2Click(Sender: TObject);
begin
  RefreshLabels;
  RefreshComboBox1;
  if ComboBox1.Items.Count>0 then ComboBox1.ItemIndex := 0;
  RefreshStringGrids
end;

procedure TFrmMaintainVS.ComboBox1Select(Sender: TObject);
begin
  RefreshStringGrids;
end;

procedure TFrmMaintainVS.StringGrid1DblClick(Sender: TObject);
var
  ScreenPt,ClientPt:TPOINT;
  c,r:integer;
  sSQL,sPID,sGID:string;
begin
  inherited;
  if ComboBox1.ItemIndex=-1 then
  begin
    Application.MessageBox('请选择左边下拉框!','注意');
    exit;
  end;
  if (StringGrid1.RowCount<1) then exit
  else if ((Length(StringGrid1.Cells[0,0])=0)and(Length(StringGrid1.Cells[1,0])=0)) then exit;
  GetCursorPos(ScreenPt);
  ClientPt := StringGrid1.ScreenToClient(ScreenPt);
  StringGrid1.MouseToCell(ClientPt.X, ClientPt.Y, c, r);
  if (c<0)or(r<0) then exit;

  if Length(StringGrid1.Cells[1,r])>0 then
  begin
    if GroupBoxVS.Caption='联系人分组表' then
    begin
      if RadioButton1.Checked then
      begin
        sPID := RightStr(ComboBox1.Text,20);
        sGID := StringGrid1.Cells[1,r];
      end else
      begin
        sGID := RightStr(ComboBox1.Text,20);
        sPID := StringGrid1.Cells[1,r];
      end;
      sSQL := ' Delete from 联系人分组表'
             +' Where (组ID=''' + sGID + ''')and(联系人ID='''+ sPID + ''')';
      DM1.QryMaintain.Close;
      DM1.QryMaintain.SQL.Text := sSQL;
      DM1.QryMaintain.ExecSQL;
      DM1.QryMaintain.Close;
    end else if GroupBoxVS.Caption='公司人员表' then
    begin
      if RadioButton1.Checked then
      begin
        sPID := RightStr(ComboBox1.Text,20);
        sGID := StringGrid1.Cells[1,r];
      end else
      begin
        sGID := RightStr(ComboBox1.Text,20);
        sPID := StringGrid1.Cells[1,r];
      end;
      sSQL := ' Delete from 公司人员表'
             +' Where (公司ID='''+ sGID + ''')and(联系人ID=''' + sPID + ''')';
      DM1.QryMaintain.Close;
      DM1.QryMaintain.SQL.Text := sSQL;
      DM1.QryMaintain.ExecSQL;
      DM1.QryMaintain.Close;
    end;
    RefreshStringGrids;
    RefreshDBGrid1;
  end;
end;

procedure TFrmMaintainVS.StringGrid2DblClick(Sender: TObject);
var
  ScreenPt,ClientPt:TPOINT;
  c,r:integer;
  sSQL,sPID,sGID:string;
begin
  inherited;
  if ComboBox1.ItemIndex=-1 then
  begin
    Application.MessageBox('请选择左边下拉框!','注意');
    exit;
  end;
  if (StringGrid2.RowCount<1) then exit
  else if ((Length(StringGrid2.Cells[0,0])=0)and(Length(StringGrid2.Cells[1,0])=0)) then exit;
  GetCursorPos(ScreenPt);
  ClientPt := StringGrid2.ScreenToClient(ScreenPt);
  StringGrid2.MouseToCell(ClientPt.X, ClientPt.Y, c, r);
  if (c<0)or(r<0) then exit;

  if Length(StringGrid2.Cells[1,r])>0 then
  begin
    if GroupBoxVS.Caption='联系人分组表' then
    begin
      if RadioButton1.Checked then
      begin
        sPID := RightStr(ComboBox1.Text,20);
        sGID := StringGrid2.Cells[1,r];
      end else
      begin
        sGID := RightStr(ComboBox1.Text,20);
        sPID := StringGrid2.Cells[1,r];
      end;
      sSQL := ' Insert into 联系人分组表(组ID,联系人ID)'
             +' Values('+ '''' + sGID + ''''+ ',' + '''' + sPID + '''' + ')';
      DM1.QryMaintain.Close;
      DM1.QryMaintain.SQL.Text := sSQL;
      DM1.QryMaintain.ExecSQL;
      DM1.QryMaintain.Close;
    end else if GroupBoxVS.Caption='公司人员表' then
    begin
      if RadioButton1.Checked then
      begin
        sPID := RightStr(ComboBox1.Text,20);
        sGID := StringGrid2.Cells[1,r];
      end else
      begin
        sGID := RightStr(ComboBox1.Text,20);
        sPID := StringGrid2.Cells[1,r];
      end;
      sSQL := ' Insert into 公司人员表(公司ID,联系人ID)'
             +' Values('+ '''' + sGID + ''''+ ',' + '''' + sPID + '''' + ')';
      DM1.QryMaintain.Close;
      DM1.QryMaintain.SQL.Text := sSQL;
      DM1.QryMaintain.ExecSQL;
      DM1.QryMaintain.Close;
    end;
    RefreshStringGrids;
    RefreshDBGrid1;
  end;
end;

procedure TFrmMaintainVS.SpeedButton3Click(Sender: TObject);
begin
  RefreshDBGrid1;
end;

procedure TFrmMaintainVS.Button1Click(Sender: TObject);
begin
  Close;
end;

end.

⌨️ 快捷键说明

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