Ejemplo n.º 1
0
 /// <summary>
 /// 调用存储过程增加一个
 /// </summary>
 /// <param name="info">实体对象</param>
 /// <returns>正常返回大于 0 的自增id, 0代表重复,否则返回-1</returns>
 public static int ProvinceAdd(Entity.Province info)
 {
     SqlParameter[] prams =
     {
         SqlDB.MakeInParam("@ProvinceName",   SqlDbType.NVarChar, 50, info.ProvinceName),
         SqlDB.MakeInParam("@ProvincePinYin", SqlDbType.NVarChar, 50, info.ProvincePinYin),
         SqlDB.MakeInParam("@ProvinceCode",   SqlDbType.NVarChar, 50, info.ProvinceCode),
         SqlDB.MakeInParam("@AdminCode",      SqlDbType.NVarChar, 50, info.AdminCode),
     };
     return(Basic.Utils.StrToInt(SqlDB.ExecuteScalar(CommandType.StoredProcedure, "ProvinceAdd", prams).ToString(), -1));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取某一个实体
        /// </summary>
        /// <param name="ProvinceID">标识</param>
        /// <returns>返回Entity</returns>
        public static Entity.Province ProvinceEntityGet(int ProvinceID)
        {
            Entity.Province info = new Entity.Province();
            DataTable       dt   = SqlDB.ExecuteDataset(CommandType.Text, "SELECT * FROM [Province] WHERE ProvinceID = " + ProvinceID + ";").Tables[0];

            if (dt.Rows.Count > 0)
            {
                info.ProvinceID   = Basic.Utils.StrToInt(dt.Rows[0]["ProvinceID"].ToString(), 0);
                info.ProvinceName = dt.Rows[0]["ProvinceName"].ToString();

                return(info);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 调用存储过程修改一个
        /// </summary>
        /// <param name="info">实体对象</param>
        /// <returns>更新成功返回ture,否则返回false</returns>
        public static bool ProvinceEdit(Entity.Province info)
        {
            SqlParameter[] prams =
            {
                SqlDB.MakeInParam("@ProvinceID",     SqlDbType.Int,       4, info.ProvinceID),
                SqlDB.MakeInParam("@ProvinceName",   SqlDbType.NVarChar, 50, info.ProvinceName),
                SqlDB.MakeInParam("@ProvincePinYin", SqlDbType.NVarChar, 50, info.ProvincePinYin),
                SqlDB.MakeInParam("@ProvinceCode",   SqlDbType.NVarChar, 50, info.ProvinceCode),
                SqlDB.MakeInParam("@AdminCode",      SqlDbType.NVarChar, 50, info.AdminCode),
            };
            int intReturnValue = 0;

            intReturnValue = SqlDB.ExecuteNonQuery(CommandType.StoredProcedure, "ProvinceEdit", prams);
            if (intReturnValue == 1)
            {
                return(true);
            }
            return(false);
        }