Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ECAMSDataAccess.StoreAreaModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update StoreArea set ");
            strSql.Append("StoreAreaCode=@StoreAreaCode,");
            strSql.Append("StoreAreaName=@StoreAreaName,");
            strSql.Append("StoreAreaType=@StoreAreaType,");
            strSql.Append("StoreAreaDescribe=@StoreAreaDescribe,");
            strSql.Append("StoreAreaSign=@StoreAreaSign,");
            strSql.Append("StoreHouseID=@StoreHouseID");
            strSql.Append(" where StoreAreaID=@StoreAreaID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@StoreAreaCode",     SqlDbType.NVarChar, 50),
                new SqlParameter("@StoreAreaName",     SqlDbType.NVarChar, 50),
                new SqlParameter("@StoreAreaType",     SqlDbType.NVarChar, 50),
                new SqlParameter("@StoreAreaDescribe", SqlDbType.NVarChar, 50),
                new SqlParameter("@StoreAreaSign",     SqlDbType.Int,       4),
                new SqlParameter("@StoreHouseID",      SqlDbType.Int,       4),
                new SqlParameter("@StoreAreaID",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.StoreAreaCode;
            parameters[1].Value = model.StoreAreaName;
            parameters[2].Value = model.StoreAreaType;
            parameters[3].Value = model.StoreAreaDescribe;
            parameters[4].Value = model.StoreAreaSign;
            parameters[5].Value = model.StoreHouseID;
            parameters[6].Value = model.StoreAreaID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ECAMSDataAccess.StoreAreaModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into StoreArea(");
            strSql.Append("StoreAreaCode,StoreAreaName,StoreAreaType,StoreAreaDescribe,StoreAreaSign,StoreHouseID)");
            strSql.Append(" values (");
            strSql.Append("@StoreAreaCode,@StoreAreaName,@StoreAreaType,@StoreAreaDescribe,@StoreAreaSign,@StoreHouseID)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@StoreAreaCode",     SqlDbType.NVarChar, 50),
                new SqlParameter("@StoreAreaName",     SqlDbType.NVarChar, 50),
                new SqlParameter("@StoreAreaType",     SqlDbType.NVarChar, 50),
                new SqlParameter("@StoreAreaDescribe", SqlDbType.NVarChar, 50),
                new SqlParameter("@StoreAreaSign",     SqlDbType.Int,       4),
                new SqlParameter("@StoreHouseID",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.StoreAreaCode;
            parameters[1].Value = model.StoreAreaName;
            parameters[2].Value = model.StoreAreaType;
            parameters[3].Value = model.StoreAreaDescribe;
            parameters[4].Value = model.StoreAreaSign;
            parameters[5].Value = model.StoreHouseID;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ECAMSDataAccess.StoreAreaModel DataRowToModel(DataRow row)
 {
     ECAMSDataAccess.StoreAreaModel model = new ECAMSDataAccess.StoreAreaModel();
     if (row != null)
     {
         if (row["StoreAreaID"] != null && row["StoreAreaID"].ToString() != "")
         {
             model.StoreAreaID = int.Parse(row["StoreAreaID"].ToString());
         }
         if (row["StoreAreaCode"] != null)
         {
             model.StoreAreaCode = row["StoreAreaCode"].ToString();
         }
         if (row["StoreAreaName"] != null)
         {
             model.StoreAreaName = row["StoreAreaName"].ToString();
         }
         if (row["StoreAreaType"] != null)
         {
             model.StoreAreaType = row["StoreAreaType"].ToString();
         }
         if (row["StoreAreaDescribe"] != null)
         {
             model.StoreAreaDescribe = row["StoreAreaDescribe"].ToString();
         }
         if (row["StoreAreaSign"] != null && row["StoreAreaSign"].ToString() != "")
         {
             model.StoreAreaSign = int.Parse(row["StoreAreaSign"].ToString());
         }
         if (row["StoreHouseID"] != null && row["StoreHouseID"].ToString() != "")
         {
             model.StoreHouseID = int.Parse(row["StoreHouseID"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ECAMSDataAccess.StoreAreaModel GetModel(int StoreAreaID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 StoreAreaID,StoreAreaCode,StoreAreaName,StoreAreaType,StoreAreaDescribe,StoreAreaSign,StoreHouseID from StoreArea ");
            strSql.Append(" where StoreAreaID=@StoreAreaID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@StoreAreaID", SqlDbType.Int, 4)
            };
            parameters[0].Value = StoreAreaID;

            ECAMSDataAccess.StoreAreaModel model = new ECAMSDataAccess.StoreAreaModel();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }