コード例 #1
0
        protected void Add_Operacion()
        {
            if (!this.agp_adquirente.Guardar_Form())
            {
                ScriptManager.RegisterStartupScript(this.up_operacion, this.up_operacion.GetType(), "alert_adquirente", string.Format("alert('{0}');", this.agp_adquirente.MensajeError), true);
                return;
            }

            int add = new OperacionBC().add_operacion(Convert.ToInt32(ViewState["id_solicitud"]), Convert.ToInt16(ViewState["id_cliente"]), ViewState["tipo_operacion"].ToString(), (string)(Session["usrname"]), 0, "", Convert.ToInt32(this.dl_sucursal.SelectedValue), 0);

            ViewState["id_solicitud"] = add.ToString();

            if (add != 0)
            {
                string output = new SolicitudPlacasProvisoriasBC().add_solicitud_placas_provisorias(add, Convert.ToInt16(this.dl_sucursal.SelectedValue), this.txt_patente.Text.Trim().ToUpper(), this.agp_adquirente.Rut);
                //Si hay un error guardando la operación
                if (output != "")
                {
                    ScriptManager.RegisterStartupScript(this.up_operacion, this.up_operacion.GetType(), "alert_add_garantia", string.Format("alert('{0}');", output), true);
                    return;
                }

                string add_or = new EstadooperacionBC().add_estado_orden(Convert.ToInt32(add), 1, ViewState["tipo_operacion"].ToString(), "", (string)(Session["usrname"]));

                this.lbl_operacion.Visible = true;
                this.lbl_numero.Visible    = true;

                this.lbl_numero.Text = add.ToString("N0");
                if (hdIdOrdenTrabajo.Value.Trim() != "0")
                {
                    FuncionGlobal.UpdateTipoOperacionOrdenTrabajo(ViewState["tipo_operacion"].ToString(), Convert.ToInt32(hdIdOrdenTrabajo.Value), add);
                }
            }
        }
コード例 #2
0
        protected void Add_Operacion()
        {
            if (!this.Validar_Form())
            {
                return;
            }

            UpdatePanel up = this.up_negocio;

            if (!this.agp_adquirente.Guardar_Form())
            {
                ScriptManager.RegisterStartupScript(up, up.GetType(), "alert_adquirente", string.Format("alert('{0}');", this.agp_adquirente.MensajeError), true);
                return;
            }
            if (this.agp_compra_para.Visible)
            {
                if (!this.agp_compra_para.Guardar_Form())
                {
                    ScriptManager.RegisterStartupScript(up, up.GetType(), "alert_compra_para", string.Format("alert('{0}');", this.agp_compra_para.MensajeError), true);
                    return;
                }
            }
            if (this.dl_tipo_doc_fundante.SelectedValue.Trim() == "FACT")
            {
                if (!this.agp_emisor.Guardar_Form())
                {
                    ScriptManager.RegisterStartupScript(up, up.GetType(), "alert_emisor", string.Format("alert('{0}');", this.agp_compra_para.MensajeError), true);
                    return;
                }
            }

            Int32  id_solicitud  = Convert.ToInt32(ViewState["id_solicitud"]);
            double Adquiriente   = this.agp_adquirente.Rut;
            short  cliente       = Convert.ToInt16(ViewState["id_cliente"]);
            double compra_para   = this.agp_compra_para.Rut;
            string creada        = "";
            double compra_repre  = 0;
            double repertorio    = 0;
            double n_factura     = Convert.ToDouble(this.txt_factura.Text.Replace(ViewState["separadorMiles"].ToString(), ""));
            string fecha_factura = this.txt_fecha_factura.Text;
            short  id_sucursal   = Convert.ToInt16(this.dl_sucursal.SelectedValue);
            double emisor        = this.agp_emisor.Rut;
            double monto         = Convert.ToDouble(this.txt_monto_factura.Text.Replace(ViewState["separadorMiles"].ToString(), ""));

            double n_cuotas = 0;

            if (this.txt_cant_cuotas.Text != "")
            {
                n_cuotas = Convert.ToDouble(this.txt_cant_cuotas.Text);
            }
            string fecha_primera                  = "";
            string fecha_ultima                   = this.txt_ultima.Text;
            string cta_corriente                  = "";
            string banco                          = "";
            string titular                        = "";
            string notario                        = this.txt_notaria_factura.Text;
            string ciudad                         = this.txt_ciudad_notaria_factura.Text;
            string fecha_contrato                 = this.txt_fecha_factura.Text;
            double n_cheques                      = 0;
            double neto_factura                   = Convert.ToDouble(this.txt_monto_factura.Text.Replace(ViewState["separadorMiles"].ToString(), ""));
            string tipo_pago_factura              = this.dl_forma_pago_factura.SelectedValue;
            double factura_intereses              = 0;
            string fecha_factura_intereses        = "";
            double monto_factura_intereses        = 0;
            string fecha_protocolizacion          = this.txt_fecha_protocolizacion.Text;
            string n_protocolizacion              = (this.txt_nro_protocolizacion.Text.Replace(ViewState["separadorMiles"].ToString(), ""));
            string n_RepertorioNotaria            = (this.txt_repertorio_protocolizacion.Text.Replace(ViewState["separadorMiles"].ToString(), ""));
            string n_RepertorioRNP                = (this.txt_repertorio_rnp.Text.Replace(ViewState["separadorMiles"].ToString(), ""));
            string fecha_repertorio               = this.txt_fecha_repertorio_protocolizacion.Text;
            string oficina_Registro               = "";
            string ing_alza_PN_registro           = "";
            string ing_alza_PH_registro           = "";
            string n_solicitud_PN_registro        = "";
            string n_solicitud_PH_registro        = "";
            string nombreEstado                   = "";
            string fechaUltimoEstado              = "";
            double valor_vehiculo                 = Convert.ToDouble(this.txt_monto_factura.Text.Replace(ViewState["separadorMiles"].ToString(), ""));
            double monto_pie                      = 0;
            double factura_gastos                 = 0;
            string fecha_factura_gastos           = "";
            double monto_factura_gastos           = 0;
            double nro_credito                    = Convert.ToDouble(this.txt_nro_credito.Text.Replace(ViewState["separadorMiles"].ToString(), ""));
            string doc_fundante                   = this.dl_tipo_doc_fundante.SelectedValue;
            string solicitante                    = "";
            string notaria_protocolizacion        = this.txt_notaria_protocolizacion.Text.Trim();
            string ciudad_notaria_protocolizacion = this.txt_ciudad_notaria_protocolizacion.Text.Trim();
            string fecha_repertorio_rnp           = this.txt_fecha_repertorio_rnp.Text;
            string estado_solicitud_rnp           = this.dl_estado_rnp.SelectedValue;
            string estado_prenda                  = this.dl_estado_prenda.SelectedValue;
            string observaciones                  = "";
            string nro_declaracion                = "";
            string fecha_pagare                   = this.txt_f_pagare.Text;


            if (this.txt_v_cuotas.Text == "")
            {
                this.txt_v_cuotas.Text = "0";
            }
            if (this.txt_tasa.Text == "")
            {
                this.txt_tasa.Text = "0";
            }
            if (this.txt_dia.Text == "")
            {
                this.txt_dia.Text = "0";
            }
            if (this.txt_c_pagare.Text == "")
            {
                this.txt_c_pagare.Text = "0";
            }



            int    valor_cuotas   = Convert.ToInt32(this.txt_v_cuotas.Text.Replace(ViewState["separadorMiles"].ToString(), ""));
            string tasa           = this.txt_tasa.Text;
            int    dia            = Convert.ToInt32(this.txt_dia.Text.Replace(ViewState["separadorMiles"].ToString(), ""));
            int    capital_pagare = Convert.ToInt32(this.txt_c_pagare.Text.Replace(ViewState["separadorMiles"].ToString(), ""));

            if (this.txt_c_pagare.Text != "0" && this.txt_c_pagare.Text != "")
            {
                fecha_primera = this.txt_f_primera.Text;
                fecha_ultima  = this.txt_f_ultima.Text;
            }


            int add = new OperacionBC().add_operacion(id_solicitud, cliente, ViewState["tipo_operacion"].ToString(), (string)(Session["usrname"]), 0, nro_credito.ToString().Trim(), Convert.ToInt32(this.dl_sucursal.SelectedValue), 0);

            ViewState["id_solicitud"]  = add.ToString();
            this.lbl_operacion.Visible = true;
            this.lbl_numero.Visible    = true;
            this.lbl_numero.Text       = add.ToString("N0");

            if (add != 0)
            {
                string output = new GarantiaBC().add_Garantia(add, Adquiriente, cliente, compra_para, creada, compra_repre, repertorio, n_factura, fecha_factura, id_sucursal,
                                                              emisor, monto, n_cuotas, fecha_primera, fecha_ultima, cta_corriente, banco, titular, notario, ciudad, fecha_contrato, n_cheques,
                                                              neto_factura, tipo_pago_factura, factura_intereses, fecha_factura_intereses, monto_factura_intereses, fecha_protocolizacion, n_protocolizacion, n_RepertorioNotaria,
                                                              n_RepertorioRNP, fecha_repertorio, oficina_Registro, ing_alza_PN_registro, ing_alza_PH_registro, n_solicitud_PN_registro, n_solicitud_PH_registro, nombreEstado,
                                                              fechaUltimoEstado, valor_vehiculo, monto_pie, factura_gastos, fecha_factura_gastos, monto_factura_gastos, nro_credito, doc_fundante, solicitante,
                                                              notaria_protocolizacion, ciudad_notaria_protocolizacion, fecha_repertorio_rnp, estado_solicitud_rnp, estado_prenda, observaciones, this.chk_cav.Checked, nro_declaracion, fecha_pagare,
                                                              valor_cuotas, capital_pagare, tasa, dia);
                //Si hay un error guardando la operación
                if (output != "")
                {
                    ScriptManager.RegisterStartupScript(up, up.GetType(), "alert_add_garantia", string.Format("alert('{0}');", output), true);
                    return;
                }

                //PARA ORDEN DE TRABAJO
                if (IdOrdenTrabajo != 0)
                {
                    FuncionGlobal.UpdateTipoOperacionOrdenTrabajo(ViewState["tipo_operacion"].ToString(), IdOrdenTrabajo, add);
                }

                string add_or = new EstadooperacionBC().add_estado_orden(Convert.ToInt32(add), 1, ViewState["tipo_operacion"].ToString(), "", (string)(Session["usrname"]));

                if (!this.agp_vehiculo.Guardar_Form(add))
                {
                    ScriptManager.RegisterStartupScript(up, up.GetType(), "alert_add_vehiculo", string.Format("alert('{0}');", this.agp_vehiculo.MensajeError), true);
                    return;
                }

                this.Busca_Operacion();
            }
        }
コード例 #3
0
        protected void bt_guardar_Click(object sender, EventArgs e)
        {
            UpdatePanel up = (UpdatePanel)Master.FindControl("UpdatePanel1");

            string rutcomp = "0";
            string rutvend = "0";


            //if(txtNumFactura.Text == "")
            //{
            //    tdMensaje.Visible = true;
            //    lblMensaje.Text = "Favor agregar número de factura.";
            //    return;
            //}

            //DateTime result;

            //bool validafecha = DateTime.TryParse(txt_fecha_documento.Text, out result.ToShortDateString("DD/MM/YYYY"));

            if (txt_patente.Text == "" || txt_patente.Text == "0")
            {
                FuncionGlobal.alerta_updatepanel("Debe ingresar la Fecha de Documento correcta", Page, up);
                return;
            }



            if (txt_patente.Text == "" || txt_patente.Text == "0")
            {
                FuncionGlobal.alerta_updatepanel("Debe ingresar la Patente", Page, up);
                return;
            }


            if (txt_fecha_documento.Text == "" || txt_fecha_documento.Text == "0")
            {
                FuncionGlobal.alerta_updatepanel("Debe ingresar la Fecha de Documento", Page, up);
                return;
            }

            if (id_cliente == 15)
            {
                if (txt_interno.Text == "")
                {
                    //Response.Write("<script language=javascript>alert('Debe ingresar el número de operación banco');</script>");
                    //return;
                    FuncionGlobal.alerta_updatepanel("Debe ingresar el número de operación banco", Page, up);
                    return;
                }

                if (Convert.ToInt32(txt_interno.Text) <= 0)
                {
                    FuncionGlobal.alerta_updatepanel("El número de operación banco no corresponde", Page, up);
                    return;
                    //Response.Write("<script language=javascript>alert('El número de operación banco no corresponde');</script>");
                    //return;
                }

                if (txtNumFactura.Text == "")
                {
                    FuncionGlobal.alerta_updatepanel("Debe ingresar el número de factura", Page, up);
                    return;
                    //Response.Write("<script language=javascript>alert('Debe ingresar el número de factura');</script>");
                    //return;
                }

                var validaNumOperacionBanco = new OperacionBC().validaNumOperacionBanco(Convert.ToInt32(txt_interno.Text), Convert.ToInt32(txtNumFactura.Text));
                if (validaNumOperacionBanco.Numero_cliente != txt_interno.Text)
                {
                    FuncionGlobal.alerta_updatepanel("Por favor revise número de operacion o factura.", Page, up);
                    return;
                    //Response.Write("<script language=javascript>alert('Por favor revise número de operacion o factura.');</script>");
                    //return;
                }
            }

            if (Datoscomprador.Guardar_Form())
            {
                if (Datoscomprador.InfoPersona != null)
                {
                    rutcomp = Datoscomprador.InfoPersona.Rut.ToString();
                }
            }


            if (Datosvendedor.Guardar_Form())
            {
                if (Datosvendedor.InfoPersona != null)
                {
                    rutvend = Datosvendedor.InfoPersona.Rut.ToString();
                }
            }

            Int32 add = new OperacionBC().add_operacion(Convert.ToInt32(lbl_numero.Text),
                                                        Convert.ToInt16(dl_cliente.SelectedValue), tipo_operacion,
                                                        (string)(Session["usrname"]), 0, (txt_interno.Text.Trim()),
                                                        Convert.ToInt32(dl_sucursal_origen.SelectedValue), Convert.ToInt32(txtNumFactura.Text));

            //PARA ORDEN DE TRABAJO
            if (IdOrdenTrabajo != 0)
            {
                FuncionGlobal.UpdateTipoOperacionOrdenTrabajo(tipo_operacion, IdOrdenTrabajo, add);
            }



            string       addparcom = new ParticipeOperacionBC().add_participe(add, Convert.ToInt32(Datoscomprador.InfoPersona.Rut), "COMPR");
            string       addparven = new ParticipeOperacionBC().add_participe(add, Convert.ToInt32(Datosvendedor.InfoPersona.Rut), "VENDE");
            Meratenencia mera      = new Meratenencia();

            mera.Anno_causa     = Convert.ToInt32(txt_anno_causa.Text);
            mera.Autorizacion   = txt_autorizacion_doc.Text;
            mera.Calidad_mero   = dl_calidad_mero.SelectedValue;
            mera.Fecha_doc      = Convert.ToDateTime(txt_fecha_documento.Text);
            mera.Id_solicitud   = Convert.ToInt32(add);
            mera.Lugar_doc      = txt_lugar_doc.Text;
            mera.N_doc          = txt_n_doc.Text;
            mera.Naturaleza_doc = dl_naturaleza_doc.SelectedValue;
            mera.Rut_comprador  = Convert.ToInt32(Datoscomprador.InfoPersona.Rut);
            mera.Rut_vendedor   = Convert.ToInt32(Datosvendedor.InfoPersona.Rut);
            mera.Tipo_doc       = dl_tipo_doc.SelectedValue;
            mera.Titulo_mera    = dl_titulo_mera.SelectedValue;
            mera.Tribunal       = txt_tribunal.Text;
            mera.N_bien         = dl_bien.SelectedValue;
            string addmera = new MeratenenciaBC().add_meratenencia(mera);

            DatosVehiculo mdato2 = new DatosvehiculoBC().getDatovehiculobyPatente_id_solicitud(txt_patente.Text, add);

            Marcavehiculo marca   = new Marcavehiculo();
            Tipovehiculo  tipvehi = new Tipovehiculo();
            string        mar     = dl_marca.SelectedValue;
            string        tip     = dl_tipo_vehiculo.SelectedValue;

            if (mar != "0")
            {
                marca = new MarcavehiculoBC().getmarcavehiculo(Convert.ToInt16(mar));
            }
            else
            {
                marca = new MarcavehiculoBC().getmarcavehiculo(69);
            }
            if (tip != "0")
            {
                tipvehi = new TipovehiculoBC().getTipoVehiculo(tip);
            }
            else
            {
                tipvehi = new TipovehiculoBC().getTipoVehiculo("PDF");
            }
            //Int32 id_dato_vehiculo = 0;


            if (mdato2 != null)
            {
                string datovehi = new DatosvehiculoBC().add_Datosvehiculo(add,
                                                                          mdato2.Marca,
                                                                          mdato2.Tipo_vehiculo,
                                                                          txt_patente.Text,
                                                                          FuncionGlobal.digitoVerificadorPatente(txt_patente.Text),
                                                                          mdato2.Modelo, mdato2.Chassis, "", mdato2.Vin, mdato2.Serie, Convert.ToInt32(0), "", mdato2.Color, 0, 0, "", 0, 0,
                                                                          Convert.ToInt32(0), Convert.ToInt32(0),
                                                                          "", Convert.ToInt32(0),
                                                                          Convert.ToInt32(mdato2.Id_dato_vehiculo), DateTime.Now, "", "false", "", 0, "false",
                                                                          mdato2.Transmision, mdato2.Equipamiento, "0");
            }
            else
            {
                string datovehi = new DatosvehiculoBC().add_Datosvehiculo(add,
                                                                          marca,
                                                                          tipvehi,
                                                                          txt_patente.Text,
                                                                          FuncionGlobal.digitoVerificadorPatente(txt_patente.Text),
                                                                          txt_modelo.Text, "", "", "", "", Convert.ToInt32(0), "", "", 0, 0, "", 0, 0,
                                                                          Convert.ToInt32(0),
                                                                          Convert.ToInt32(0),
                                                                          "", Convert.ToInt32(0), 0, DateTime.Now,
                                                                          "", "false", "", 0, "0", "0", "0", "0");
            }

            string add_or = new EstadooperacionBC().add_estado_orden(Convert.ToInt32(add), 1, tipo_operacion, "", (string)(Session["usrname"]));


            lbl_operacion.Visible = true;
            lbl_numero.Visible    = true;
            lbl_operacion.Text    = "Operación de Meratenencia Numero:";
            lbl_numero.Text       = Convert.ToString(add);

            int bien;

            if (dl_bien.SelectedValue == "0" || dl_bien.SelectedValue == null || dl_bien.SelectedValue == "")
            {
                bien = Convert.ToInt32(txt_bien.Text);
            }
            else
            {
                bien = Convert.ToInt32(dl_bien.SelectedValue);
            }

            if (id_cliente == 15)
            {
                new BienesNumeroClienteBC().add_integracion_leasing(add, bien,
                                                                    Convert.ToInt32(txt_interno.Text), tipo_operacion);
            }

            FuncionGlobal.alerta(lbl_titulo.Text + ", INGRESADO CON EXITO", Page);
        }
コード例 #4
0
        protected void Add_Operacion()
        {
            if (this.txt_fecha_factura.Text == "")
            {
                FuncionGlobal.alerta_updatepanel("Falta ingresar la fecha de Factura", this.Page, up_operacion);
                return;
            }
            if (this.dl_sucursal.SelectedValue == "0")
            {
                FuncionGlobal.alerta_updatepanel("Falta ingresar la Sucursal", this.Page, up_operacion);
                return;
            }
            if (this.txt_neto.Text == "")
            {
                FuncionGlobal.alerta_updatepanel("Falta ingresar el Neto de la Factura", this.Page, up_operacion);
                return;
            }
            if (this.txt_factura.Text == "")
            {
                FuncionGlobal.alerta_updatepanel("Falta ingresar la Factura", this.Page, up_operacion);
                return;
            }


            if (!this.agp_adquirente.Guardar_Form())
            {
                ScriptManager.RegisterStartupScript(this.up_operacion, this.up_operacion.GetType(), "alert_adquirente", string.Format("alert('{0}');", this.agp_adquirente.MensajeError), true);
                return;
            }

            int add = new OperacionBC().add_operacion(Convert.ToInt32(ViewState["id_solicitud"]), Convert.ToInt16(ViewState["id_cliente"]), ViewState["tipo_operacion"].ToString(), (string)(Session["usrname"]), 0, "", Convert.ToInt32(this.dl_sucursal.SelectedValue), 0);

            this.agpDatosGrabar.Id_solicitud = add;
            this.agpDatosGrabar.Carga_vent   = Convert.ToInt32(this.dl_cargo_venta.SelectedValue.Trim());

            if (!this.agp_vehiculo.Guardar_Form(add))
            {
                ScriptManager.RegisterStartupScript(this.up_operacion, this.up_operacion.GetType(), "alert_vehiculo", string.Format("alert('{0}');", this.agp_vehiculo.MensajeError), true);
                return;
            }
            Int32 factura = 0;

            if (this.txt_factura.Text != "")
            {
                factura = Convert.ToInt32(this.txt_factura.Text);
            }

            ViewState["id_solicitud"] = add.ToString();

            string neto = "0";

            if (this.txt_neto.Text != "")
            {
                neto = this.txt_neto.Text;
            }

            if (add != 0)
            {
                string output = new PreinscripcionBC().add_preinscripcion(add, Convert.ToDouble(factura), "", "", "", "", this.dl_cargo_venta.SelectedValue.ToString(), this.txt_fecha_factura.Text,
                                                                          Convert.ToDouble(this.agp_adquirente.Rut), "CON", "SP", Convert.ToDouble(0), "1", Convert.ToDouble(neto), "",
                                                                          0, Convert.ToInt16(this.dl_sucursal.SelectedValue), Convert.ToInt16(this.dl_sucursal.SelectedValue),
                                                                          Convert.ToDouble(0), Convert.ToDouble(0), "", "0");
                //Si hay un error guardando la operación
                if (output != "")
                {
                    ScriptManager.RegisterStartupScript(this.up_operacion, this.up_operacion.GetType(), "alert_add_PermySeg", string.Format("alert('{0}');", output), true);
                    return;
                }

                string add_or = new EstadooperacionBC().add_estado_orden(Convert.ToInt32(add), 1, ViewState["tipo_operacion"].ToString(), "", (string)(Session["usrname"]));
                if (hdIdOrdenTrabajo.Value.Trim() != "0")
                {
                    FuncionGlobal.UpdateTipoOperacionOrdenTrabajo(ViewState["tipo_operacion"].ToString(), Convert.ToInt32(hdIdOrdenTrabajo.Value), add);
                }
            }
        }
コード例 #5
0
        protected void Add_Operacion()
        {
            double para = 0;
            double adq  = 0;

            //if (!this.agp_adquirente.Guardar_Form())
            //{
            //    ScriptManager.RegisterStartupScript(this.up_operacion, this.up_operacion.GetType(), "alert_adquirente", string.Format("alert('{0}');", this.agp_adquirente.MensajeError), true);
            //    return;
            //}

            if (this.dl_cliente.SelectedValue == "15" && this.txtNumOperacion.Text == "")
            {
                FuncionGlobal.alerta_updatepanel("Falta ingresar número de operación cliente", this.Page, up_operacion);
                return;
            }
            if (this.txt_fecha_factura.Text == "")
            {
                FuncionGlobal.alerta_updatepanel("Falta ingresar la fecha de Facturacion", this.Page, up_operacion);
                return;
            }
            if (this.txt_factura.Text == "")
            {
                FuncionGlobal.alerta_updatepanel("Falta ingresar la Factura", this.Page, up_operacion);
                return;
            }

            if (this.agp_adquirente.Guardar_Form())
            {
                if (this.agp_adquirente.InfoPersona != null)
                {
                    adq = this.agp_adquirente.InfoPersona.Rut;
                }
                else
                {
                    adq = this.agp_adquirente.getRut();
                }
            }
            if (this.agpCompraPara.Visible)
            {
                if (this.agpCompraPara.Guardar_Form())
                {
                    if (this.agpCompraPara.InfoPersona != null)
                    {
                        para = this.agpCompraPara.InfoPersona.Rut;
                    }
                    else
                    {
                        para = this.agpCompraPara.getRut();
                    }
                }
            }
            var tipoOper = Request.QueryString["tipo_operacion"].ToString();

            var numOperacion = "0";

            if (tipoOper.Trim() == "STMH")
            {
                numOperacion = this.txtNumOperacion.Text;
            }

            int add = new OperacionBC().add_operacion(Convert.ToInt32(ViewState["id_solicitud"]),
                                                      Convert.ToInt16(ViewState["id_cliente"]),
                                                      ViewState["tipo_operacion"].ToString(), (string)(Session["usrname"]), 0,
                                                      numOperacion, Convert.ToInt32(this.dl_sucursal.SelectedValue), 0);

            this.agpDatosGrabar.Id_solicitud = add;
            this.agpDatosGrabar.Carga_vent   = Convert.ToInt32(this.dl_cargo_venta.SelectedValue.Trim());
            if (hdIdOrdenTrabajo.Value.Trim() != "0")
            {
                FuncionGlobal.UpdateTipoOperacionOrdenTrabajo(ViewState["tipo_operacion"].ToString(), Convert.ToInt32(hdIdOrdenTrabajo.Value), add);
            }

            if (!this.agp_vehiculo.Guardar_Form(add))
            {
                ScriptManager.RegisterStartupScript(this.up_operacion, this.up_operacion.GetType(), "alert_vehiculo", string.Format("alert('{0}');", this.agp_vehiculo.MensajeError), true);
                return;
            }
            Int32 factura = 0;

            if (this.txt_factura.Text != "")
            {
                factura = Convert.ToInt32(this.txt_factura.Text);
            }

            ViewState["id_solicitud"] = add.ToString();

            if (add != 0)
            {
                string output = new PreinscripcionBC().add_preinscripcion(add, Convert.ToDouble(factura), "", "", "", "", this.dl_cargo_venta.SelectedValue.ToString(), this.txt_fecha_factura.Text,
                                                                          Convert.ToDouble(adq), this.dl_financiera.SelectedValue, "SP", Convert.ToDouble(para), this.dl_forma_pago.SelectedValue, Convert.ToDouble(this.txt_neto.Text), "",
                                                                          0, Convert.ToInt16(this.dl_sucursal.SelectedValue), Convert.ToInt16(this.dl_sucursal.SelectedValue),
                                                                          Convert.ToDouble(0), Convert.ToDouble(0), "", "0");
                //Si hay un error guardando la operación
                if (output != "")
                {
                    ScriptManager.RegisterStartupScript(this.up_operacion, this.up_operacion.GetType(), "alert_add_PermySeg", string.Format("alert('{0}');", output), true);
                    return;
                }

                string add_or = new EstadooperacionBC().add_estado_orden(Convert.ToInt32(add), 1, ViewState["tipo_operacion"].ToString(), "", (string)(Session["usrname"]));
            }

            if (ViewState["id_cliente"].ToString() == "15")
            {
                var patente_op_tipo = ViewState["tipo_operacion"];
                new BienesNumeroClienteBC().act_datos_bien(Convert.ToInt32(txtNumOperacion.Text),                             //numeroOperacion   int,
                                                           Convert.ToInt32(txt_factura.Text),                                 //factura     numeric(18),
                                                           Convert.ToInt32(dl_bien.SelectedValue),                            //id_bien     numeric(18),
                                                           Convert.ToInt32(add),                                              //id_solicitud    numeric(18),
                                                           patente_op_tipo.ToString(),                                        //patente     varchar(6),
                                                           Convert.ToDateTime(txt_fecha_factura.Text),                        //fecha_emision_factura  DATETIME,
                                                           Convert.ToInt32(dlInstruccionPago.Text),                           //instruccion_de_pago  int,
                                                           Convert.ToInt32(!string.IsNullOrEmpty((ckNormaEuro.Text)) ? 1 : 0) //normaEuro int = 0,
                                                           );
            }
        }