private void formMain_Load(object sender, EventArgs e) { var cert = Wsd.GetCertificate(); if (cert == null) { MessageBox.Show("Debe configurar un certificado digital para utilizar la aplicación."); } string cn = cert.Subject.Replace("CN=", ""); string[] tokens = cn.Split('-'); string nifCandidate = tokens[1].Replace("CIF", "").Replace("NIF", "").Trim(); if (tokens.Length > 1 && nifCandidate.Length == 9) { txTitularPartyName.Text = tokens[0].Trim(); txTitularTaxIdentificationNumber.Text = tokens[1].Replace("CIF", "").Replace("NIF", "").Trim(); } Inizialize(); grdIva.Rows.Add(4, null, null); grdIva.Rows.Add(10, 100, 10); grdIva.Rows.Add(21, 100, 21); }
private void formMain_Load(object sender, EventArgs e) { _TextBoxes = new List<Control>(); GetTextBoxes(this, _TextBoxes); var cert = Wsd.GetCertificate(); if (cert == null) { MessageBox.Show("Debe configurar un certificado digital para utilizar la aplicación."); } string cn = cert.Subject.Replace("CN=", ""); string[] tokens = cn.Split('-'); string nifCandidate = tokens[1].Replace("CIF", "").Replace("NIF", "").Trim(); if (tokens.Length > 1 && nifCandidate.Length==9) { txEmisorPartyName.Text = tokens[0].Trim(); txEmisorTaxIdentificationNumber.Text = tokens[1].Replace("CIF","").Replace("NIF","").Trim(); } Inizialize(); }
public void ObtCertificadoDigital(ref string NIFEmpresa, ref string NomEmpresa) { var cert = Wsd.GetCertificate(); if (cert == null) { string _msg = "Debe configurar un certificado digital para utilizar la aplicación."; MessageBox.Show(_msg, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (cert.Subject.StartsWith("CN=")) { string cn = cert.Subject.Replace("CN=", ""); string[] tokens = cn.Split('-'); string nifCandidate = tokens[1].Replace("CIF", "").Replace("NIF", "").Trim(); if (tokens.Length > 1 && nifCandidate.Length == 9) { NomEmpresa = tokens[0].Trim(); NIFEmpresa = tokens[1].Replace("CIF", "").Replace("NIF", "").Trim(); } } else { string[] tokens = cert.Subject.Split(','); string nifCandidate = tokens[2].Replace("OID.2.5.4.97=VATES-", "").Trim(); if (tokens.Length > 1 && nifCandidate.Length == 9) { NomEmpresa = tokens[1].Replace("O=", "").Trim(); NIFEmpresa = nifCandidate; } } }