public EClient Insert(EClient eClient) { EClient eResult = null; BSequence bSequence = new BSequence(); ESequence eSequence = new ESequence(eClient); int correlative = 0; eClient.SearchName = ProcessSearchName(eClient); correlative = bSequence.GetCorrelative(eSequence); eClient.CodeClient = correlative; eClient.Validar(); dClient.Insert(eClient); if (dClient.ExistsPrimaryKey()) { Message = string.Format("El código de Cliente '{0}' ya existe en el Sistema, no se puede crear el registro.", eClient.CodeClient); throw new Exception(Message); } if (dClient.ExistsReference()) { Message = string.Format("El código de Empresa '{0}' no existe en el Sistema, no se puede crear el registro.", eClient.CodeClient); throw new Exception(Message); } correlative++; eSequence.Correlative = correlative; bSequence.SetCorrelativo(eSequence); eResult = Select(eClient); eClient.Audit.Code = eResult.CodeClient.ToString(); eClient.Audit.TypeEvent = "Insert"; bAudit.Insert(eClient.Audit); return(eResult); }
public EClient Update(EClient eClient) { EClient eResult; eClient.SearchName = ProcessSearchName(eClient); eClient.Validar(); dClient.Update(eClient); eClient.Audit.TypeEvent = "Update"; bAudit.Insert(eClient.Audit); eResult = Select(eClient); return(eResult); }