| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1629 人关注过本帖
标题:这两段代码,谁能帮忙祥细解释一下,看不懂
只看楼主 加入收藏
lukebc
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:3
帖 子:74
专家分:32
注 册:2009-8-18
结帖率:71.43%
收藏
已结贴  问题点数:14 回复次数:1 
这两段代码,谁能帮忙祥细解释一下,看不懂
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();
            }
        }
搜索更多相关主题的帖子: private return 
2016-09-05 15:52
stave_7
Rank: 4
等 级:业余侠客
威 望:1
帖 子:36
专家分:227
注 册:2016-6-3
收藏
得分:14 
第一个判断字符串中是否有数字
第二个就是插入数据库呗

学习是大事
2016-09-05 16:14
快速回复:这两段代码,谁能帮忙祥细解释一下,看不懂
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.057974 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved