private bool checkcount() //判断数量中是否存在负数,以确定是否要开清单
{
SqlConnection con=new SqlConnection("server=localhost;database=ufdata-excel;uid=sa;pwd=luohzh");
SqlDataAdapter com=new SqlDataAdapter(strsql,con);
DataSet dsmul_count=new DataSet();
com.Fill(dsmul_count,"mult_table_count");
this.dataGrid1.DataSource=dsmul_count.Tables[0].DefaultView;
int crowscount=dsmul_count.Tables[0].Rows.Count;
int aaa;
if (crowscount>1)
{
for (int i=0;i<crowscount;i++)
{
aaa=int.Parse(this.dataGrid1[i,3].ToString());
if (aaa<=0)
{ this.btnpritqd.Enabled=false;
MessageBox.Show("发货数量中存在负数,请先开发票后再开清单!","出错信息",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
this.textBox1.Focus();
return false;}
}
}请赐教......
{
SqlConnection con=new SqlConnection("server=localhost;database=ufdata-excel;uid=sa;pwd=luohzh");
SqlDataAdapter com=new SqlDataAdapter(strsql,con);
DataSet dsmul_count=new DataSet();
com.Fill(dsmul_count,"mult_table_count");
this.dataGrid1.DataSource=dsmul_count.Tables[0].DefaultView;
int crowscount=dsmul_count.Tables[0].Rows.Count;
int aaa;
if (crowscount>1)
{
for (int i=0;i<crowscount;i++)
{
aaa=int.Parse(this.dataGrid1[i,3].ToString());
if (aaa<=0)
{ this.btnpritqd.Enabled=false;
MessageBox.Show("发货数量中存在负数,请先开发票后再开清单!","出错信息",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
this.textBox1.Focus();
return false;}
}
}请赐教......
解决方案 »
- 使用foreach遍历自定义可枚举类型的时候为什么并不要求自定义类型实现 IEnumerable和IEnumerator?
- 如何用WEB方式打开网络共享文件夹
- 实现对TabControl的良好控制
- 请帮帮忙,C#实现数据导入的完整程序
- SQL2005新增的varchar(max)数据类型,在C#的SqlParameter如何表示?
- 类类型作为方法的参数时,使用 ref 和不使用ref的区别?..请高手解答,顶都有分
- 初始化失败怎么解决?
- 如何打印窗体指定的区域??如用RECTANGLE指定,用打印机打出来!!
- 非托管代码(delphi等)是否可以利用托管代码(c#)导出的类?
- 改动dataGrid,最后更新到数据库的问题!
- 特菜问题,如何随Form的改变,内部控件自动调整大小?
- 请教如何在C#或者其他.net里面使用OWC~那里可以找到资料或者Sample?
应该没个分支都有返回直,如:
if(..)
{
...
return false;
}
return true;
{
SqlConnection con=new SqlConnection("server=localhost;database=ufdata-excel;uid=sa;pwd=luohzh");
SqlDataAdapter com=new SqlDataAdapter(strsql,con);
DataSet dsmul_count=new DataSet();
com.Fill(dsmul_count,"mult_table_count");
this.dataGrid1.DataSource=dsmul_count.Tables[0].DefaultView;
int crowscount=dsmul_count.Tables[0].Rows.Count;
int aaa;
if (crowscount>1)
{
for (int i=0;i<crowscount;i++)
{
aaa=int.Parse(this.dataGrid1[i,3].ToString());
if (aaa<=0)
{
this.btnpritqd.Enabled=false;
MessageBox.Show("发货数量中存在负数,请先发票后再开清单!","出错信息",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
this.textBox1.Focus();
return false;
}
else {return true;}
}
}
}
老兄们加了else的返回值结果还是一样?
why?
你的问题可以简单描述成这样:if (crowscount>1)
{
if (aaa<=0)
{ return false;}
else
{ return ture;}
}显然当(crowscount>1)不成立时,还是没有返回的.