private void btnLimpiar_Click(object sender, EventArgs e) { txNroDoc.Clear(); lblAyudaPA.Visible = false; //MtxRutCliente.Clear(); MtxRutDeudor.Clear(); cboxTDoc.SelectedIndex = cboxTDoc.FindStringExact("Seleccione..."); lblSide.Visible = false; lbResultado.Visible = false; lblNroDoc.Visible = false; txNroDoc.Visible = false; lblRutDeudor.Visible = false; MtxRutDeudor.Visible = false; //lblRutDeudor.Text = "Ingrese Rut Deudor:"; }
private void MtxRutDeudor_Leave(object sender, EventArgs e) { Boolean bdeudor = true; String RutDeudor = MtxRutDeudor.Text; RutDeudor = RutDeudor.Replace(",", ""); Valida oVal = new Valida(); bdeudor = oVal.Rut(RutDeudor); if (bdeudor == false && RutDeudor != " -") { MessageBox.Show("No es un rut valido, ingrese nuevamente"); MtxRutDeudor.Clear(); MtxRutDeudor.Focus(); } }
private void btnBuscar_Click(object sender, EventArgs e) { ConsultaDocumento oConsulta = new ConsultaDocumento(); StringBuilder sERROR = new StringBuilder(); String Resultado = String.Empty; bool err = false; String RutDeudor = MtxRutDeudor.Text; int Ndoc = 0; String TDoc = String.Empty; ////switch (caseSwitch) ////{ //// case 1: //// Console.WriteLine("Case 1"); //// break; //// case 2: //// Console.WriteLine("Case 2"); //// break; //// default: //// Console.WriteLine("Default case"); //// break; ////} try { //String str = MtxRutDeudor.Text; RutDeudor = RutDeudor.Replace(",", ""); //str = str.Replace("-", ""); RutDeudor = RutDeudor.Replace(" ", ""); if (string.IsNullOrEmpty(RutDeudor) || RutDeudor == "-") { if (cboxTDoc.Text == "PA" || cboxTDoc.Text == "LE") { sERROR.Append("*Debes ingresar el rut del Cliente"); sERROR.AppendLine(); } else { sERROR.Append("*Debes ingresar el rut del deudor"); sERROR.AppendLine(); } err = true; MtxRutDeudor.Focus(); } //int number = 0; if (string.IsNullOrEmpty(this.txNroDoc.Text)) { if (cboxTDoc.Text != "LE" && cboxTDoc.Text != "PA") { sERROR.Append("*Debes ingresar un numero de documento"); sERROR.AppendLine(); err = true; } } else { //String RutDeudor = txRutDeudor.Text; if (txNroDoc.Text != "") { Ndoc = int.Parse(txNroDoc.Text); } ////elimina comas de los rut //RutDeudor = RutDeudor.Replace(",", ""); } if (cboxTDoc.Text == "Seleccione...") { sERROR.Append("*Debes Seleccionar el tipo de documento"); sERROR.AppendLine(); err = true; } else { TDoc = cboxTDoc.Text.ToString(); } if (err == true) { String Errores = sERROR.ToString(); MessageBox.Show(Errores); } //int Ndoc = number; //String RutCli = txRutCliente.Text; //String RutCli = MtxRutCliente.Text; //RutCli = RutCli.Replace(",", ""); //valida rut //bool bCliente = oVal.Rut(RutCli); // bool bdeudor = oVal.Rut(RutDeudor); //if(bdeudor == true){ if ((RutDeudor != " -") && (Ndoc != 0)) { if (TDoc != "Seleccione..." && TDoc != "") { if ((Ndoc != 0)) { if (TDoc == "FA" || TDoc == "FE") { lblSide.Visible = true; lbResultado.Visible = true; //lbResultado.Text = (oConsulta.ConsultaDoc(RutDeudor, Ndoc, RutCli, TDoc)).ToString(); String responseDOC = (oConsulta.ConsultaFactura(RutDeudor, Ndoc, TDoc)).ToString(); if (responseDOC == "") { lbResultado.Text = Ndoc.ToString(); } else { lbResultado.Text = responseDOC; } } } } } if (TDoc == "LE" && RutDeudor != " -") /* || TDoc == "FE")*/ { lblSide.Visible = true; lbResultado.Visible = true; //lbResultado.Text = (oConsulta.ConsultaDoc(RutDeudor, Ndoc, RutCli, TDoc)).ToString(); String responseLE = (oConsulta.ConsultaLetras(RutDeudor)).ToString(); ///RutDeudor aca funciona cmo rut cliente if (responseLE == "") { lbResultado.Text = "1"; } else { lbResultado.Text = responseLE; } } if (TDoc == "PA" && RutDeudor != " -") { if (RutDeudor != "-") { lblSide.Visible = true; lbResultado.Visible = true; //lbResultado.Text = (oConsulta.ConsultaDoc(RutDeudor, Ndoc, RutCli, TDoc)).ToString(); String responsePA = (oConsulta.ConsultaPagare(RutDeudor)).ToString(); if (responsePA == "") { lbResultado.Text = "1"; } else { lbResultado.Text = responsePA; lblAyudaPA.Visible = true; lblAyudaPA.Text = "El valor debe ser: " + responsePA + "+NumeroCuotas3digitos" + "\r\n" + "Ejemplo: " + responsePA + "001"; } ///RutDeudor aca funciona cmo rut cliente } } } catch (Exception p) { String Error = p.Message.ToString(); MessageBox.Show("Ha ocurrido un error inesperado: " + Error); } }