티스토리 뷰
/*
void Treeview_Load(String text_name) // 트리뷰에 들어갈 데이터베이스를 로드한다.
{
treeView1.Nodes.Clear();
SQLiteCommand cmdDataBase = new SQLiteCommand("select DISTINCT line from factory where layout_name='" + text_name + "';", cn);
cn.Open();
SQLiteDataReader dr = cmdDataBase.ExecuteReader();
try
{
while (dr.Read())
{
String temp;
int count = 0;
TreeNode node = new TreeNode(dr["line"].ToString());
temp = dr["line"].ToString();
// MessageBox.Show("1");
SQLiteCommand cmdDataBase2 = new SQLiteCommand("select DISTINCT block from factory where layout_name='" + text_name + "' and line = '" + temp + "';", cn);
SQLiteDataReader dr2 = cmdDataBase2.ExecuteReader();
while (dr2.Read())
{
String temp2;
temp2 = dr2["block"].ToString();
//MessageBox.Show("2");
node.Nodes.Add(temp2);
SQLiteCommand cmdDataBase3 = new SQLiteCommand("select DISTINCT robot from factory where layout_name='" + text_name + "' and line = '" + temp + "' and block = '" + temp2 + "';", cn);
SQLiteDataReader dr3 = cmdDataBase3.ExecuteReader();
while (dr3.Read())
{
//MessageBox.Show("3");
node.Nodes[count].Nodes.Add(dr3["robot"].ToString());
}
count++;
}
treeView1.Nodes.Add(node);
treeView1.ExpandAll();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
cn.Close();
}
*/
트리뷰만들기2 업그레이드
private void Treeview_Load() // 트리뷰에 들어갈 데이터베이스를 로드한다.
{
treeView1.Nodes.Clear();
SQLiteCommand cmdDataBase = new SQLiteCommand("select DISTINCT line from factory where layout_name='" + this.comboBox1.Text + "';", cn);
cn.Open();
SQLiteDataReader dr = cmdDataBase.ExecuteReader();
try
{
while (dr.Read())
{
String temp;
int count = 0; //블록 카운트
int count2 = 0; //로봇 카운트 --> 트리뷰 부품 파트 보이게 하려면 주석 해제
TreeNode node = new TreeNode(dr["line"].ToString());
temp = dr["line"].ToString();
// MessageBox.Show("1");
SQLiteCommand cmdDataBase2 = new SQLiteCommand("select DISTINCT block from factory where layout_name='" + this.comboBox1.Text + "' and line = '" + temp + "';", cn);
SQLiteDataReader dr2 = cmdDataBase2.ExecuteReader();
while (dr2.Read())
{
String temp2;
temp2 = dr2["block"].ToString();
//MessageBox.Show("2");
node.Nodes.Add(temp2);
SQLiteCommand cmdDataBase3 = new SQLiteCommand("select DISTINCT robot from factory where layout_name='" + this.comboBox1.Text + "' and line = '" + temp + "' and block = '" + temp2 + "';", cn);
SQLiteDataReader dr3 = cmdDataBase3.ExecuteReader();
while (dr3.Read())
{
string temp3;
temp3 = dr3["robot"].ToString();
//// 트리뷰 부품 파트
SQLiteCommand cmdDataBase4 = new SQLiteCommand("select DISTINCT part from factory where layout_name='" + this.comboBox1.Text + "' and line = '" + temp + "' and block = '" + temp2 + "' and robot ='" + temp3 + "';", cn);
SQLiteDataReader dr4 = cmdDataBase4.ExecuteReader();
while (dr4.Read())
{
node.Nodes[count].Nodes.Add(dr3["robot"].ToString() + "- 부품명: " + dr4["part"].ToString());
}
count2++;
}
count++;
}
treeView1.Nodes.Add(node);
treeView1.ExpandAll();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
cn.Close();
}