Exemple #1
0
 protected void btnGuardar_Click(object sender, EventArgs e)
 {
     if (this.lblMontoaRendir.Text == "0")
     {
         ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "Error", "alert('Monto a rendir est\x00e1 en cero');", true);
     }
     else
     {
         DataTable table = null;
         table = ConsultasEspecificas.VALIDADOCLIBERADOS(this.hiddCobranza.Value.ToString(), this.lblnrocomprobante.Text.ToString());
         if (((table.Rows.Count > 0) && (table != null)) && (table.Rows[0]["id_moneda"].ToString() == "5"))
         {
             long    num  = Convert.ToInt64(this.lblnrocomprobante.Text.ToString());
             decimal num2 = 0M;
             num2 = Convert.ToDecimal(table.Rows[0]["montoabono"].ToString());
             DataTable table2 = ConsultasEspecificas.TOTALESABONOS(this.hiddCobranza.Value.ToString(), num.ToString());
             if ((table2.Rows.Count > 0) && (table2 != null))
             {
                 decimal num3 = 0M;
                 if (string.IsNullOrEmpty(table2.Rows[0]["Montomch"].ToString()))
                 {
                     ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "Error", "alert('Falta ingresar documentos en Multicheque (MCH)');", true);
                     return;
                 }
                 num3 = Convert.ToDecimal(table2.Rows[0]["Montomch"].ToString());
                 if (num2 != num3)
                 {
                     ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "Error", "alert('Falta ingresar documentos en Multicheque (MCH)');", true);
                     return;
                 }
             }
             if ((table.Rows[0]["MCH"].ToString() != "S") && (table.Rows[0]["estado"].ToString() != "L"))
             {
                 ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "Error", "alert('Debe liberar documentos antes de rendir');", true);
                 return;
             }
             if (table.Rows[0]["MCH"].ToString() == "S")
             {
                 DataTable table3 = null;
                 table3 = ConsultasEspecificas.VALIDADOCLIBERADOSMCH(this.hiddCobranza.Value.ToString());
                 if ((table3.Rows.Count > 0) && (table3 != null))
                 {
                     ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "Error", "alert('Debe liberar documentos antes de rendir');", true);
                     return;
                 }
             }
         }
         if (this.lblMontoaRendir.Text == "0")
         {
             ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "Error", "alert('Monto a rendir est\x00e1 en cero');", true);
         }
         else
         {
             int    num4         = 0;
             string swmonto      = null;
             string swInteres    = null;
             string swGastos     = null;
             string str4         = null;
             string swhonorarios = null;
             string str6         = null;
             string str7         = null;
             string str8         = null;
             if ((this.chkMonto.Checked || (this.lblMonto.Text == "0")) || (this.chkMonto.Text == "Rendido"))
             {
                 swmonto = "S";
                 num4++;
             }
             if ((this.chkIntereses.Checked || (this.lblIntereses.Text == "0")) || (this.chkIntereses.Text == "Rendido"))
             {
                 swInteres = "S";
                 num4++;
             }
             if ((this.chkGastos.Checked || (this.lblGastos.Text == "0")) || (this.chkGastos.Text == "Rendido"))
             {
                 swGastos = "S";
                 num4++;
             }
             if ((this.chkInteresAdicional.Checked || (this.lblInteresAdicional.Text == "0")) || (this.chkInteresAdicional.Text == "Rendido"))
             {
                 str4 = "S";
                 num4++;
             }
             if ((this.chkHonorarios.Checked || (this.lblHonorarios.Text == "0")) || (this.chkHonorarios.Text == "Rendido"))
             {
                 swhonorarios = "S";
                 num4++;
             }
             if ((this.chkDescHonorarios.Checked || (this.lblDescHonorarios.Text == "0")) || (this.chkDescHonorarios.Text == "Rendido"))
             {
                 str6 = "S";
                 num4++;
             }
             if ((this.chkOtrosDescuentos.Checked || (this.lblOtrosDescuentos.Text == "0")) || (this.chkOtrosDescuentos.Text == "Rendido"))
             {
                 str7 = "S";
                 num4++;
             }
             if ((this.chkDescInteres.Checked || (this.lblDescInteres.Text == "0")) || (this.chkDescInteres.Text == "Rendido"))
             {
                 str8 = "S";
                 num4++;
             }
             Transaccion.ActualizarRendicionAbonos(this.hddIdAbono.Value.ToString(), this.hiddCobranza.Value.ToString(), swmonto, swInteres, swGastos, str4, swhonorarios, str6, str8, str7, (long)num4);
             DataTable table4 = null;
             table4 = Transaccion.InsRendicion(this.hddIdAbono.Value.ToString(), this.hiddCobranza.Value.ToString(), this.lblMontoaRendir.Text.ToString(), this.Session["Usuario"].ToString());
             string str10 = "";
             if ((table4.Rows.Count > 0) && (table4 != null))
             {
                 str10 = "ComprobanteRendicion.aspx?id_Rendicion=" + table4.Rows[0][0].ToString().ToString();
             }
             this.CargaGrilla(this.hiddCobranza.Value.ToString());
             string str11 = "DetalleRendicion.aspx?id_abono=" + this.hddIdAbono.Value.ToString() + "&id_cobranza=" + this.hiddCobranza.Value.ToString() + "&nrooperacion=" + this.hddnrooperacion.Value.ToString() + "&rutdeudor=" + this.hddrutdeudor.Value.ToString() + "&nomdeudor=" + this.hddnomdeudor.Value.ToString() + "&nrocomprobante=" + this.hddnrocomprobante.Value.ToString() + "&nomcliente=" + this.hddnomcliente.Value.ToString() + "&montoabono=" + this.hddmontoabono.Value.ToString();
             this.Page.RegisterClientScriptBlock("Mensaje", "<script>alert('Datos guardados correctamente');location.href='" + str11.ToString() + "';</script>");
         }
     }
 }