Example #1
0
    protected void rptComunaInactivo_OnItemCommand(object sender, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Activar")
        {
            HiddenField hdnIdComuna = new HiddenField();
            hdnIdComuna = (HiddenField)e.Item.FindControl("hdnIdComuna");

            ComunaDTO theComunaDTO = new ComunaDTO();
            theComunaDTO.IdComuna            = decimal.Parse(hdnIdComuna.Value);
            theComunaDTO.UsuarioModificacion = myUsuario.Rut;
            bool respuesta = YouCom.bll.ComunaBLL.ActivaComuna(theComunaDTO);
            if (respuesta)
            {
                cargarComunaInactivo();
                if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
                {
                    string script = "alert('Comuna Activada correctamente.');";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                }
            }
            else
            {
            }
        }
    }
Example #2
0
        public List <ComunaDTO> GetAllComunas()
        {
            con.Open();

            SqlCommand    cmd = new SqlCommand();
            SqlDataReader reader;

            cmd.CommandText = "SELECT * FROM COMUNA";
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            reader          = cmd.ExecuteReader();

            List <ComunaDTO> retorno = new List <ComunaDTO>();

            while (reader.Read())
            {
                ComunaDTO item = new ComunaDTO();
                item.ComCod      = (reader["ComCod"] != DBNull.Value) ? reader["ComCod"].ToString() : string.Empty;
                item.Descripcion = (reader["Descripcion"] != DBNull.Value) ? reader["Descripcion"].ToString() : string.Empty;
                item.Id_Region   = (reader["Id_Region"] != DBNull.Value) ? Convert.ToInt32(reader["Id_Region"]) : 0;
                item.Estado      = (reader["Estado"] != DBNull.Value) ? Convert.ToInt32(reader["Estado"]) : 0;
                retorno.Add(item);
            }
            reader.Close();
            con.Close();
            return(retorno);
        }
Example #3
0
    protected void btnEditar_Click(object sender, EventArgs e)
    {
        btnEditar.Visible = false;
        btnGrabar.Visible = true;

        ComunaDTO theComunaDTO = new ComunaDTO();

        theComunaDTO.IdComuna          = decimal.Parse(this.hdnIdComuna.Value);
        theComunaDTO.NombreComuna      = this.txtNombre.Text.ToUpper();
        theComunaDTO.DescripcionComuna = this.txtNombre.Text.ToUpper();
        CiudadDTO myCiudadDTO = new CiudadDTO();

        myCiudadDTO.IdCiudad      = decimal.Parse(this.ddlCiudad.SelectedValue);
        theComunaDTO.TheCiudadDTO = myCiudadDTO;

        theComunaDTO.UsuarioModificacion = myUsuario.Rut;

        bool respuesta = YouCom.bll.ComunaBLL.Update(theComunaDTO);

        if (respuesta)
        {
            cargarComuna();
            this.txtNombre.Text = string.Empty;
            this.ddlCiudad.ClearSelection();

            if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
            {
                string script = "alert('Comuna editada correctamente.');";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
            }
        }
        else
        {
        }
    }
Example #4
0
    protected void btnGrabar_Click(object sender, EventArgs e)
    {
        List <ComunaDTO> comuna = new List <ComunaDTO>();

        comuna = (Session["comuna"] as List <ComunaDTO>);

        ComunaDTO theComunaDTO = new ComunaDTO();

        theComunaDTO.NombreComuna      = this.txtNombre.Text.ToUpper();
        theComunaDTO.DescripcionComuna = this.txtNombre.Text.ToUpper();

        CiudadDTO myCiudadDTO = new CiudadDTO();

        myCiudadDTO.IdCiudad      = decimal.Parse(this.ddlCiudad.SelectedValue);
        theComunaDTO.TheCiudadDTO = myCiudadDTO;

        theComunaDTO.UsuarioIngreso = myUsuario.Rut;

        comuna = comuna.Where(x => x.NombreComuna == theComunaDTO.NombreComuna).ToList();
        if (comuna.Any())
        {
            foreach (var item in comuna)
            {
                if (item.Estado == "2")
                {
                    string script = "alert('Comuna Existe pero Fue Eliminado Para Activarlo dirigase a Papelera.');";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                    return;
                }
                else
                {
                    string script = "alert('Comuna ya Existe .');";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                    return;
                }
            }
        }


        bool respuesta = YouCom.bll.ComunaBLL.Insert(theComunaDTO);

        if (respuesta)
        {
            this.txtNombre.Text = string.Empty;
            this.ddlCiudad.ClearSelection();
            string script = "alert('Comuna Ingresada correctamente.');";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
            cargarCiudad();
        }
        else
        {
        }
    }
Example #5
0
    protected void rptComuna_OnItemCommand(object sender, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Editar")
        {
            HiddenField hdnIdComuna = new HiddenField();
            hdnIdComuna = (HiddenField)e.Item.FindControl("hdnIdComuna");

            YouCom.DTO.ComunaDTO myComunaDTO = new YouCom.DTO.ComunaDTO();
            myComunaDTO = YouCom.bll.ComunaBLL.detalleComuna(decimal.Parse(hdnIdComuna.Value));

            this.hdnIdComuna.Value  = myComunaDTO.IdComuna.ToString();
            txtNombre.Text          = myComunaDTO.NombreComuna;
            ddlCiudad.SelectedIndex = ddlCiudad.Items.IndexOf(ddlCiudad.Items.FindByValue(myComunaDTO.TheCiudadDTO.IdCiudad.ToString()));

            btnGrabar.Visible = false;
            btnEditar.Visible = true;
        }
        if (e.CommandName == "Eliminar")
        {
            HiddenField hdnIdCiudad = new HiddenField();
            hdnIdCiudad = (HiddenField)e.Item.FindControl("hdnIdCiudad");

            ComunaDTO theComunaDTO = new ComunaDTO();
            theComunaDTO.IdComuna            = decimal.Parse(hdnIdComuna.Value);
            theComunaDTO.UsuarioModificacion = myUsuario.Rut;

            bool validacionIntegridad = YouCom.bll.ComunaBLL.ValidaEliminacionComuna(theComunaDTO);
            if (validacionIntegridad)
            {
                string script = "alert(' No es posible eliminar un Comuna con registro asociado.');";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                return;
            }
            else
            {
                bool respuesta = YouCom.bll.ComunaBLL.Delete(theComunaDTO);
                if (respuesta)
                {
                    cargarCiudad();
                    if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
                    {
                        string script = "alert('Comuna Eliminada correctamente.');";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                    }
                }
                else
                {
                }
            }
        }
    }
Example #6
0
        public static bool ValidaEliminacionComuna(ComunaDTO theComunaDTO)
        {
            DataTable pobjDataTable = new DataTable();
            bool      retorno       = false;

            if (YouCom.DAL.ComunaDAL.ValidaEliminacionComuna(theComunaDTO, ref pobjDataTable))
            {
                foreach (DataRow wobjDataRow in pobjDataTable.Rows)
                {
                    retorno = true;
                }
            }
            return(retorno);
        }
Example #7
0
        public static bool mantenedorComuna(ComunaDTO comuna, int accion)
        {
            try
            {
                bool valida = false;
                using (DB_A5AC51_micosporeEntities db = new DB_A5AC51_micosporeEntities())
                {
                    db.SP_MANTENEDOR_COMUNA(comuna.Id.ToString(), comuna.Nombre, accion);
                    db.SaveChanges();
                    valida = true;
                }


                return(valida);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Example #8
0
        public static bool registrarComuna(ComunaDTO objComuna)
        {
            //mantenedor_prueba prueba = new mantenedor_prueba();
            //prueba.cargarGrilla();
            //return objComuna.Nombre;

            try
            {
                if (ComunaNegocio.crearComunaNegocio(objComuna))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Example #9
0
        public static List <ComunaDTO> ObtenerComunasAll()
        {
            try
            {
                List <ComunaDTO> comunas = new List <ComunaDTO>();

                using (DB_A5AC51_micosporeEntities db = new DB_A5AC51_micosporeEntities())
                {
                    foreach (var aux in db.COMUNA)
                    {
                        ComunaDTO comuna = new ComunaDTO();
                        comuna.Id     = aux.ID_COMUNA;
                        comuna.Nombre = aux.NOMBRE;
                        comunas.Add(comuna);
                    }
                }
                return(comunas);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Example #10
0
        public static List <YouCom.DTO.ComunaDTO> getListadoComuna()
        {
            DataTable pobjDataTable = new DataTable();

            YouCom.DTO.ComunaDTO        theComunaDTO;
            List <YouCom.DTO.ComunaDTO> collComuna = new List <ComunaDTO>();

            if (YouCom.DAL.ComunaDAL.getListadoComuna(ref pobjDataTable))
            {
                foreach (DataRow wobjDataRow in pobjDataTable.Rows)
                {
                    theComunaDTO          = new ComunaDTO();
                    theComunaDTO.IdComuna = wobjDataRow["idComuna"] != null?decimal.Parse(wobjDataRow["idComuna"].ToString()) : 0;

                    theComunaDTO.NombreComuna      = wobjDataRow["nombreComuna"] != null ? wobjDataRow["nombreComuna"].ToString() : string.Empty;
                    theComunaDTO.DescripcionComuna = wobjDataRow["descripcionComuna"] != null ? wobjDataRow["descripcionComuna"].ToString() : string.Empty;

                    YouCom.DTO.CiudadDTO myCiudad = new DTO.CiudadDTO();

                    myCiudad.IdCiudad = wobjDataRow["idCiudad"] != null?decimal.Parse(wobjDataRow["idCiudad"].ToString()) : 0;

                    myCiudad.NombreCiudad = wobjDataRow["nombreCiudad"].ToString();

                    theComunaDTO.TheCiudadDTO = myCiudad;

                    theComunaDTO.UsuarioIngreso      = wobjDataRow["usuario_ingreso"] != null ? wobjDataRow["usuario_ingreso"].ToString() : string.Empty;
                    theComunaDTO.FechaIngreso        = wobjDataRow["fecha_ingreso"] != null ? wobjDataRow["fecha_ingreso"].ToString() : string.Empty;
                    theComunaDTO.UsuarioModificacion = wobjDataRow["usuario_modificacion"] != null ? wobjDataRow["usuario_modificacion"].ToString() : string.Empty;
                    theComunaDTO.FechaModificacion   = wobjDataRow["fecha_modificacion"] != null ? wobjDataRow["fecha_modificacion"].ToString() : string.Empty;
                    theComunaDTO.Estado = wobjDataRow["estado"] != null ? wobjDataRow["estado"].ToString() : string.Empty;

                    collComuna.Add(theComunaDTO);
                }
            }
            return(collComuna);
        }
Example #11
0
 public static bool eliminarComunaNegocio(ComunaDTO comuna)
 {
     return(ComunaData.mantenedorComuna(comuna, 3));
 }
Example #12
0
 public static bool actualizarComunaNegocio(ComunaDTO comuna)
 {
     return(ComunaData.mantenedorComuna(comuna, 2));
 }
Example #13
0
 public static bool crearComunaNegocio(ComunaDTO comuna)
 {
     return(ComunaData.mantenedorComuna(comuna, 1));
 }
Example #14
0
        public static bool ValidaEliminacionComuna(ComunaDTO theComunaDTO)
        {
            bool respuesta = facade.Comuna.ValidaEliminacionComuna(theComunaDTO);

            return(respuesta);
        }
Example #15
0
        public static bool ActivaComuna(ComunaDTO theComunaDTO)
        {
            bool respuesta = ComunaDAL.ActivaComuna(theComunaDTO);

            return(respuesta);
        }