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 static string Insert(string name, string surname, string gender, DateTime dob, string document_type, string document_number, string address, string phone, string email) { DClient Obj = new DClient(); Obj.Name = name; Obj.Surname = surname; Obj.Gender = gender; Obj.Dob = dob; Obj.TypeDocument = document_type; Obj.DocumentNumber = document_number; Obj.Address = address; Obj.Phone = phone; Obj.Email = email; return(Obj.Insert(Obj)); }