Пример #1
0
 public int getCount(Documento_ENT documento, int all)
 {
     try
     {
         using (SqlConnection sqlConn = new SqlConnection(this.ConexionPH))
         {
             sqlConn.Open();
             SqlCommand cmd = new SqlCommand(this.ConexionPH, sqlConn);
             cmd.CommandType = System.Data.CommandType.StoredProcedure;
             cmd.CommandText = "SP_LIST_COUNT_FILTRO_DOCUMENTO";
             cmd.Parameters.AddWithValue("@id_conjunto_habitacional", documento.IdConjuntoHabitacional);
             cmd.Parameters.AddWithValue("@folio", documento.Folio);
             cmd.Parameters.AddWithValue("@nombre", documento.Nombre);
             cmd.Parameters.AddWithValue("@fecha_documento", documento.FechaDocumento);
             cmd.Parameters.AddWithValue("@fecha_vencimiento", documento.FechaVencimiento);
             cmd.Parameters.AddWithValue("@all", all);
             SqlDataReader reader = cmd.ExecuteReader();
             if (reader.Read())
             {
                 return(reader["total"].Equals(DBNull.Value) ? 0 : Convert.ToInt32(reader["total"]));
             }
             else
             {
                 return(0);
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Error al ejecutar SP_LIST_COUNT_FILTRO_DOCUMENTO", ex);
     }
 }
 protected void btn_grabar_docAsociada_Click(object sender, EventArgs e)
 {
     if (this.validar())
     {
         Documento_ENT documento       = this.cargarDocumento();
         string        nombreDocumento = new Utilidad().getMD5(fileArchivo.FileName, DateTime.Now.ToShortDateString()).ToUpper();
         int           resultadoUpload = new Utilidad().uploadArchivo(fileArchivo,
                                                                      Server.MapPath(new Utilidad().traerParametro("rutaUpload")),
                                                                      new Utilidad().traerParametro("extensionUpload").Split('/'),
                                                                      nombreDocumento);
         if (resultadoUpload.Equals(1))
         {
             documento.ArchivoNombre    = nombreDocumento + System.IO.Path.GetExtension(fileArchivo.FileName).ToLower();
             documento.ArchivoExtencion = System.IO.Path.GetExtension(fileArchivo.FileName).ToLower();
             documento.ArchivoTipo      = documento.ArchivoExtencion.Replace(".", "");
             documento = new Documento_BSS().insertDocumento(documento);
             ClientScript.RegisterStartupScript(this.GetType(), "", JavaScript.alert("Documento Cargado Exitósamente"));
             Response.Redirect("~/modulo/conjuntoHabitacional/Tabs/DocumentoListado.aspx");
         }
         else if (resultadoUpload.Equals(2))
         {
             ClientScript.RegisterStartupScript(this.GetType(), "", JavaScript.alert("La extensión del archivo no esta permitida"));
         }
         else
         {
             ClientScript.RegisterStartupScript(this.GetType(), "", JavaScript.alert("Error al cargar archivo, intente nuevamente, si el problema persiste consulte con su administrador"));
         }
     }
 }
    private Documento_ENT cargarDocumento()
    {
        ConjuntoHabitacional_ENT conjunto  = (ConjuntoHabitacional_ENT)Session["conjuntoHabitacionalSeleccionado"];
        Documento_ENT            documento = new Documento_ENT();

        documento.IdConjuntoHabitacional = conjunto.IdConjuntoHabitacional;
        documento.Nombre           = txtNombreDocumento.Text;
        documento.Folio            = txtFolioDocumento.Text;
        documento.FechaDocumento   = txtFechaDocumento.Text.Equals("") ? new DateTime(1900, 1, 1) : Convert.ToDateTime(txtFechaDocumento.Text);
        documento.FechaVencimiento = txtFechaVencimiento.Text.Equals("") ? new DateTime(1900, 1, 1) : Convert.ToDateTime(txtFechaVencimiento.Text);
        documento.FechaIngreso     = DateTime.Now;
        documento.Descripcion      = txtDescripcion.InnerText;
        documento.Estado           = true;
        return(documento);
    }
Пример #4
0
        public Documento_ENT insert(Documento_ENT datosDocumento)
        {
            try
            {
                using (SqlConnection sqlConn = new SqlConnection(this.ConexionPH))
                {
                    sqlConn.Open();
                    SqlCommand cmd = new SqlCommand(this.ConexionPH, sqlConn);
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.CommandText = "SP_INSERT_DOCUMENTO";

                    cmd.Parameters.AddWithValue("@id_conjunto_habitacional", datosDocumento.IdConjuntoHabitacional);
                    cmd.Parameters.AddWithValue("@folio", datosDocumento.Folio);
                    cmd.Parameters.AddWithValue("@nombre", datosDocumento.Nombre);
                    cmd.Parameters.AddWithValue("@fecha_documento", datosDocumento.FechaDocumento);
                    cmd.Parameters.AddWithValue("@fecha_vencimiento", datosDocumento.FechaVencimiento);
                    cmd.Parameters.AddWithValue("@fecha_ingreso", datosDocumento.FechaIngreso);
                    cmd.Parameters.AddWithValue("@descripcion", datosDocumento.Descripcion);
                    cmd.Parameters.AddWithValue("@archivo_nombre", datosDocumento.ArchivoNombre);
                    cmd.Parameters.AddWithValue("@archivo_extencion", datosDocumento.ArchivoExtencion);
                    cmd.Parameters.AddWithValue("@archivo_tipo", datosDocumento.ArchivoTipo);
                    cmd.Parameters.AddWithValue("@estado", datosDocumento.Estado);

                    Documento_ENT oDatosDocumento = new Documento_ENT();
                    SqlDataReader reader          = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        datosDocumento.IdDocumento            = Convert.ToInt32(reader["id_documento"]);
                        datosDocumento.IdConjuntoHabitacional = reader["id_conjunto_habitacional"].Equals(DBNull.Value) ? 0 : Convert.ToInt32(reader["id_conjunto_habitacional"]);
                        datosDocumento.Folio            = reader["folio"].Equals(DBNull.Value) ? "" : reader["folio"].ToString();
                        datosDocumento.Nombre           = reader["nombre"].Equals(DBNull.Value) ? "" : Convert.ToString(reader["nombre"]);
                        datosDocumento.FechaDocumento   = reader["fecha_documento"].Equals(DBNull.Value) ? Convert.ToDateTime(null) : Convert.ToDateTime(reader["fecha_documento"]);
                        datosDocumento.FechaVencimiento = reader["fecha_vencimiento"].Equals(DBNull.Value) ? Convert.ToDateTime(null) : Convert.ToDateTime(reader["fecha_vencimiento"]);
                        datosDocumento.FechaIngreso     = reader["fecha_ingreso"].Equals(DBNull.Value) ? Convert.ToDateTime(null) : Convert.ToDateTime(reader["fecha_ingreso"]);
                        datosDocumento.Descripcion      = reader["descripcion"].Equals(DBNull.Value) ? "" : Convert.ToString(reader["descripcion"]);
                        datosDocumento.ArchivoNombre    = reader["archivo_nombre"].Equals(DBNull.Value) ? "" : Convert.ToString(reader["archivo_nombre"]);
                        datosDocumento.ArchivoExtencion = reader["archivo_extencion"].Equals(DBNull.Value) ? "" : Convert.ToString(reader["archivo_extencion"]);
                        datosDocumento.ArchivoTipo      = reader["archivo_tipo"].Equals(DBNull.Value) ? "" : Convert.ToString(reader["archivo_tipo"]);
                        datosDocumento.Estado           = reader["estado"].Equals(DBNull.Value) ? false : Convert.ToBoolean(reader["estado"]);
                    }
                    return(oDatosDocumento);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error al ejecutar SP_INSERT_DOCUMENTO", ex);
            }
        }
Пример #5
0
        public List <Documento_ENT> getAllByPage(Documento_ENT documento, int desde, int hasta, int all)
        {
            try
            {
                using (SqlConnection sqlConn = new SqlConnection(this.ConexionPH))
                {
                    sqlConn.Open();
                    SqlCommand cmd = new SqlCommand(this.ConexionPH, sqlConn);
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.CommandText = "sp_list_filtro_documento";
                    cmd.Parameters.AddWithValue("@id_conjunto_habitacional", documento.IdConjuntoHabitacional);
                    cmd.Parameters.AddWithValue("@folio", documento.Folio);
                    cmd.Parameters.AddWithValue("@nombre", documento.Nombre);
                    cmd.Parameters.AddWithValue("@fecha_documento", documento.FechaDocumento);
                    cmd.Parameters.AddWithValue("@fecha_vencimiento", documento.FechaVencimiento);
                    cmd.Parameters.AddWithValue("@desde", desde);
                    cmd.Parameters.AddWithValue("@hasta", hasta);
                    cmd.Parameters.AddWithValue("@all", all);
                    List <Documento_ENT> listDocumento = new List <Documento_ENT>();
                    SqlDataReader        reader        = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Documento_ENT datosDocumento = new Documento_ENT();
                        datosDocumento.IdDocumento            = Convert.ToInt32(reader["id_documento"]);
                        datosDocumento.IdConjuntoHabitacional = reader["id_conjunto_habitacional"].Equals(DBNull.Value) ? 0 : Convert.ToInt32(reader["id_conjunto_habitacional"]);
                        datosDocumento.Folio            = reader["folio"].Equals(DBNull.Value) ? "" : reader["folio"].ToString();
                        datosDocumento.Nombre           = reader["nombre"].Equals(DBNull.Value) ? "" : Convert.ToString(reader["nombre"]);
                        datosDocumento.FechaDocumento   = reader["fecha_documento"].Equals(DBNull.Value) ? Convert.ToDateTime(null) : Convert.ToDateTime(reader["fecha_documento"]);
                        datosDocumento.FechaVencimiento = reader["fecha_vencimiento"].Equals(DBNull.Value) ? Convert.ToDateTime(null) : Convert.ToDateTime(reader["fecha_vencimiento"]);
                        datosDocumento.FechaIngreso     = reader["fecha_ingreso"].Equals(DBNull.Value) ? Convert.ToDateTime(null) : Convert.ToDateTime(reader["fecha_ingreso"]);
                        datosDocumento.Descripcion      = reader["descripcion"].Equals(DBNull.Value) ? "" : Convert.ToString(reader["descripcion"]);
                        datosDocumento.ArchivoNombre    = reader["archivo_nombre"].Equals(DBNull.Value) ? "" : Convert.ToString(reader["archivo_nombre"]);
                        datosDocumento.ArchivoExtencion = reader["archivo_extencion"].Equals(DBNull.Value) ? "" : Convert.ToString(reader["archivo_extencion"]);
                        datosDocumento.ArchivoTipo      = reader["archivo_tipo"].Equals(DBNull.Value) ? "" : Convert.ToString(reader["archivo_tipo"]);
                        datosDocumento.Estado           = reader["estado"].Equals(DBNull.Value) ? false : Convert.ToBoolean(reader["estado"]);

                        listDocumento.Add(datosDocumento);
                    }
                    return(listDocumento);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error al ejecutar sp_list_filtro_documento", ex);
            }
        }
Пример #6
0
        public int update(Documento_ENT datosDocumento)
        {
            try
            {
                using (SqlConnection sqlConn = new SqlConnection(this.ConexionPH))
                {
                    sqlConn.Open();
                    SqlCommand cmd = new SqlCommand(this.ConexionPH, sqlConn);
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.CommandText = "SP_UPDATE_DOCUMENTO_IDDOCUMENTO";

                    cmd.Parameters.AddWithValue("@id_documento", datosDocumento.IdDocumento);
                    cmd.Parameters.AddWithValue("@id_conjunto_habitacional", datosDocumento.IdConjuntoHabitacional);
                    cmd.Parameters.AddWithValue("@folio", datosDocumento.Folio);
                    cmd.Parameters.AddWithValue("@nombre", datosDocumento.Nombre);
                    cmd.Parameters.AddWithValue("@fecha_documento", datosDocumento.FechaDocumento);
                    cmd.Parameters.AddWithValue("@fecha_vencimiento", datosDocumento.FechaVencimiento);
                    cmd.Parameters.AddWithValue("@fecha_ingreso", datosDocumento.FechaIngreso);
                    cmd.Parameters.AddWithValue("@descripcion", datosDocumento.Descripcion);
                    cmd.Parameters.AddWithValue("@archivo_nombre", datosDocumento.ArchivoNombre);
                    cmd.Parameters.AddWithValue("@archivo_extencion", datosDocumento.ArchivoExtencion);
                    cmd.Parameters.AddWithValue("@archivo_tipo", datosDocumento.ArchivoTipo);
                    cmd.Parameters.AddWithValue("@estado", datosDocumento.Estado);

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        this.error = reader["error"].Equals(1) ? 1 : 0;
                    }
                    return(this.error);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error al ejecutar SP_UPDATE_DOCUMENTO_IDDOCUMENTO", ex);
            }
        }
Пример #7
0
 public int delete(Documento_ENT datosDocumento)
 {
     try
     {
         using (SqlConnection sqlConn = new SqlConnection(this.ConexionPH))
         {
             sqlConn.Open();
             SqlCommand cmd = new SqlCommand(this.ConexionPH, sqlConn);
             cmd.CommandType = System.Data.CommandType.StoredProcedure;
             cmd.CommandText = "SP_DELETE_DOCUMENTO";
             cmd.Parameters.AddWithValue("@id_documento", datosDocumento.IdDocumento);
             SqlDataReader reader = cmd.ExecuteReader();
             while (reader.Read())
             {
                 this.error = reader["error"].Equals(1) ? 1 : 0;
             }
             return(this.error);
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Error al ejecutar SP_DELETE_DOCUMENTO", ex);
     }
 }
Пример #8
0
 public int update(Documento_ENT documento)
 {
     return(new Documento_DAO().update(documento));
 }
Пример #9
0
        public Documento_ENT getDocumentoID(Documento_ENT datosDocumento)
        {
            Documento_ENT oDocumento = new Documento_DAO().getForIdDocumento(datosDocumento);

            return(oDocumento);
        }
Пример #10
0
        public int deleteDocumento(Documento_ENT datosDocumento)
        {
            int error = new Documento_DAO().delete(datosDocumento);

            return(error);
        }
Пример #11
0
        public Documento_ENT insertDocumento(Documento_ENT datosDocumento)
        {
            Documento_ENT oDocumento = new Documento_DAO().insert(datosDocumento);

            return(oDocumento);
        }