public FormModifyJuridicPerson(DataValidation dataValidation, JuridicPersonTypeEnum type, JuridicPersonDTO juridicPerson) : base(dataValidation, type) { InitializeComponent(); this.juridicPerson = juridicPerson; this.enterDataCompany(juridicPerson); if (type == JuridicPersonTypeEnum.Client) { this.Text = "Modificar cliente"; } else if (type == JuridicPersonTypeEnum.Provider) { this.Text = "Modificar proveedor"; } this.bAccept.Text = "Modificar"; }
public FormJuridicPersons(DataValidation dataValidation, JuridicPersonTypeEnum type) { this.dataValidation = dataValidation; InitializeComponent(); this.dgvJuridicPersons.AutoGenerateColumns = false; this.juridicPersonType = type; if (type == JuridicPersonTypeEnum.Client) { this.Text = "Clientes"; } else if (type == JuridicPersonTypeEnum.Provider) { this.Text = "Proveedores"; } this.refreshJuridicPersons(); }
public FormAddJuridicPerson(DataValidation dataValidation, JuridicPersonTypeEnum juridicPersonType) { this.dataValidation = dataValidation; this.juridicPersonType = juridicPersonType; InitializeComponent(); if (juridicPersonType == JuridicPersonTypeEnum.Client) { this.nudAccountCode.Value = this.dataValidation.selectAccountCodeAvailable(AccountRangeTemplatesEnum.CREDITOS_COMERCIALES, (int)FormSelectCompany.selectedCompanyId); } else if (juridicPersonType == JuridicPersonTypeEnum.Provider) { this.nudAccountCode.Value = this.dataValidation.selectAccountCodeAvailable(AccountRangeTemplatesEnum.DEUDAS_COMERCIALES, (int)FormSelectCompany.selectedCompanyId); } this.cbLocation.DataSource = dataValidation.getLocations(); this.cbDocumentType.DataSource = dataValidation.getDocumentTypes(); this.cbConditionRegardingVat.DataSource = dataValidation.getConditionRegardingVats(); this.validationsJuridicPerson = new Dictionary<Control, ErrorProvider>(); this.validationsJuridicPerson.Add(tbBusinessName, epJuridicPerson); this.validationsJuridicPerson.Add(tbDocument, epJuridicPerson); this.validationsJuridicPerson.Add(cbDocumentType, epJuridicPerson); this.validationsJuridicPerson.Add(cbLocation, epJuridicPerson); this.validationsJuridicPerson.Add(cbConditionRegardingVat, epJuridicPerson); this.validationsJuridicPerson.Add(nudZipCode, epJuridicPerson); this.validationsJuridicPerson.Add(tbPhone, epJuridicPerson); this.validationsJuridicPerson.Add(tbAddress, epJuridicPerson); string juridicPersonTitle = null; if (juridicPersonType == JuridicPersonTypeEnum.Client) juridicPersonTitle = "cliente"; else if (juridicPersonType == JuridicPersonTypeEnum.Provider) juridicPersonTitle = "proveedor"; this.Text = "Registrar nuevo " + juridicPersonTitle; }
public List<JuridicPersonDTO> selectJuridicPersonsByName(JuridicPersonTypeEnum type, string name) { return this.data.selectJuridicPersonByName(type, name); }
public List<JuridicPersonDTO> selectJuridicPersonByName(JuridicPersonTypeEnum type, string name) { StringBuilder query = new StringBuilder(); query.AppendLine("SELECT JP.Id, BusinessName, JPT.Id TypeId, JPT.Type, DT.Id DocumentTypeId, DT.Type DocumentType, Document, CompanyId, LocationId, L.Name Location, ConditionRegardingVatId, CRV.Name ConditionRegardingVat, Phone, ZipCode, Address, AccountId, A.Code AccountCode FROM JuridicPersons JP"); query.AppendLine("INNER JOIN Accounts A ON A.Id = JP.AccountId"); query.AppendLine("INNER JOIN JuridicPersonType JPT ON JPT.Id = JP.JuridicPersonTypeId"); query.AppendLine("INNER JOIN DocumentType DT ON DT.Id = JP.DocumentTypeId"); query.AppendLine("INNER JOIN Locations L ON L.Id = JP.LocationId"); query.AppendLine("INNER JOIN ConditionRegardingVat CRV ON CRV.Id = JP.ConditionRegardingVatId"); query.AppendLine("WHERE JPT.Id = @typeId AND (@name IS NULL OR @name = '' OR CHARINDEX(@name, BusinessName) > 0);"); SqlCommand command = new SqlCommand(query.ToString(), this.conection); command.CommandType = System.Data.CommandType.Text; command.Parameters.AddWithValue("@typeId", (int)type); command.Parameters.AddWithValue("@name", name); List<JuridicPersonDTO> juridicPersons = new List<JuridicPersonDTO>(); try { this.conection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { JuridicPersonDTO juridicPerson = new JuridicPersonDTO( (int)reader["Id"], reader["BusinessName"].ToString(), new JuridicPersonTypeDTO((int)reader["TypeId"], reader["Type"].ToString()), new DocumentTypeDTO((int)reader["DocumentTypeId"], reader["DocumentType"].ToString()), (long)reader["Document"], (int)reader["CompanyId"], new LocationDTO((int)reader["LocationId"], reader["Location"].ToString()), new ConditionRegardingVatDTO((int)reader["ConditionRegardingVatId"], reader["ConditionRegardingVat"].ToString()), reader["Phone"].ToString(), (int)reader["ZipCode"], new AccountDTO((int)reader["AccountId"], (int)reader["AccountCode"]), reader["Address"].ToString()); juridicPersons.Add(juridicPerson); } } } } finally { if (this.conection.State == ConnectionState.Open) this.conection.Close(); } return juridicPersons; }