Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(lgk.Model.tb_province model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_province set ");
            strSql.Append("id=@id,");
            strSql.Append("provinceID=@provinceID,");
            strSql.Append("province=@province");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",         SqlDbType.Int,      4),
                new SqlParameter("@provinceID", SqlDbType.NVarChar, 6),
                new SqlParameter("@province",   SqlDbType.NVarChar, 40)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.provinceID;
            parameters[2].Value = model.province;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(lgk.Model.tb_province model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_province(");
            strSql.Append("id,provinceID,province)");
            strSql.Append(" values (");
            strSql.Append("@id,@provinceID,@province)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",         SqlDbType.Int,      4),
                new SqlParameter("@provinceID", SqlDbType.NVarChar, 6),
                new SqlParameter("@province",   SqlDbType.NVarChar, 40)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.provinceID;
            parameters[2].Value = model.province;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Example #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public lgk.Model.tb_province GetModel(string strWhere)
        {
            //该表无主键信息,请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1 id,provinceID,province,provinceen from tb_province ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }

            lgk.Model.tb_province model = new lgk.Model.tb_province();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["provinceID"] != null && ds.Tables[0].Rows[0]["provinceID"].ToString() != "")
                {
                    model.provinceID = ds.Tables[0].Rows[0]["provinceID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["province"] != null && ds.Tables[0].Rows[0]["province"].ToString() != "")
                {
                    model.province = ds.Tables[0].Rows[0]["province"].ToString();
                }
                if (ds.Tables[0].Rows[0]["provinceen"] != null && ds.Tables[0].Rows[0]["provinceen"].ToString() != "")
                {
                    model.provinceen = ds.Tables[0].Rows[0]["provinceen"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }