C# 如果不需要,如何禁用可启用警报(关键级别) void DisplayLowQuantityItems() { SqlCommand=new SqlCommand(“从轮胎中选择品牌,其中数量
取一个C# 如果不需要,如何禁用可启用警报(关键级别) void DisplayLowQuantityItems() { SqlCommand=new SqlCommand(“从轮胎中选择品牌,其中数量,c#,C#,取一个计数器变量,并在循环中递增 void DisplayLowQuantityItems() { SqlCommand command = new SqlCommand ("Select Brand from Tires where Quantity <5",con); con.Open(); SqlDataReader reader = command.ExecuteReader(); StringBuilder productNames= new St
计数器
变量,并在循环中递增
void DisplayLowQuantityItems()
{
SqlCommand command = new SqlCommand ("Select Brand from Tires where Quantity <5",con);
con.Open();
SqlDataReader reader = command.ExecuteReader();
StringBuilder productNames= new StringBuilder();
while(reader.Read())
{
productNames.Append(reader["Brand"].ToString()+Environment.NewLine);
}
con.Close();
MessageBox.Show("Following Products quantity is lessthan 5\n"+productNames);
}
int计数器=0;
while(reader.Read())
{
productNames.Append(读卡器[“品牌”].ToString()+环境.NewLine);
计数器++;
}
如果(计数器<代码>无效显示LowQuantityItems()
{
SqlCommand=new SqlCommand(“从数量使用计数器的轮胎中选择品牌,将其设置为0,并在<代码>中递增,同时<代码>,循环。在显示<代码>消息框代码>之前的代码末尾,使用复选框,<代码>如果(计数器<5))
@adv12,productNames
是一个StringBuilder
,我不知道如何计算,我想,OP必须拆分,然后检查长度或长度something@Habib,哦,我略读了。对不起!//做些事情……请说清楚,我应该把MessageBox放在哪里?是的,,,这里你可以放MessageBox,但是……我的问题仍然不是答案回答“如果不需要,如何禁用可启用警报”bro,如果您的记录超过5条,它将不会被查看我替换了if(是的,哇,我发布此消息已经太久了。因此它的计数==0不是耶。现在它可以禁用了
int counter=0;
while(reader.Read())
{
productNames.Append(reader["Brand"].ToString()+Environment.NewLine);
counter++;
}
if(counter<5)
MessageBox.Show("Following Products quantity is lessthan 5\n"+productNames);
DataTable dt = new DataTable();
dt.Load(reader);
con.close();
if (dt.Rows.Count < 5)
{
//do stuff
}
void DisplayLowQuantityItems()
{
SqlCommand command = new SqlCommand ("Select Brand from Tires where Quantity <5",con);
con.Open();
SqlDataReader reader = command.ExecuteReader();
StringBuilder productNames= new StringBuilder();
DataTable dt=new DataTable();
dt.Load(reader);
con.Close();
if(dt.Rows.Count>=5)
{
productNames.Append(reader["Brand"].ToString()+Environment.NewLine);
}
else
{
MessageBox.Show("Following Products quantity is lessthan 5\n"+productNames);
}
}
void DisplayLowQuantityItems()
{
SqlCommand command = new SqlCommand ("Select Brand from Tires where Quantity <5",con);
con.Open();
SqlDataReader reader = command.ExecuteReader();
StringBuilder productNames= new StringBuilder();
int count = 0;
while(reader.Read())
{
productNames.Append(reader["Brand"].ToString()+Environment.NewLine);
count++;
}
con.Close();
if (count == 0)
{
//leave it blank
}
else
{
MessageBox.Show("Following Products quantity is lessthan 5\n"+productNames);
}
}