Example #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LPWeb.Model.RegionExecutives GetModel(int RegionId, int ExecutiveId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 RegionId,ExecutiveId from RegionExecutives ");
            strSql.Append(" where RegionId=@RegionId and ExecutiveId=@ExecutiveId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RegionId",    SqlDbType.Int, 4),
                new SqlParameter("@ExecutiveId", SqlDbType.Int, 4)
            };
            parameters[0].Value = RegionId;
            parameters[1].Value = ExecutiveId;

            LPWeb.Model.RegionExecutives model = new LPWeb.Model.RegionExecutives();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["RegionId"].ToString() != "")
                {
                    model.RegionId = int.Parse(ds.Tables[0].Rows[0]["RegionId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ExecutiveId"].ToString() != "")
                {
                    model.ExecutiveId = int.Parse(ds.Tables[0].Rows[0]["ExecutiveId"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(LPWeb.Model.RegionExecutives model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update RegionExecutives set ");
            strSql.Append("RegionId=@RegionId,");
            strSql.Append("ExecutiveId=@ExecutiveId");
            strSql.Append(" where RegionId=@RegionId and ExecutiveId=@ExecutiveId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RegionId",    SqlDbType.Int, 4),
                new SqlParameter("@ExecutiveId", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.RegionId;
            parameters[1].Value = model.ExecutiveId;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Example #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(LPWeb.Model.RegionExecutives model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into RegionExecutives(");
            strSql.Append("RegionId,ExecutiveId)");
            strSql.Append(" values (");
            strSql.Append("@RegionId,@ExecutiveId)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RegionId",    SqlDbType.Int, 4),
                new SqlParameter("@ExecutiveId", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.RegionId;
            parameters[1].Value = model.ExecutiveId;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }