private bool theSwitch; //主窗体加载开关,只有数据库连接可用才开启 private void FrmStart_Hst_Load(object sender, EventArgs e) { DataBase_Hst DBCheck_Hst = new DataBase_Hst(); DBCheck_Hst.SqlCon_Hst(); //调用数据库连接方法 if (DBCheck_Hst.conCheck_Hst()) //调用连接检查方法 { str_Hst[2] = "连接可用.."; str_Hst[3] = "正在进入"; theSwitch = true; DBCheck_Hst.SqlDisCon_Hst(); } else { str_Hst[2] = "连接不可用.."; str_Hst[3] = "请检查后重试"; theSwitch = false; } theSwitch = true; str_Hst[0] = "正在加载资源文件.."; str_Hst[1] = "正在检查数据库连接..."; timer1_Hst.Interval = 4500; timer1_Hst.Enabled = true; timer2_Hst.Interval = 1000; timer2_Hst.Enabled = true; }
private void FrmQuery_Hst_Load(object sender, EventArgs e) { DB_Hst.SqlCon_Hst(); //连接数据库 DB_Hst.SqlDataSet_Hst(); //调用函数将数据库中数据填充进入DataSet类对象中 dataGridView_Hst.DataSource = DB_Hst.SqlDS_Hst.Tables[0]; for (int i_Hst = 0; i_Hst < DB_Hst.SqlDS_Hst.Tables[0].Columns.Count; i_Hst++) { comboBox_Hst.Items.Add(DB_Hst.SqlDS_Hst.Tables[0].Columns[i_Hst].ToString()); } comboBox_Hst.DropDownStyle = ComboBoxStyle.DropDownList; }
private void FrmUpdate_Hst_Load(object sender, EventArgs e) //窗体加载事件 { CancelOperation_Hst.Visible = false; //设置各控件属性 comboBox_Hst.DropDownStyle = ComboBoxStyle.DropDownList; txtName_Hst.ReadOnly = true; txtAge_Hst.ReadOnly = true; buttonFindPic_Hst.Enabled = false; radioButtonFemale_Hst.Enabled = false; radioButtonMale_Hst.Enabled = false; DB_Hst = new DataBase_Hst(); //实例化数据库操作对象 DB_Hst.SqlCon_Hst(); ReLoadComoBox(); comboBox_Hst.Text = comboBox_Hst.Items[0].ToString(); pictureBox_Hst.SizeMode = PictureBoxSizeMode.StretchImage; //设置图像显示方式 }