示例#1
0
        /// <summary>
        /// 将收货地址设置为默认
        /// </summary>
        /// <param name="remarks"></param>
        /// <returns></returns>
        public bool SetDefault(string remarks = null)
        {
            BeginTransaction();
            //set the specific address to default address
            Tnet_Shipping_Address daAddress = new Tnet_Shipping_Address();

            daAddress.ReferenceTransactionFrom(Transaction);
            if (!daAddress.SelectByPk(_addressId))
            {
                Rollback();
                Alert("收货地址不存在");
                return(false);
            }
            //first of all, set all address default property to false
            Tnet_Shipping_AddressCollection daShippingUpdate = new Tnet_Shipping_AddressCollection();

            daShippingUpdate.ReferenceTransactionFrom(Transaction);
            if (!daShippingUpdate.ListDefaultAddress(daAddress.Owner_Id, (Address_Owner_Type)daAddress.Owner_Type))
            {
                Rollback();
                Alert("系统异常");
                return(false);
            }
            int rowCount = daShippingUpdate.Count;

            if (rowCount > 0)
            {
                if (!daShippingUpdate.UpdateAllAddressNotDefault(daAddress.Owner_Id, (Address_Owner_Type)daAddress.Owner_Type, rowCount))
                {
                    Rollback();
                    Alert("更新默认地址失败");
                    return(false);
                }
            }
            if (!daAddress.SetDefault(_addressId))
            {
                Rollback();
                Alert("设置默认地址失败");
                return(false);
            }
            Commit();
            return(true);
        }
示例#2
0
 public bool SetDefault()
 {
     BeginTransaction();
     //first of all, set all address default property to false
     Tnet_Shipping_AddressCollection daShippingUpdate = new Tnet_Shipping_AddressCollection();
     daShippingUpdate.ReferenceTransactionFrom(Transaction);
     if (!daShippingUpdate.ListDefaultAddress(_address.User_Id, Address_Owner_Type.个人用户))
     {
         Rollback();
         Alert("系统异常");
         return false;
     }
     int rowCount = daShippingUpdate.Count;
     if (rowCount > 0)
     {
         if (!daShippingUpdate.UpdateAllAddressNotDefault(_address.User_Id, Address_Owner_Type.个人用户, rowCount))
         {
             Rollback();
             Alert("更新默认地址失败");
             return false;
         }
     }
     //set the specific address to default address
     Tnet_Shipping_Address daAddress = new Tnet_Shipping_Address();
     daAddress.ReferenceTransactionFrom(Transaction);
     daAddress.Is_Default = 1;
     daAddress.Address_Id = _address.Address_Id;
     if (daAddress.Update())
     {
         Rollback();
         Alert("设置默认地址失败");
         return false;
     }
     Commit();
     return true;
 }