Exemplo n.º 1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <NetWeightAdjustmentEntity> DataTableToList(DataTable dt)
        {
            List <NetWeightAdjustmentEntity> modelList = new List <NetWeightAdjustmentEntity>( );
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                NetWeightAdjustmentEntity model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new NetWeightAdjustmentEntity( );
                    if (dt.Rows[n]["ItemID"] != null && dt.Rows[n]["ItemID"].ToString( ) != "")
                    {
                        model.ItemID = int.Parse(dt.Rows[n]["ItemID"].ToString( ));
                    }
                    if (dt.Rows[n]["LocalProductName"] != null && dt.Rows[n]["LocalProductName"].ToString( ) != "")
                    {
                        model.LocalProductName = dt.Rows[n]["LocalProductName"].ToString( );
                    }
                    if (dt.Rows[n]["AdjustRatio"] != null && dt.Rows[n]["AdjustRatio"].ToString( ) != "")
                    {
                        model.AdjustRatio = decimal.Parse(dt.Rows[n]["AdjustRatio"].ToString( ));
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(NetWeightAdjustmentEntity model)
        {
            StringBuilder strSql = new StringBuilder( );

            strSql.Append("insert into T_NetWeightAdjustment(");
            strSql.Append("LocalProductName,AdjustRatio)");
            strSql.Append(" values (");
            strSql.Append("@LocalProductName,@AdjustRatio)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@LocalProductName", SqlDbType.VarChar, 50),
                new SqlParameter("@AdjustRatio",      SqlDbType.Decimal, 9)
            };
            parameters[0].Value = model.LocalProductName;
            parameters[1].Value = model.AdjustRatio;

            object obj = SqlHelper.GetSingle(SqlHelper.LocalSqlServer, strSql.ToString( ), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(NetWeightAdjustmentEntity model)
        {
            StringBuilder strSql = new StringBuilder( );

            strSql.Append("update T_NetWeightAdjustment set ");
            strSql.Append("LocalProductName=@LocalProductName,");
            strSql.Append("AdjustRatio=@AdjustRatio");
            strSql.Append(" where ItemID=@ItemID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@LocalProductName", SqlDbType.VarChar, 50),
                new SqlParameter("@AdjustRatio",      SqlDbType.Decimal,  9),
                new SqlParameter("@ItemID",           SqlDbType.Int, 4)
            };
            parameters[0].Value = model.LocalProductName;
            parameters[1].Value = model.AdjustRatio;
            parameters[2].Value = model.ItemID;

            int rows = SqlHelper.ExecuteSql(SqlHelper.LocalSqlServer, strSql.ToString( ), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public NetWeightAdjustmentEntity GetModel(int ItemID)
        {
            StringBuilder strSql = new StringBuilder( );

            strSql.Append("select  top 1 ItemID,LocalProductName,AdjustRatio from T_NetWeightAdjustment ");
            strSql.Append(" where ItemID=@ItemID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ItemID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ItemID;

            NetWeightAdjustmentEntity model = new NetWeightAdjustmentEntity( );
            DataSet ds = SqlHelper.Query(SqlHelper.LocalSqlServer, strSql.ToString( ), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ItemID"] != null && ds.Tables[0].Rows[0]["ItemID"].ToString( ) != "")
                {
                    model.ItemID = int.Parse(ds.Tables[0].Rows[0]["ItemID"].ToString( ));
                }
                if (ds.Tables[0].Rows[0]["LocalProductName"] != null && ds.Tables[0].Rows[0]["LocalProductName"].ToString( ) != "")
                {
                    model.LocalProductName = ds.Tables[0].Rows[0]["LocalProductName"].ToString( );
                }
                if (ds.Tables[0].Rows[0]["AdjustRatio"] != null && ds.Tables[0].Rows[0]["AdjustRatio"].ToString( ) != "")
                {
                    model.AdjustRatio = decimal.Parse(ds.Tables[0].Rows[0]["AdjustRatio"].ToString( ));
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(NetWeightAdjustmentEntity model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(NetWeightAdjustmentEntity model)
 {
     return(dal.Add(model));
 }