Exemplo n.º 1
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            // ----------------------------------------------------------------------------------
            ALCSA.Negocio.Cobranzas.Cobranza objCobranza = new ALCSA.Negocio.Cobranzas.Cobranza(this.txtNoperacion.Text, this.cliente.SelectedValue);
            if (objCobranza.ID > 0)
            {
                this.Page.RegisterClientScriptBlock("Mensaje", "<script>alert('N\x00b0 de operaci\x00f3n ya se encuentra registrado para ese cliente');</script>");
                this.txtNoperacion.Focus();
                return;
            }

            objCobranza.Nrooperacion    = this.txtNoperacion.Text.Trim();
            objCobranza.RutCli          = ALCSA.FWK.IdentificacionTributaria.FormatearRut(this.cliente.SelectedValue).Replace(".", string.Empty);
            objCobranza.RutDeudor       = ALCSA.FWK.IdentificacionTributaria.FormatearRut(this.txtRut.Text).Replace(".", string.Empty);
            objCobranza.Codigo          = this.txtNumero.Text.Trim();
            objCobranza.IdRemesa        = ALCSA.FWK.Web.Control.ExtraerValorComoEntero(ddlRemesas);
            objCobranza.IdProcedimiento = ALCSA.FWK.Web.Control.ExtraerValorComoEntero(tipoprocedimiento);
            objCobranza.IdMateria       = Convert.ToInt32(this.materia.SelectedValue.Split(new char[] { '|' })[0]);
            objCobranza.IdProducto      = Convert.ToInt32(this.producto.SelectedValue);
            objCobranza.Tipocobranza    = this.tipocobranza.SelectedValue;
            objCobranza.Usuario         = this.Session["Usuario"] != null ? this.Session["Usuario"].ToString() : string.Empty;

            objCobranza.Guardar();
            // ----------------------------------------------------------------------------------
            string strTipo = objCobranza.BuscarTipoActividad();
            string strRuta = string.Empty;

            if (strTipo == ALCSA.Negocio.Cobranzas.Cobranza.TIPO_COBRANZA_DOCUMENTO_JUICIO)
            {
                strRuta = "DocuJuicio.aspx";
            }
            else if (strTipo == ALCSA.Negocio.Cobranzas.Cobranza.TIPO_COBRANZA_DOCUMENTO_PAGARE)
            {
                strRuta = "DocuPagare.aspx";
            }
            else if (strTipo == ALCSA.Negocio.Cobranzas.Cobranza.TIPO_COBRANZA_MUTUO)
            {
                strRuta = "Mutuo.aspx";
            }
            else if (strTipo == ALCSA.Negocio.Cobranzas.Cobranza.TIPO_COBRANZA_DOCUMENTO_ESTANDAR_UNO)
            {
                strRuta = "DocEstandard_1.aspx";
            }
            else if (strTipo == ALCSA.Negocio.Cobranzas.Cobranza.TIPO_COBRANZA_DOCUMENTO_ESTANDAR_DOS)
            {
                strRuta = "DocEstandard_2.aspx";
            }
            else if (strTipo == ALCSA.Negocio.Cobranzas.Cobranza.TIPO_COBRANZA_DOCUMENTO_ESTANDAR_TRES)
            {
                strRuta = "DocEstandard_3.aspx";
            }
            else if (strTipo == ALCSA.Negocio.Cobranzas.Cobranza.TIPO_COBRANZA_DOCUMENTO_ESTANDAR_CUATRO)
            {
                strRuta = "DocEstandard_4.aspx";
            }
            else if (strTipo == ALCSA.Negocio.Cobranzas.Cobranza.TIPO_COBRANZA_CUOTA_COLEGIO)
            {
                strRuta = "cuotacolegio.aspx";
            }
            // ----------------------------------------------------------------------------------
            if (!string.IsNullOrEmpty(strRuta))
            {
                Response.Redirect(string.Format("{0}?id_cob={1}&es_nueva=1", strRuta, objCobranza.ID), true);
            }
            else
            {
                // ------------------------------------------------------------------------------
                // PASAR A MODO LECTURA
                this.txtRut.ReadOnly            = false;
                this.txtNoperacion.Text         = string.Empty;
                this.txtRut.Text                = string.Empty;
                this.txtNombre.Text             = string.Empty;
                this.txtNumero.Text             = string.Empty;
                this.tipocobranza.SelectedIndex = 0;
                this.tipoprocedimiento.Items.Clear();
                this.materia.Items.Clear();
                this.producto.Items.Clear();
                this.ComboClientes();
                this.ComboProcedimiento();
                this.Deshabilitar();
                this.btnBuscar.Visible  = true;
                this.btnGuardar.Visible = false;
                // ------------------------------------------------------------------------------
                this.Page.RegisterClientScriptBlock("Mensaje", "<script>alert('La cobranza se guardo correctamente.');</script>");
                // ------------------------------------------------------------------------------
            }
            // ----------------------------------------------------------------------------------
        }