private void BuscarCliente(string Numero) { if (Numero.Length == 8 || Numero.Length == 11) { if (fn.Existencia("*", "Cliente", "Numero='" + Numero + "'") == true) { clienteEncontrado(Numero); } else { if (Numero.Length == 8) { frmBuscarDni FRM = new frmBuscarDni(); frmBuscarDni.DNI = Numero; FRM.ShowDialog(); if (FRM.existe == true) { txtnumero.Text = FRM.txt_dni.Text; if (Numero != "") { if (fn.Existencia("Numero", "Cliente", "Numero='" + Numero + "'") == true) { clienteEncontrado(Numero); } } } } else if (Numero.Length == 11) { frmBuscarRuc FRM = new frmBuscarRuc(); FRM.txtruc.Text = txtnumero.Text; FRM.ShowDialog(); txtnumero.Text = FRM.txtruc.Text; if (Numero != "") { if (fn.Existencia("Numero", "Cliente", "Numero='" + Numero + "'") == true) { clienteEncontrado(Numero); } } } } } else { MessageBox.Show("Numero de identificación incorrecto", "FactuTED", MessageBoxButtons.OK, MessageBoxIcon.Information); txtnumero.Focus(); } }
private void BuscarCliente(string Numero) { try { if (Numero.Length == 8 || Numero.Length == 11 || Numero == "0") { //VERIFICAMOS EXISTENCIA DEL CLIENTE if (fn.Existencia("*", "Cliente", "Numero='" + Numero + "'") == true) { txtCliente.Text = fn.select_one_value("Nombre", "Cliente", "Numero='" + Numero + "'", 0); } //SI NO EXISTE - REGISTRAMOS else { if (Numero.Length == 8) { frmBuscarDni FRM = new frmBuscarDni(); frmBuscarDni.ConTeclado = true; frmBuscarDni.DNI = Numero; txtNroDocumento.Clear(); txtCliente.Text = "CLIENTES VARIOS"; FRM.ShowDialog(); if (FRM.existe == true) { txtNroDocumento.Text = FRM.txt_dni.Text; if (Numero != "") { if (fn.Existencia("Numero", "Cliente", "Numero='" + txtNroDocumento.Text + "'") == true) { txtCliente.Text = fn.select_one_value("Nombre", "Cliente", "Numero='" + txtNroDocumento.Text + "'", 0); } } } } //SUNAT else if (Numero.Length == 11) { try { while (noExisteRegistre() == false) { DialogResult msj = MessageBox.Show("Error Consulta Sunat. Verificar R.U.C. Desea Reintentar?", "FactuTED", MessageBoxButtons.RetryCancel); if (msj == DialogResult.Retry) { noExisteRegistre(); } else if (msj == DialogResult.Cancel) { break; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "FactuTED", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (fn.Existencia("Numero", "Cliente", "Numero='" + Numero + "'") == true) { txtCliente.Text = fn.select_one_value("Nombre", "Cliente", "Numero='" + Numero + "'", 0); } } } } else { _frmMesaje.lblmensaje.Text = "NUMERO DE DOCUMENTO INCORRECTO"; _frmMesaje.ShowDialog(); txtNroDocumento.Text = "0"; txtCliente.Text = "CLIENTES VARIOS"; } } catch (Exception ex) { MessageBox.Show(ex.Message, "FactuTED", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }