Esempio n. 1
0
        public void delete(SqlConnection conn, Formadepago valueObject)
        {
            SqlCommand stmt = null;
            String     sql  = "";

            try {
                sql  = "DELETE FROM FORMA_DE_PAGO WHERE (ID = @ID )";
                stmt = new SqlCommand(sql, conn);
                stmt.Parameters.AddWithValue("@ID", valueObject.ID);

                int rowcount = databaseUpdate(stmt);
                if (rowcount == 0)
                {
                    throw new Exception("Object could not be deleted! (PrimaryKey not found)");
                }
                if (rowcount > 1)
                {
                    throw new Exception("PrimaryKey Error when updating DB! (Many objects were deleted!)");
                }
            } finally {
                if (stmt != null)
                {
                    stmt.Dispose();
                }
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("formadepagoID,Codigo,Descripcion")] Formadepago formadepago)
        {
            if (id != formadepago.formadepagoID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(formadepago);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FormadepagoExists(formadepago.formadepagoID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(formadepago));
        }
Esempio n. 3
0
        public void save(SqlConnection conn, Formadepago valueObject)
        {
            SqlCommand stmt = null;
            String     sql  = "";

            try {
                sql  = "UPDATE FORMA_DE_PAGO SET  FORMA_PAGO = @FORMA_PAGO  WHERE (ID= @ID)";
                stmt = new SqlCommand(sql, conn);
                if (valueObject.FORMA_PAGO != null && valueObject.FORMA_PAGO.Length <= 0)
                {
                    stmt.Parameters.AddWithValue("@FORMA_PAGO", valueObject.FORMA_PAGO);
                }
                else
                {
                    stmt.Parameters.AddWithValue("@FORMA_PAGO", DBNull.Value);
                }
                stmt.Parameters.AddWithValue("@ID", valueObject.ID);

                int rowcount = databaseUpdate(stmt);
                if (rowcount == 0)
                {
                    throw new Exception("Object could not be saved! (PrimaryKey not found)");
                }
            } finally {
                if (stmt != null)
                {
                    stmt.Dispose();
                }
            }
        }
Esempio n. 4
0
        private List <Formadepago> listQuery(SqlCommand stmt)
        {
            List <Formadepago> searchResults = new List <Formadepago>();
            SqlDataReader      reader        = null;

            try {
                int intt = 0; long longg = 0; double doublee = 0; DateTime datee;
                reader = stmt.ExecuteReader();
                while (reader.Read())
                {
                    Formadepago temp = createValueObject();

                    temp.ID         = reader["ID"] != null && int.TryParse(reader["ID"].ToString(), out intt) ? intt : 0;
                    temp.FORMA_PAGO = reader["FORMA_PAGO"] != null ? reader["FORMA_PAGO"].ToString() : null;
                    searchResults.Add(temp);
                }
            }
            finally {
                if (!reader.IsClosed)
                {
                    reader.Close();
                }
                if (stmt != null)
                {
                    stmt.Dispose();
                }
            }
            return(searchResults);
        }
Esempio n. 5
0
        public void create(SqlConnection conn, Formadepago valueObject)
        {
            String     sql  = "";
            SqlCommand stmt = null;

            try {
                sql = "INSERT INTO FORMA_DE_PAGO ( ID," +
                      " FORMA_PAGO)" +
                      "VALUES ( @ID, @FORMA_PAGO)";
                stmt = new SqlCommand(sql, conn);
                stmt.Parameters.AddWithValue("@ID", valueObject.ID);
                if (valueObject.FORMA_PAGO != null && valueObject.FORMA_PAGO.Length <= 0)
                {
                    stmt.Parameters.AddWithValue("@FORMA_PAGO", valueObject.FORMA_PAGO);
                }
                else
                {
                    stmt.Parameters.AddWithValue("@FORMA_PAGO", DBNull.Value);
                }



                databaseUpdate(stmt);
            } finally {
                if (stmt != null)
                {
                    stmt.Dispose();
                }
            }
        }
Esempio n. 6
0
        /**
         * Inserta nuevo registro en la tabla
         * @param Formadepago obj
         * @return Retorna el mismo objeto pero con la llave primaria configurada
         */
        public Formadepago crearFormadepago(Formadepago obj)
        {
            List <Formadepago> lista   = null;
            Formadepago        obj_new = new Formadepago();

            try {
                FormadepagoDao dao = new FormadepagoDao();
                conn = conexion.conection();
                //int id = Funciones.obtenerId(conn, "FORMA_DE_PAGO");
                //obj.ID = id;
                dao.create(conn, obj);
                //verificar existencia
                obj_new.FORMA_PAGO = obj.FORMA_PAGO;
                lista = dao.searchMatching(conn, obj_new);
                if (lista != null && lista.Count > 0)
                {
                    obj_new = (Formadepago)lista[0];
                }
                else
                {
                    obj_new.ID = -1;
                }
            } catch (Exception e) {
                obj_new.ID = -1;
            } finally {
                if (conn != null && conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(obj_new);
        }
Esempio n. 7
0
        /**
         * Busca los registros que coincidan con los datos enviados
         * @param Formadepago obj
         * @return Retorna la lista de los registros que coinciden
         */
        public Formadepago[] buscarFormadepago(Formadepago obj, int pagina, int numRegPagina)
        {
            Formadepago[]      result = null;
            List <Formadepago> lista  = null;

            if (pagina > 0 && numRegPagina > 0)
            {
                pagina--;
                int limInf = 0;
                int limSup = 0;
                limInf = pagina * numRegPagina + 1;
                limSup = (pagina + 1) * numRegPagina;
                try {
                    FormadepagoDao dao = new FormadepagoDao();
                    conn  = conexion.conection();
                    lista = dao.searchMatching(conn, obj, limInf, limSup);
                    if (lista != null && lista.Count > 0)
                    {
                        result = lista.ToArray();
                    }
                } catch (Exception e) {
                    result = null;
                } finally {
                    if (conn != null && conn.State == System.Data.ConnectionState.Open)
                    {
                        conn.Close();
                    }
                }
            }
            return(result);
        }
Esempio n. 8
0
        /**
         * Busca el primer registro que coincida con los datos enviados
         * @param Formadepago obj
         * @return Retorna el mismo objeto pero con los datos consultados
         */
        public Formadepago buscarPrimeroFormadepago(Formadepago obj)
        {
            List <Formadepago> lista = null;

            try {
                FormadepagoDao dao = new FormadepagoDao();
                conn  = conexion.conection();
                lista = dao.searchMatching(conn, obj);
                if (lista != null && lista.Count > 0)
                {
                    obj = (Formadepago)lista[0];
                }
                else
                {
                    obj.ID = -1;
                }
            } catch (Exception e) {
                obj.ID = -1;
            } finally {
                if (conn != null && conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(obj);
        }
 public bool editarFormadepago(Formadepago obj)
 {
     if (autenticacion != null && autenticacion.esValido())
     {
         return(gestionFormadepago.editarFormadepago(obj));
     }
     return(false);
 }
 public Formadepago[] buscarPaginacionFormadepago(Formadepago obj, int pag, int numReg)
 {
     if (autenticacion != null && autenticacion.esValido())
     {
         return(gestionFormadepago.buscarFormadepago(obj, pag, numReg));
     }
     return(null);
 }
 public Formadepago[] buscarFormadepago(Formadepago obj)
 {
     if (autenticacion != null && autenticacion.esValido())
     {
         return(gestionFormadepago.buscarFormadepago(obj));
     }
     return(null);
 }
 public int contarBusquedaFormadepago(Formadepago obj)
 {
     if (autenticacion != null && autenticacion.esValido())
     {
         return(gestionFormadepago.contarBusquedaFormadepago(obj));
     }
     return(-1);
 }
Esempio n. 13
0
        public async Task <IActionResult> Create([Bind("formadepagoID,Codigo,Descripcion")] Formadepago formadepago)
        {
            if (ModelState.IsValid)
            {
                _context.Add(formadepago);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(formadepago));
        }
Esempio n. 14
0
        public int countSearchMatching(SqlConnection conn, Formadepago valueObject)
        {
            bool   first = true;
            String sql   = "SELECT COUNT(*) FROM FORMA_DE_PAGO WHERE 1=1 ";

            if (valueObject.ID != null && valueObject.ID != 0)
            {
                if (first)
                {
                    first = false;
                }
                sql += "AND ID= " + valueObject.ID + " ";
            }

            if (!String.IsNullOrEmpty(valueObject.FORMA_PAGO))
            {
                if (first)
                {
                    first = false;
                }
                sql += "AND FORMA_PAGO= '" + valueObject.FORMA_PAGO + "' ";
            }

            SqlCommand    stmt    = null;
            SqlDataReader result  = null;
            int           allRows = 0;

            try
            {
                stmt   = new SqlCommand(sql, conn);
                result = stmt.ExecuteReader();
                if (result.Read())
                {
                    allRows = int.Parse(result[0].ToString());
                }
            }
            finally
            {
                if (!result.IsClosed)
                {
                    result.Close();
                }
                if (stmt != null)
                {
                    stmt.Dispose();
                }
            }
            return(allRows);
        }
Esempio n. 15
0
        public int contarBusquedaFormadepago(Formadepago obj)
        {
            int cantidad = -1;

            try {
                FormadepagoDao dao = new FormadepagoDao();
                conn     = conexion.conection();
                cantidad = dao.countSearchMatching(conn, obj);
            } catch (Exception e) {
                cantidad = -1;
            } finally {
                if (conn != null && conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(cantidad);
        }
Esempio n. 16
0
        /**
         * Edita un registro en la tabla
         * @param Formadepago obj
         * @return boolean indicando si se realizo o no la actualizacion
         */
        public bool editarFormadepago(Formadepago obj)
        {
            bool resultado;

            resultado = false;
            try {
                FormadepagoDao dao = new FormadepagoDao();
                conn = conexion.conection();
                dao.save(conn, obj);
                resultado = true;
            } catch (Exception e) {
                resultado = false;
            } finally {
                if (conn != null && conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(resultado);
        }
Esempio n. 17
0
        /**
         * Busca los registros que coincidan con los datos enviados
         * @param Formadepago obj
         * @return Retorna la lista de los registros que coinciden
         */
        public Formadepago[] buscarFormadepago(Formadepago obj)
        {
            Formadepago[]      result = null;
            List <Formadepago> lista  = null;

            try {
                FormadepagoDao dao = new FormadepagoDao();
                conn  = conexion.conection();
                lista = dao.searchMatching(conn, obj);
                if (lista != null && lista.Count > 0)
                {
                    result = lista.ToArray();
                }
            } catch (Exception e) {
                result = null;
            } finally {
                if (conn != null && conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(result);
        }
Esempio n. 18
0
        public List <Formadepago> searchMatching(SqlConnection conn, Formadepago valueObject, int limiteInf, int limiteSup)
        {
            List <Formadepago> searchResults = new List <Formadepago>();
            bool   first = true;
            String sql   = "SELECT * FROM FORMA_DE_PAGO WHERE 1=1 ";

            if (valueObject.ID != null && valueObject.ID != 0)
            {
                if (first)
                {
                    first = false;
                }
                sql += "AND ID= " + valueObject.ID + " ";
            }

            if (!String.IsNullOrEmpty(valueObject.FORMA_PAGO))
            {
                if (first)
                {
                    first = false;
                }
                sql += "AND FORMA_PAGO= '" + valueObject.FORMA_PAGO + "' ";
            }

            sql += ") AS CONSULTA WHERE RowNumber >=" + limiteInf + " AND RowNumber <=" + limiteSup;

            if (first)
            {
                searchResults = new List <Formadepago>();
            }
            else
            {
                searchResults = listQuery(new SqlCommand(sql, conn));
            }

            return(searchResults);
        }
Esempio n. 19
0
 public Formadepago buscarPrimeroFormadepago(Formadepago obj)
 {
     return(gestionFormadepago.buscarPrimeroFormadepago(obj));
 }
Esempio n. 20
0
 public Formadepago crearFormadepago(Formadepago obj)
 {
     return(gestionFormadepago.crearFormadepago(obj));
 }
Esempio n. 21
0
 public Formadepago[] buscarFormadepago(Formadepago obj)
 {
     return(gestionFormadepago.buscarFormadepago(obj));
 }
Esempio n. 22
0
 public Formadepago[] buscarPaginacionFormadepago(Formadepago obj, int pag, int numReg)
 {
     return(gestionFormadepago.buscarFormadepago(obj, pag, numReg));
 }
Esempio n. 23
0
 public int contarBusquedaFormadepago(Formadepago obj)
 {
     return(gestionFormadepago.contarBusquedaFormadepago(obj));
 }
Esempio n. 24
0
 public bool eliminarFormadepago(Formadepago obj)
 {
     return(gestionFormadepago.eliminarFormadepago(obj));
 }
Esempio n. 25
0
 public bool editarFormadepago(Formadepago obj)
 {
     return(gestionFormadepago.editarFormadepago(obj));
 }