Beispiel #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ParcelTakeOutConditionEntity model)
        {
            StringBuilder strSql = new StringBuilder( );

            strSql.Append("insert into T_ParcelTakeOutCondition(");
            strSql.Append("ItemCode,ModelCode,LocalProductName,MinExportQTY)");
            strSql.Append(" values (");
            strSql.Append("@ItemCode,@ModelCode,@LocalProductName,@MinExportQTY)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ItemCode",         SqlDbType.VarChar, 50),
                new SqlParameter("@ModelCode",        SqlDbType.VarChar, 50),
                new SqlParameter("@LocalProductName", SqlDbType.VarChar, 50),
                new SqlParameter("@MinExportQTY",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.ItemCode;
            parameters[1].Value = model.ModelCode;
            parameters[2].Value = model.LocalProductName;
            parameters[3].Value = model.MinExportQTY;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ParcelTakeOutConditionEntity model)
        {
            StringBuilder strSql = new StringBuilder( );

            strSql.Append("update T_ParcelTakeOutCondition set ");
            strSql.Append("ItemCode=@ItemCode,");
            strSql.Append("ModelCode=@ModelCode,");
            strSql.Append("LocalProductName=@LocalProductName,");
            strSql.Append("MinExportQTY=@MinExportQTY");
            strSql.Append(" where ItemID=@ItemID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ItemCode",         SqlDbType.VarChar, 50),
                new SqlParameter("@ModelCode",        SqlDbType.VarChar, 50),
                new SqlParameter("@LocalProductName", SqlDbType.VarChar, 50),
                new SqlParameter("@MinExportQTY",     SqlDbType.Int,      4),
                new SqlParameter("@ItemID",           SqlDbType.Int, 4)
            };
            parameters[0].Value = model.ItemCode;
            parameters[1].Value = model.ModelCode;
            parameters[2].Value = model.LocalProductName;
            parameters[3].Value = model.MinExportQTY;
            parameters[4].Value = model.ItemID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ParcelTakeOutConditionEntity GetModel(int ItemID)
        {
            StringBuilder strSql = new StringBuilder( );

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

            ParcelTakeOutConditionEntity model = new ParcelTakeOutConditionEntity( );
            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]["ItemCode"] != null && ds.Tables[0].Rows[0]["ItemCode"].ToString( ) != "")
                {
                    model.ItemCode = ds.Tables[0].Rows[0]["ItemCode"].ToString( );
                }
                if (ds.Tables[0].Rows[0]["ModelCode"] != null && ds.Tables[0].Rows[0]["ModelCode"].ToString( ) != "")
                {
                    model.ModelCode = ds.Tables[0].Rows[0]["ModelCode"].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]["MinExportQTY"] != null && ds.Tables[0].Rows[0]["MinExportQTY"].ToString( ) != "")
                {
                    model.MinExportQTY = int.Parse(ds.Tables[0].Rows[0]["MinExportQTY"].ToString( ));
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <ParcelTakeOutConditionEntity> DataTableToList(DataTable dt)
        {
            List <ParcelTakeOutConditionEntity> modelList = new List <ParcelTakeOutConditionEntity>( );
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                ParcelTakeOutConditionEntity model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new ParcelTakeOutConditionEntity( );
                    if (dt.Rows[n]["ItemID"] != null && dt.Rows[n]["ItemID"].ToString( ) != "")
                    {
                        model.ItemID = int.Parse(dt.Rows[n]["ItemID"].ToString( ));
                    }
                    if (dt.Rows[n]["ItemCode"] != null && dt.Rows[n]["ItemCode"].ToString( ) != "")
                    {
                        model.ItemCode = dt.Rows[n]["ItemCode"].ToString( );
                    }
                    if (dt.Rows[n]["ModelCode"] != null && dt.Rows[n]["ModelCode"].ToString( ) != "")
                    {
                        model.ModelCode = dt.Rows[n]["ModelCode"].ToString( );
                    }
                    if (dt.Rows[n]["LocalProductName"] != null && dt.Rows[n]["LocalProductName"].ToString( ) != "")
                    {
                        model.LocalProductName = dt.Rows[n]["LocalProductName"].ToString( );
                    }
                    if (dt.Rows[n]["MinExportQTY"] != null && dt.Rows[n]["MinExportQTY"].ToString( ) != "")
                    {
                        model.MinExportQTY = int.Parse(dt.Rows[n]["MinExportQTY"].ToString( ));
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(ParcelTakeOutConditionEntity model)
 {
     return(dal.Update(model));
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(ParcelTakeOutConditionEntity model)
 {
     return(dal.Add(model));
 }