using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
namespace PhoneBook
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
private string strConn = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
private void frmMain_Load(object sender, EventArgs e)
{
LoadGroup();
if (trvGroup.Nodes.Count > 0)
{
trvGroup.SelectedNode = trvGroup.Nodes[0];
LoadList();
}
else
{
lvContact.Clear();
}
}
private void LoadGroup()
{
try
{
trvGroup.Nodes.Clear();
SqlConnection conn = new SqlConnection(strConn);
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "select distinct 组别 from 联系人 where 用户名='"+tsslUserName.Text+"'";
conn.Open();
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
trvGroup.Nodes.Add(sdr[0].ToString());
}
sdr.Close();
conn.Close();
}
catch
{ }
}
private void LoadList()
{
if (trvGroup.Nodes.Count == 0)
{
lvContact.Clear();
return;
}
if (trvGroup.SelectedNode.Index >= 0)
{
string strGroup = trvGroup.SelectedNode.Text;
try
{
lvContact.Clear();
lvContact.Columns.Add("姓名",100);
lvContact.Columns.Add("工作
2019-12-21 21:57:58
1.54MB
C#
管理系统
1