private void show355BDpic0()
{
string tempShelve_no = "";
string tempFS="";
try
{
conn = new OracleConnection(ConnectionString);
conn.Open();
OracleDataAdapter da = new OracleDataAdapter(String.Format("SELECT Shelve_no,Flag_State FROM T_GJ_Shelve Where Shelve_no like '01A%' Order by Shelve_no"), conn);
ds = new DataSet();
da.Fill(ds, "01A_KW");
da.Dispose();
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
tempShelve_no = ds.Tables["01A_KW"].Rows[i]["Shelve_no"].ToString();
tempFS = ds.Tables["01A_KW"].Rows[i]["Flag_State"].ToString();
string controlBtnName = "btn_" + tempShelve_no;
foreach (Control kj_1 in this.Controls)
{
if (kj_1 is GroupBox)
{
foreach (Control kj_2 in kj_1.Controls)
{
if (kj_2 is Button)
{
bool flag2;
flag2 = kj_2.Name.Equals(controlBtnName, StringComparison.CurrentCultureIgnoreCase);
switch (tempFS)
{
case "0": //空闲未锁定
if (flag2)
((Button)kj_2).BackColor = Color.White; //白色
break;
case "1": //空闲锁定
if (flag2)
((Button)kj_2).BackColor = Color.FromArgb(255, 192, 192); //浅红
break;
case "2": //占用未锁定
if (flag2)
{
((Button)kj_2).BackgroundImage = ToolsManagement.Properties.Resources.BreakDownT;
((Button)kj_2).BackgroundImageLayout = ImageLayout.Stretch;
//((Button)kj_2).BackColor = Color.FromArgb(128, 128, 255); //浅蓝
}
break;
case "3": //占用锁定
if (flag2)
{
((Button)kj_2).BackgroundImage = ToolsManagement.Properties.Resources.BreakDownT;
((Button)kj_2).BackgroundImageLayout = ImageLayout.Stretch;
((Button)kj_2).BackColor = Color.FromArgb(255, 192, 192); //浅红
//((Button)kj_2).BackColor = Color.FromArgb(255, 255, 192); //浅黄
}
break;
}
}
}
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
conn.Close();
conn.Dispose();
ds.Dispose();
}
}
((Button)kj_2).BackgroundImage = ToolsManagement.Properties.Resources.BreakDownT的实现:将Button的imagine属性设置成从项目资源中导入,这时图片便在项目的Properties.Resources中。BreakDownT的.ico文件可用.ico转化器将其它图片转化成.ico图片。