Ejemplo n.º 1
0
        void BtnGrabar_Click(object sender, EventArgs e)
        {
            BtnGoodInmueble.Visible = false;
            LblGoodInmueble.Text    = "";
            int SeleccionJur      = 0;
            int PersonaJuridicaId = 0;

            if (Valida() == true)
            {
                if (ChkOtraJur.Checked == true)
                {
                    SeleccionJur      = 1;
                    PersonaJuridicaId = Convert.ToInt32(CboJuridico.SelectedValue);
                }
                if (TxtInmuebleId.Text == "")
                {
                    int InmuebleId = ClInmueble.Max_Inmueble();
                    ClUsuario.Insertar_Actividad_Pagina(16, Convert.ToInt32(Session["UsuarioId"]), ClUsuario.CorrId_ActividadPagina(), 4);
                    int EsRePresentante       = 0;
                    int EsRepresentanteVarios = 0;
                    if (ChkRepreseanteyPropietario.Checked == true)
                    {
                        EsRePresentante = 1;
                    }
                    if (ChkRepresentanteVariasPer.Checked == true)
                    {
                        EsRepresentanteVarios = 1;
                    }
                    //ClInmueble.Inserta_Inmueble(InmuebleId, Convert.ToInt32(Session["UsuarioId"]), SeleccionJur, PersonaJuridicaId, TxtDirccion.Text, TxtAldea.Text, TxtFinca.Text, Convert.ToInt32(CboMunicipio.SelectedValue), Convert.ToInt32(CboTipoDocumento.SelectedValue), Convert.ToDateTime(TxtFecEmi.SelectedDate), Convert.ToInt32(ClUtilitarios.IIf(TxtNoFinca.Text == "", 0, TxtNoFinca.Text)), Convert.ToInt32(ClUtilitarios.IIf(TxtFolio.Text == "", 0, TxtFolio.Text)), Convert.ToInt32(ClUtilitarios.IIf(TxtLibro.Text == "", 0, TxtLibro.Text)), TxtDe.Text, TxtNoCerti.Text, TxtNoEscritura.Text, Convert.ToInt32(CboTitulo.SelectedValue), TxtNomNotario.Text, Convert.ToInt32(OptAreasPro.SelectedValue), Convert.ToDouble(TxtArea.Text), Convert.ToInt32(CboArea.SelectedValue), EsRePresentante, EsRepresentanteVarios);
                    for (int i = 0; i < GrdPropietarios.Items.Count; i++)
                    {
                        //int PersonaId = Convert.ToInt32(GrdPropietarios.Items[i].OwnerTableView.DataKeyValues[i]["PersonaId"]);
                        //if (Convert.ToBoolean(GrdPropietarios.Items[i].OwnerTableView.DataKeyValues[i]["Existe"]) == false)
                        //{
                        //    //PersonaId = ClPersona.MaxPersonaId();
                        //    //ClPersona.Insertar_Persona_Propietario(PersonaId, GrdPropietarios.Items[i].OwnerTableView.DataKeyValues[i]["Nombres"].ToString(), GrdPropietarios.Items[i].OwnerTableView.DataKeyValues[i]["Apellidos"].ToString(), GrdPropietarios.Items[i].OwnerTableView.DataKeyValues[i]["Dpi"].ToString().Replace("-",""));
                        //}
                        //ClInmueble.Inserta_Inmueble_Propietario(PersonaId,InmuebleId);
                    }
                    if (RadUploadFile.UploadedFiles.Count > 0)
                    {
                        Stream fileStream      = RadUploadFile.UploadedFiles[0].InputStream;
                        byte[] attachmentBytes = new byte[fileStream.Length];
                        fileStream.Read(attachmentBytes, 0, Convert.ToInt32(fileStream.Length));
                        ClInmueble.Actualiza_Archivo(InmuebleId, attachmentBytes, RadUploadFile.UploadedFiles[0].ContentType, RadUploadFile.UploadedFiles[0].FileName);
                        fileStream.Close();
                    }


                    BtnGoodInmueble.Visible = true;
                    LblGoodInmueble.Text    = "Inmueble Agregado Exitosamente";
                }
                else
                {
                    ClUsuario.Insertar_Actividad_Pagina(16, Convert.ToInt32(Session["UsuarioId"]), ClUsuario.CorrId_ActividadPagina(), 2);
                    ClInmueble.Actualiza_Inmueble(Convert.ToInt32(TxtInmuebleId.Text), SeleccionJur, PersonaJuridicaId, TxtDirccion.Text, TxtAldea.Text, TxtFinca.Text, Convert.ToInt32(CboMunicipio.SelectedValue), Convert.ToInt32(CboTipoDocumento.SelectedValue), Convert.ToDateTime(TxtFecEmi.SelectedDate), Convert.ToInt32(ClUtilitarios.IIf(TxtNoFinca.Text == "", 0, TxtNoFinca.Text)), Convert.ToInt32(ClUtilitarios.IIf(TxtFolio.Text == "", 0, TxtFolio.Text)), Convert.ToInt32(ClUtilitarios.IIf(TxtLibro.Text == "", 0, TxtLibro.Text)), TxtDe.Text, TxtNoCerti.Text, TxtNoEscritura.Text, Convert.ToInt32(CboTitulo.SelectedValue), TxtNomNotario.Text, Convert.ToInt32(OptAreasPro.SelectedValue), Convert.ToDouble(TxtArea.Text), Convert.ToInt32(CboArea.SelectedValue));
                    if (RadUploadFile.UploadedFiles.Count > 0)
                    {
                        Stream fileStream      = RadUploadFile.UploadedFiles[0].InputStream;
                        byte[] attachmentBytes = new byte[fileStream.Length];
                        fileStream.Read(attachmentBytes, 0, Convert.ToInt32(fileStream.Length));
                        ClInmueble.Actualiza_Archivo(Convert.ToInt32(TxtInmuebleId.Text), attachmentBytes, RadUploadFile.UploadedFiles[0].ContentType, RadUploadFile.UploadedFiles[0].FileName);
                        fileStream.Close();
                    }
                    BtnGoodInmueble.Visible = true;
                    LblGoodInmueble.Text    = "Inmueble modificado Exitosamente";
                }
                GrdInmuebles.Rebind();
                Limpiar();
            }
        }
Ejemplo n.º 2
0
        void GrdInmuebles_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == "CmdPreview")
            {
                DataSet DsArchivo = new DataSet();
                DsArchivo = ClInmueble.Archivo_Inmueble(Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["InmuebleId"]));
                byte[] bytes;
                string fileName, contentType;
                bytes       = (byte[])DsArchivo.Tables["DATOS"].Rows[0]["Archivo_Propiedad"];
                contentType = DsArchivo.Tables["DATOS"].Rows[0]["ContenyType"].ToString();
                fileName    = DsArchivo.Tables["DATOS"].Rows[0]["Nombre_Archivo"].ToString();

                Response.Clear();
                Response.Buffer  = true;
                Response.Charset = "";
                Response.Cache.SetCacheability(HttpCacheability.NoCache);


                Response.ContentType = contentType;
                Response.AddHeader("content-disposition", "attachment; filename=" + fileName);
                Response.AddHeader("content-length", (bytes.Length - 1).ToString());
                Response.BinaryWrite(bytes.ToArray());
                Response.Flush();
                Response.End();
            }
            else if (e.CommandName == "CmdEdit")
            {
                DataSet ds = new DataSet();
                TxtInmuebleId.Text = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["InmuebleId"].ToString();
                ds = ClInmueble.Inmueble_Get(Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["InmuebleId"]));
                if (ds.Tables["DATOS"].Rows[0]["PersonaJuridicaId"].ToString() == "")
                {
                    ChkOtraJur.Checked  = false;
                    DivJuridico.Visible = false;
                }
                else
                {
                    ChkOtraJur.Checked            = true;
                    DivJuridico.Visible           = true;
                    CboJuridico.SelectedValue     = ds.Tables["DATOS"].Rows[0]["PersonaJuridicaId"].ToString();
                    CboJuridico.SelectedItem.Text = ds.Tables["DATOS"].Rows[0]["jur"].ToString();
                }
                TxtDirccion.Text = ds.Tables["DATOS"].Rows[0]["Direccion"].ToString();
                TxtAldea.Text    = ds.Tables["DATOS"].Rows[0]["Aldea"].ToString();
                TxtFinca.Text    = ds.Tables["DATOS"].Rows[0]["Finca"].ToString();
                CboDepartamento.SelectedValue     = ds.Tables["DATOS"].Rows[0]["DepartamentoId"].ToString();
                CboDepartamento.SelectedItem.Text = ds.Tables["DATOS"].Rows[0]["Departamento"].ToString();
                ClUtilitarios.LlenaCombo(ClCatalogos.ListadoMunicipios(Convert.ToInt32(CboDepartamento.SelectedValue)), CboMunicipio, "MunicipioId", "Municipio");
                CboMunicipio.SelectedValue         = ds.Tables["DATOS"].Rows[0]["MunicipioId"].ToString();
                CboMunicipio.SelectedItem.Text     = ds.Tables["DATOS"].Rows[0]["Municipio"].ToString();
                CboTipoDocumento.SelectedValue     = ds.Tables["DATOS"].Rows[0]["TipoDoc_PropiedadId"].ToString();
                CboTipoDocumento.SelectedItem.Text = ds.Tables["DATOS"].Rows[0]["TipoDocPropiedad"].ToString();
                TxtFecEmi.SelectedDate             = Convert.ToDateTime(ds.Tables["DATOS"].Rows[0]["Fec_Emision"].ToString());
                if (CboTipoDocumento.SelectedValue == "1")
                {
                    DivPropiedad.Visible = true;
                    DivMun.Visible       = false;
                    DiVPos.Visible       = false;
                    TxtNoFinca.Text      = ds.Tables["DATOS"].Rows[0]["NoFinca"].ToString();
                    TxtFolio.Text        = ds.Tables["DATOS"].Rows[0]["Folio"].ToString();
                    TxtLibro.Text        = ds.Tables["DATOS"].Rows[0]["Libro"].ToString();
                    TxtDe.Text           = ds.Tables["DATOS"].Rows[0]["De"].ToString();
                }
                else if (CboTipoDocumento.SelectedValue == "2")
                {
                    DivPropiedad.Visible = false;
                    DivMun.Visible       = true;
                    DiVPos.Visible       = false;
                    TxtNoCerti.Text      = ds.Tables["DATOS"].Rows[0]["NoCertificacion"].ToString();
                }
                else if (CboTipoDocumento.SelectedValue == "3")
                {
                    DivPropiedad.Visible        = false;
                    DivMun.Visible              = false;
                    DiVPos.Visible              = true;
                    TxtNoEscritura.Text         = ds.Tables["DATOS"].Rows[0]["NoEscritura"].ToString();
                    CboTitulo.SelectedValue     = ds.Tables["DATOS"].Rows[0]["TituloNotarioId"].ToString();
                    CboTitulo.SelectedItem.Text = ds.Tables["DATOS"].Rows[0]["TituloNotario"].ToString();
                }
                if (ds.Tables["DATOS"].Rows[0]["En_Area"].ToString() == "1")
                {
                    OptAreasPro.SelectedValue = "1";
                    DivArea.Visible           = true;
                    CboArea.SelectedValue     = ds.Tables["DATOS"].Rows[0]["AreaProtegidaId"].ToString();
                    CboArea.SelectedItem.Text = ds.Tables["DATOS"].Rows[0]["AreaPro"].ToString();
                }
                else
                {
                    OptAreasPro.SelectedValue = "0";
                    DivArea.Visible           = false;
                }
                TxtArea.Text = ds.Tables["DATOS"].Rows[0]["Area"].ToString();
                if (ds.Tables["DATOS"].Rows[0]["EsRepresentante"].ToString() == "1")
                {
                    ChkRepreseanteyPropietario.Checked = true;
                    ChkRepresentanteVariasPer.Checked  = false;
                }
                if (ds.Tables["DATOS"].Rows[0]["EsRepresentanteVarios"].ToString() == "1")
                {
                    ChkRepresentanteVariasPer.Checked  = true;
                    ChkRepreseanteyPropietario.Checked = false;
                }
                DivGrigPropietarios.Visible = true;
                GrdPropietarios.Rebind();
                BtnGrabar.Visible = false;
                GrdPropietarios.Columns[5].Visible = false;
            }
            else if (e.CommandName == "CmdDel")
            {
                ClUsuario.Insertar_Actividad_Pagina(16, Convert.ToInt32(Session["UsuarioId"]), ClUsuario.CorrId_ActividadPagina(), 3);
                ClInmueble.Elimina_Inmueble(Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["InmuebleId"]));
                GrdInmuebles.Rebind();
                Limpiar();
                BtnGoodInmueble.Visible = true;
                LblGoodInmueble.Text    = "Inmueble eliminado";
            }
        }