📄 form1.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Collections;
using dist.hb.EnvQueryStat.Manage;
using dist.hb.EnvQueryStat.Query;
using dist.hb.EnvQueryStat;
using dist.hb.EnvQueryStat.Pub;
namespace dist.hb.EnvQueryStat
{
public partial class Form1 : Form
{
private OleDbConnection m_DbConn;
public Form1()
{
InitializeComponent();
string strConn = "Provider=SQLOLEDB;Data Source=dist-demo;Initial Catalog=hbPOP;"
+ "Integrated Security=SSPI";
strConn = GetDBConnParam();
m_DbConn = new OleDbConnection(strConn);
m_DbConn.Open();
}
private void btnSet_Click(object sender, EventArgs e)
{
frmQSSet frm = new frmQSSet();
frm.OleDbConn = m_DbConn;
frm.ShowDialog(this);
}
private void gridControl1_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
{
}
private string GetDBConnParam()
{
string sFile = System.Windows.Forms.Application.StartupPath + "\\dbConn.txt";
// Create the new, empty data file.
if (!File.Exists(sFile)) return "";
using (StreamReader sr = new StreamReader(sFile))
{
string sTemp = sr.ReadLine();
sr.Close();
return sTemp;
}
return "";
}
private void btnQuery_Click(object sender, EventArgs e)
{
frmUnivQuery frm = new frmUnivQuery();
frm.OleDbConn = m_DbConn;
frm.QueryInstID = Convert.ToInt32(textBox1_QueryCode.Text);
frm.ShowDialog(this);
}
private void button1_Click(object sender, EventArgs e)
{
frmMain frm = new frmMain();
frm.ShowDialog(this);
}
private void btnTest_Click(object sender, EventArgs e)
{
frmSelectDictItem frm = new frmSelectDictItem();
frm.OleDbConn = m_DbConn;
frm.DICT = "select dm as code, mc as name from xt_codes where dmlx ='01' ";
frm.ShowDialog(this);
foreach (clsDictItem item in frm.m_array)
{
MessageBox.Show(item.strName);
}
}
private void button2_Click(object sender, EventArgs e)
{
System.Xml.XmlDocument document =
new System.Xml.XmlDataDocument();
document.Load("d://TreeNode.xml");
populateTreeControl(document.DocumentElement,
treeView1.Nodes);
}
private string WriteHtml(string sUserName, string sPwd, string sPostURL, string sDesURL)
{
string strHtmlFile = System.Windows.Forms.Application.StartupPath + "\\" + "post.html";
StreamWriter sw = new StreamWriter(strHtmlFile);
if (sw != null)
{
sw.WriteLine("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'>");
sw.WriteLine("<HTML>");
sw.WriteLine("<HEAD>");
sw.WriteLine("<TITLE> POST </TITLE>");
sw.WriteLine("</HEAD>");
sw.WriteLine("<BODY onload = 'javascript:PostForm.submit()'>");
sw.WriteLine("<FORM id='PostForm' METHOD=POST ACTION='" +sPostURL+"'>");
sw.WriteLine("<INPUT TYPE='hidden' NAME='Name' value='"+sUserName +"'>");
sw.WriteLine("<INPUT TYPE='hidden' NAME='Pwd' value='"+sPwd +"'>");
sw.WriteLine("<INPUT TYPE='hidden' NAME='URL' value='"+sDesURL +"'>");
sw.WriteLine("</FORM>");
sw.WriteLine("</BODY>");
sw.WriteLine("</HTML>");
}
sw.Close();
return strHtmlFile;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void populateTreeControl(System.Xml.XmlNode document, System.Windows.Forms.TreeNodeCollection nodes)
{
foreach (System.Xml.XmlNode node in document.ChildNodes)
{
// If the element has a value, display it;
// otherwise display the first attribute
// (if there is one) or the element name
// (if there isn't)
string text = (node.Value != null ? node.Value :
(node.Attributes != null &&
node.Attributes.Count > 0) ?
node.Attributes[0].Value : node.Name);
TreeNode new_child = new TreeNode(text);//在次增加其他的属性值
nodes.Add(new_child);
populateTreeControl(node, new_child.Nodes);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -