/// <summary> /// 删除授权商品记录 /// </summary> /// <param name="id">授权ID</param> /// <returns>大于0成功,否则失败</returns> /// <remarks> /// <list type="bullet"> /// <item></item> /// </list> /// </remarks> public int Delete(string authProductIds, int connectorId) { ClearCache(); int val = 0; StringBuilder sb = new StringBuilder(); if (string.IsNullOrEmpty(authProductIds)) { return(-1); } //检查信息是否存在 string sql = string.Format("select count(0) from {0} where ConnectorId={1} and Id in ({2})", TableName, connectorId, authProductIds); DataTable dt = DbAccess.GetDataTable(sql); if (dt == null || Utils.ToInt(dt.Rows[0][0]) == 0) { return(-1); } string[] ids = authProductIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string authId in ids) { int id = Utils.ToInt(authId); if (id > 0) { AuthProductEntity ent = (AuthProductEntity) new AuthProductBusiness().GetEntity("Id=" + id + " and ConnectorId=" + connectorId); if (ent != null && Utils.ToInt(ent.Id) > 0) { sb.AppendLine(DbAccess.Provider.DeleteCommandText(ent, TableName)); } } } val = DbService.ExecuteNonQuery(sb.ToString()); return(val); }
/// <summary> /// 插入授权商品信息 /// </summary> /// <returns>大于0成功,否则失败</returns> /// <remarks> /// <list type="bullet"> /// </list> /// </remarks> public int Insert(string productIds, int connectorId) { ClearCache(); int val = 0; StringBuilder sb = new StringBuilder(); if (string.IsNullOrEmpty(productIds)) { return(-1); } //检查信息是否存在 string sql = string.Format("select count(0) from {0} where ConnectorId={1} and ProductId in ({2})", TableName, connectorId, productIds); DataTable dt = DbAccess.GetDataTable(sql); if (Utils.ToInt(dt.Rows[0][0]) != 0) { return(-1); } string[] ids = productIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string productId in ids) { int id = Utils.ToInt(productId); if (id > 0) { AuthProductEntity ent = new AuthProductEntity(); ent.ConnectorId = connectorId; ent.ProductId = id; ent.Status = 1; ent.AddTime = DateTime.Now; ent.UpdateTime = DateTime.Now; sb.AppendLine(DbAccess.Provider.InsertCommandText(ent, TableName)); } } val = DbService.ExecuteNonQuery(sb.ToString()); return(val); }