/// <summary> /// 设置实体 /// </summary> /// <param name="entity">实体</param> private void SetEntity(SQLBuilder sqlBuilder, BaseContactTargetEntity entity) { sqlBuilder.SetValue(BaseContactTargetEntity.FieldContactId, entity.ContactId); sqlBuilder.SetValue(BaseContactTargetEntity.FieldCategory, entity.Category); sqlBuilder.SetValue(BaseContactTargetEntity.FieldReceiverId, entity.ReceiverId); sqlBuilder.SetValue(BaseContactTargetEntity.FieldReceiverRealName, entity.ReceiverRealName); }
/// <summary> /// 更新实体 /// </summary> /// <param name="entity">实体</param> public int UpdateEntity(BaseContactTargetEntity entity) { SQLBuilder sqlBuilder = new SQLBuilder(DbHelper); sqlBuilder.BeginUpdate(BaseContactTargetEntity.TableName); this.SetEntity(sqlBuilder, entity); sqlBuilder.SetWhere(BaseContactTargetEntity.FieldId, entity.Id); return(sqlBuilder.EndUpdate()); }
public void AddCompany(string contactId, string companyId) { BaseContactTargetEntity entity = new BaseContactTargetEntity(); entity.Id = Guid.NewGuid().ToString("N"); entity.ContactId = contactId; entity.Category = "Company"; entity.ReceiverId = companyId; entity.ReceiverRealName = BaseOrganizeManager.GetNameByCache(companyId); this.Add(entity); }
/// <summary> /// 联络单可以按省看? /// </summary> /// <param name="contactId">联络单主键</param> /// <param name="areaId">省份主键</param> /// <returns>影响行数</returns> public void AddArea(string contactId, string areaId) { BaseContactTargetEntity entity = new BaseContactTargetEntity(); entity.Id = Guid.NewGuid().ToString("N"); entity.ContactId = contactId; entity.Category = "Area"; entity.ReceiverId = areaId; entity.ReceiverRealName = BaseAreaManager.GetNameByByCache(areaId); this.Add(entity); }
/// <summary> /// 添加实体 /// </summary> /// <param name="entity">实体</param> public string AddEntity(BaseContactTargetEntity entity) { string sequence = string.Empty; sequence = entity.Id; SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId); sqlBuilder.BeginInsert(BaseContactTargetEntity.TableName, BaseContactTargetEntity.FieldId); if (entity.Id is string) { this.Identity = false; } if (!this.Identity) { sqlBuilder.SetValue(BaseContactTargetEntity.FieldId, entity.Id); } else { if (!this.ReturnId && DbHelper.CurrentDbType == CurrentDbType.Oracle) { sqlBuilder.SetFormula(BaseContactTargetEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL "); } else { if (this.Identity && DbHelper.CurrentDbType == CurrentDbType.Oracle) { if (string.IsNullOrEmpty(sequence)) { BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity); sequence = sequenceManager.Increment(this.CurrentTableName); } entity.Id = sequence; sqlBuilder.SetValue(BaseContactTargetEntity.FieldId, entity.Id); } } } this.SetEntity(sqlBuilder, entity); if (UserInfo != null) { sqlBuilder.SetValue(BaseContactTargetEntity.FieldCreateUserId, UserInfo.Id); sqlBuilder.SetValue(BaseContactTargetEntity.FieldCreateBy, UserInfo.RealName); } sqlBuilder.SetDBNow(BaseContactTargetEntity.FieldCreateOn); if (DbHelper.CurrentDbType == CurrentDbType.SqlServer && this.Identity) { sequence = sqlBuilder.EndInsert().ToString(); } else { sqlBuilder.EndInsert(); } return(sequence); }
/// <summary> /// 添加 /// </summary> /// <param name="entity">实体</param> /// <returns>主键</returns> public string Add(BaseContactTargetEntity entity) { return(this.AddEntity(entity)); }
/// <summary> /// 获取实体 /// </summary> /// <param name="id">主键</param> public BaseContactTargetEntity GetEntity(string id) { BaseContactTargetEntity baseContactTargetEntity = new BaseContactTargetEntity(this.GetDataTableById(id)); return(baseContactTargetEntity); }
/// <summary> /// 更新 /// </summary> /// <param name="entity">实体</param> public int Update(BaseContactTargetEntity entity) { return(this.UpdateEntity(entity)); }
/// <summary> /// 添加 /// </summary> /// <param name="entity">实体</param> /// <param name="identity">自增量方式</param> /// <returns>主键</returns> public string Add(BaseContactTargetEntity entity, bool identity) { this.Identity = identity; return(this.AddEntity(entity)); }