这两段代码,谁能帮忙祥细解释一下,看不懂
private bool isNumber(string s){
int Flag = 0;
char[] str = s.ToCharArray();
for (int i = 0; i < str.Length; i++)
{
if (Char.IsNumber(str[i]))
{
Flag++;
}
else
{
Flag = -1;
break;
}
}
if (Flag > 0)
{
return true;
}
else
{
return false;
}
}
public void saveGoods(AddGoods _Add)
{
string sql = "";
sql = sql + "insert into SMS_Goods(GoodsID,GoodsName,StoreName,SupName,SpecName,UnitName,GoodsNum,GoodsPrice,GoodsAPrice,GoodsPeople,GoodsRemarks) values (@GoodsID,@GoodsName,@StoreName,@SupName,@SpecName,@UnitName,@GoodsNum,@GoodsPrice,@GoodsAPrice,@GoodsPeople,@GoodsRemarks)";
SqlCom = new SqlCommand(sql,Dconn.OpenConn());
Mysda = new SqlDataAdapter();
Mysda.SelectCommand = SqlCom;
SqlCom.Parameters.Add("@GoodsID", SqlDbType.VarChar, 20, "GoodsID").Value = _Add.GoodsID;
SqlCom.Parameters.Add("@GoodsName", SqlDbType.VarChar, 50, "GoodsName").Value = _Add.GoodsName;
SqlCom.Parameters.Add("@StoreName", SqlDbType.VarChar, 50, "StoreName").Value = _Add.StoreName;
SqlCom.Parameters.Add("@SupName", SqlDbType.VarChar, 50, "SupName").Value = _Add.SupName;
SqlCom.Parameters.Add("@UnitName", SqlDbType.VarChar, 10, "UnitName").Value = _Add.UnitName;
SqlCom.Parameters.Add("@GoodsNum", SqlDbType.Int, 4, "GoodsNum").Value = _Add.GoodsNum;
SqlCom.Parameters.Add("@SpecName", SqlDbType.VarChar, 50, "SpecName").Value = _Add.SpecName;
SqlCom.Parameters.Add("@GoodsPrice", SqlDbType.Float, 10, "GoodsPrice").Value = _Add.GoodsPrice;
SqlCom.Parameters.Add("@GoodsAPrice", SqlDbType.Float, 10, "GoodsAPrice").Value = _Add.GoodsAPrice;
SqlCom.Parameters.Add("@GoodsPeople", SqlDbType.VarChar, 20, "GoodsPeople").Value = _Add.GoodsPeople;
SqlCom.Parameters.Add("@GoodsRemarks", SqlDbType.VarChar, 50, "GoodsRemarks").Value = _Add.GoodsRemarks;
try
{
SqlCom.ExecuteNonQuery();
}
catch (Exception) { }
finally
{
Dconn.CloseConn();
}
}